Makefile 5.01 KB
Newer Older
1 2 3 4 5 6 7 8 9
############################################################################
#
#		This is the GHC Makefile for MacOS X-specific targets
#
# Targets: 
#
#	framework-pkg  [MacOS only]
#		Builds /Library/Frameworks/GHC.framework wrapped into a Mac
#		installer package; must be executed in a ./configure'd tree
10 11 12 13 14
#		(--prefix doesn't matter as it will be overridden); other
#		./configure arguments are passed through, unless overwritten
#		with XCODE_EXTRA_CONFIGURE_ARGS.  A deployment target can
#		be specified by setting the corresponding ./configure
#		argument or by setting MACOSX_DEPLOYMENT_TARGET.
15 16 17 18 19 20 21 22
#
#	framework-binary-dist  [MacOS only]
#		Builds GHC.framework encapsulating a binary distribution
#		(to give a relocatable framework); must be used in a fully
#		built tree
#
############################################################################

23 24 25 26 27 28 29
include ../../mk/config.mk

ifeq "$(ProjectVersion)" ""
$(error Please run ./configure first)
endif

include ../../mk/custom-settings.mk
30 31 32 33 34 35 36 37 38 39 40 41 42

# The ProjectVersionInt is GHC's idea of an API version and hence determines
# the framework version.
FRAMEWORK_VERSION = $(ProjectVersionInt)

# Xcode requires CURRENT_PROJECT_VERSION to be an int or float.  We use this
# only as the build version (aka CFBundleVersion).
CURRENT_PROJECT_VERSION = $(ProjectVersionInt).$(ProjectPatchLevel)

# The user-visible CFBundleShortVersionString is set to the standard GHC 
# version number.
SHORT_VERSION_STRING = $(ProjectVersion)

43 44 45
# Name of the installer package
PACKAGE_NAME = GHC-$(ProjectVersion)-$(TargetArch_CPP).pkg

46 47
# Determine arguments that should be passed to ./configure from within Xcode
#
48
# By default, we pass whatever was used when the present tree was configured.
49 50 51 52 53 54 55 56 57 58 59
# The user can override this by setting XCODE_EXTRA_CONFIGURE_ARGS.  If
# MACOSX_DEPLOYMENT_TARGET is set, the target is added to whatever arguments
# are passed.
export XCODE_EXTRA_CONFIGURE_ARGS
ifeq "$(XCODE_EXTRA_CONFIGURE_ARGS)" ""
XCODE_EXTRA_CONFIGURE_ARGS = $(shell echo $(CONFIGURE_ARGS))
endif
ifneq "$(MACOSX_DEPLOYMENT_TARGET)" ""
XCODE_EXTRA_CONFIGURE_ARGS += --with-macosx-deployment-target=$(MACOSX_DEPLOYMENT_TARGET)
endif

60 61 62 63 64 65 66
# Determine whether we need to pass a "-target" option to packagemaker
#
# If a deployment target has been set, we use the same target for packagemaker.
ifneq "$(MACOSX_DEPLOYMENT_TARGET)" ""
PACKAGEMAKER_TARGET = -target $(MACOSX_DEPLOYMENT_TARGET)
endif

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
# Xcode's installation build product location (this is where the GHC.framework
# is assembled)
DSTROOT=/tmp/GHC.dst

# Tools directory for a system volume install
TOOLS_SYSTEM=$(DSTROOT)/Library/Frameworks/GHC.framework/Tools

PACKAGEMAKER=/Developer/usr/bin/packagemaker

# Build and package GHC.framework for /Library/Frameworks
#
# * Be careful to clean out Xcode's build product location first, as Xcode
#   sets permissions such that a second install on top of an existing one
#   fails
# * Make there are no contents component descriptions in the .pmdoc.  These are
#   created by the PackageMaker GUI and have per default the wrong ownership
#   and permissions for all files (as well as prevent correct setting of those
#   for files that are not in the content list).
85
framework-pkg:
86
	-chmod -fR u+w $(DSTROOT)
87 88 89
	-$(RM) -rf $(DSTROOT)
	mkdir -p $(TOOLS_SYSTEM)
	cp installer-scripts/Uninstaller $(TOOLS_SYSTEM)
90 91 92 93
	xcodebuild -target GHC-systemwide clean build\
		   CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
	    	   SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
	 	   FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
94 95
		   CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)\
		   COMMAND_MODE=unix2003
96
	xcodebuild -target GHC-systemwide install\
97 98 99
		   CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
	    	   SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
	 	   FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
100 101
		   CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)\
		   COMMAND_MODE=unix2003
102
	-$(RM) -f GHC-system.pmdoc/*-contents.xml
103 104
	$(PACKAGEMAKER) -v --doc GHC-system.pmdoc\
			$(PACKAGEMAKER_TARGET) -o $(TOP)/$(PACKAGE_NAME)
105

106 107 108 109 110 111
# If we don't specify COMMAND_MODE=unix2003 then xcodebuild defaults
# to setting it to legacy, which means that ar builds archives
# without a table of contents. That makes the build fail later on.



112 113 114 115 116 117 118
# Instead of making 'binary-dist' a Makefile dependency, we let xcodebuild call
# 'make binary-dist'.  This has the advantage that xcode knows the framework
# path into which the distribution should be installed and can instruct 
# binary-dist to put it directly into the right place without copying the whole
# tree yet another time.
#
framework-binary-dist:
119
	xcodebuild -target GHC-relocatable clean build\
120 121 122 123 124
		   CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
	    	   SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
	 	   FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
		   CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)
	@echo "FIXME: call the packager"; exit 1
125 126 127 128
	# FIXME: The approach with the binary-dist in the package has the
	# problem that the BOM is wrong and the installer relocation feature
	# isn't sufficient as the layout in the binary-dist and the installed
	# tree is different