Partially fix "make framework-pkg"
[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 include ../../mk/config.mk
24
25 ifeq "$(ProjectVersion)" ""
26 $(error Please run ./configure first)
27 endif
28
29 include ../../mk/custom-settings.mk
30
31 # The ProjectVersionInt is GHC's idea of an API version and hence determines
32 # the framework version.
33 FRAMEWORK_VERSION = $(ProjectVersionInt)
34
35 # Xcode requires CURRENT_PROJECT_VERSION to be an int or float.  We use this
36 # only as the build version (aka CFBundleVersion).
37 CURRENT_PROJECT_VERSION = $(ProjectVersionInt).$(ProjectPatchLevel)
38
39 # The user-visible CFBundleShortVersionString is set to the standard GHC 
40 # version number.
41 SHORT_VERSION_STRING = $(ProjectVersion)
42
43 # Name of the installer package
44 PACKAGE_NAME = GHC-$(ProjectVersion)-$(TargetArch_CPP).pkg
45
46 # Determine arguments that should be passed to ./configure from within Xcode
47 #
48 # By default, we pass whatever was used when the present tree was configured.
49 # The user can override this by setting XCODE_EXTRA_CONFIGURE_ARGS.  If
50 # MACOSX_DEPLOYMENT_TARGET is set, the target is added to whatever arguments
51 # are passed.
52 export XCODE_EXTRA_CONFIGURE_ARGS
53 ifeq "$(XCODE_EXTRA_CONFIGURE_ARGS)" ""
54 XCODE_EXTRA_CONFIGURE_ARGS = $(shell echo $(CONFIGURE_ARGS))
55 endif
56 ifneq "$(MACOSX_DEPLOYMENT_TARGET)" ""
57 XCODE_EXTRA_CONFIGURE_ARGS += --with-macosx-deployment-target=$(MACOSX_DEPLOYMENT_TARGET)
58 endif
59
60 # Determine whether we need to pass a "-target" option to packagemaker
61 #
62 # If a deployment target has been set, we use the same target for packagemaker.
63 ifneq "$(MACOSX_DEPLOYMENT_TARGET)" ""
64 PACKAGEMAKER_TARGET = -target $(MACOSX_DEPLOYMENT_TARGET)
65 endif
66
67 # Xcode's installation build product location (this is where the GHC.framework
68 # is assembled)
69 DSTROOT=/tmp/GHC.dst
70
71 # Tools directory for a system volume install
72 TOOLS_SYSTEM=$(DSTROOT)/Library/Frameworks/GHC.framework/Tools
73
74 PACKAGEMAKER=/Developer/usr/bin/packagemaker
75
76 # Build and package GHC.framework for /Library/Frameworks
77 #
78 # * Be careful to clean out Xcode's build product location first, as Xcode
79 #   sets permissions such that a second install on top of an existing one
80 #   fails
81 # * Make there are no contents component descriptions in the .pmdoc.  These are
82 #   created by the PackageMaker GUI and have per default the wrong ownership
83 #   and permissions for all files (as well as prevent correct setting of those
84 #   for files that are not in the content list).
85 framework-pkg:
86         -chmod -fR u+w $(DSTROOT)
87         -$(RM) -rf $(DSTROOT)
88         mkdir -p $(TOOLS_SYSTEM)
89         cp installer-scripts/Uninstaller $(TOOLS_SYSTEM)
90         xcodebuild -target GHC-systemwide clean build\
91                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
92                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
93                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
94                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)\
95                    COMMAND_MODE=unix2003
96         xcodebuild -target GHC-systemwide install\
97                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
98                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
99                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
100                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)\
101                    COMMAND_MODE=unix2003
102         -$(RM) -f GHC-system.pmdoc/*-contents.xml
103         $(PACKAGEMAKER) -v --doc GHC-system.pmdoc\
104                         $(PACKAGEMAKER_TARGET) -o $(TOP)/$(PACKAGE_NAME)
105
106 # If we don't specify COMMAND_MODE=unix2003 then xcodebuild defaults
107 # to setting it to legacy, which means that ar builds archives
108 # without a table of contents. That makes the build fail later on.
109
110
111
112 # Instead of making 'binary-dist' a Makefile dependency, we let xcodebuild call
113 # 'make binary-dist'.  This has the advantage that xcode knows the framework
114 # path into which the distribution should be installed and can instruct 
115 # binary-dist to put it directly into the right place without copying the whole
116 # tree yet another time.
117 #
118 framework-binary-dist:
119         xcodebuild -target GHC-relocatable clean build\
120                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
121                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
122                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
123                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)
124         @echo "FIXME: call the packager"; exit 1
125         # FIXME: The approach with the binary-dist in the package has the
126         # problem that the BOM is wrong and the installer relocation feature
127         # isn't sufficient as the layout in the binary-dist and the installed
128         # tree is different