312fbd76a87d3bc353dd39933d8c311a2eaa01e4
[ghc-hetmet.git] / distrib / MacOS / Makefile
1 ############################################################################
2 #
3 #               This is the GHC Makefile for MacOS X-specific targets
4 #
5 # Targets: 
6 #
7 #       framework-pkg  [MacOS only]
8 #               Builds /Library/Frameworks/GHC.framework wrapped into a Mac
9 #               installer package; must be executed in a ./configure'd tree
10 #               (--prefix doesn't matter as it will be overridden); other
11 #               ./configure arguments are passed through, unless overwritten
12 #               with XCODE_EXTRA_CONFIGURE_ARGS.  A deployment target can
13 #               be specified by setting the corresponding ./configure
14 #               argument or by setting MACOSX_DEPLOYMENT_TARGET.
15 #
16 #       framework-binary-dist  [MacOS only]
17 #               Builds GHC.framework encapsulating a binary distribution
18 #               (to give a relocatable framework); must be used in a fully
19 #               built tree
20 #
21 ############################################################################
22
23 TOP=../..
24 include $(TOP)/mk/boilerplate.mk
25
26 # The ProjectVersionInt is GHC's idea of an API version and hence determines
27 # the framework version.
28 FRAMEWORK_VERSION = $(ProjectVersionInt)
29
30 # Xcode requires CURRENT_PROJECT_VERSION to be an int or float.  We use this
31 # only as the build version (aka CFBundleVersion).
32 CURRENT_PROJECT_VERSION = $(ProjectVersionInt).$(ProjectPatchLevel)
33
34 # The user-visible CFBundleShortVersionString is set to the standard GHC 
35 # version number.
36 SHORT_VERSION_STRING = $(ProjectVersion)
37
38 # Name of the installer package
39 PACKAGE_NAME = GHC-$(ProjectVersion)-$(TargetArch_CPP).pkg
40
41 # Determine arguments that should be passed to ./configure from within Xcode
42 #
43 # By default, we pass whatever was used whne the present tree was configured.
44 # The user can override this by setting XCODE_EXTRA_CONFIGURE_ARGS.  If
45 # MACOSX_DEPLOYMENT_TARGET is set, the target is added to whatever arguments
46 # are passed.
47 export XCODE_EXTRA_CONFIGURE_ARGS
48 ifeq "$(XCODE_EXTRA_CONFIGURE_ARGS)" ""
49 XCODE_EXTRA_CONFIGURE_ARGS = $(shell echo $(CONFIGURE_ARGS))
50 endif
51 ifneq "$(MACOSX_DEPLOYMENT_TARGET)" ""
52 XCODE_EXTRA_CONFIGURE_ARGS += --with-macosx-deployment-target=$(MACOSX_DEPLOYMENT_TARGET)
53 endif
54
55 # Xcode's installation build product location (this is where the GHC.framework
56 # is assembled)
57 DSTROOT=/tmp/GHC.dst
58
59 # Tools directory for a system volume install
60 TOOLS_SYSTEM=$(DSTROOT)/Library/Frameworks/GHC.framework/Tools
61
62 PACKAGEMAKER=/Developer/usr/bin/packagemaker
63
64 # Build and package GHC.framework for /Library/Frameworks
65 #
66 # * Be careful to clean out Xcode's build product location first, as Xcode
67 #   sets permissions such that a second install on top of an existing one
68 #   fails
69 # * Make there are no contents component descriptions in the .pmdoc.  These are
70 #   created by the PackageMaker GUI and have per default the wrong ownership
71 #   and permissions for all files (as well as prevent correct setting of those
72 #   for files that are not in the content list).
73 framework-pkg:
74         -chmod -fR u+w $(DSTROOT)
75         -$(RM) -rf $(DSTROOT)
76         mkdir -p $(TOOLS_SYSTEM)
77         cp installer-scripts/Uninstaller $(TOOLS_SYSTEM)
78         xcodebuild -target GHC-systemwide clean build install\
79                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
80                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
81                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
82                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)
83         -$(RM) -f GHC-system.pmdoc/*-contents.xml
84         $(PACKAGEMAKER) -v --doc GHC-system.pmdoc -o $(TOP)/$(PACKAGE_NAME)
85
86 # Instead of making 'binary-dist' a Makefile dependency, we let xcodebuild call
87 # 'make binary-dist'.  This has the advantage that xcode knows the framework
88 # path into which the distribution should be installed and can instruct 
89 # binary-dist to put it directly into the right place without copying the whole
90 # tree yet another time.
91 #
92 framework-binary-dist:
93         xcodebuild -target GHC-relocatable clean build\
94                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
95                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
96                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
97                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)
98         @echo "FIXME: call the packager"; exit 1
99         # FIXME: The approach with the binary-dist in the package has the
100         # problem that the BOM is wrong and the installer relocation feature
101         # isn't sufficient as the layout in the binary-dist and the installed
102         # tree is different