MacOS installer: terminate build on intermediate failure
[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 when 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 # Determine whether we need to pass a "-target" option to packagemaker
56 #
57 # If a deployment target has been set, we use the same target for packagemaker.
58 ifneq "$(MACOSX_DEPLOYMENT_TARGET)" ""
59 PACKAGEMAKER_TARGET = -target $(MACOSX_DEPLOYMENT_TARGET)
60 endif
61
62 # Xcode's installation build product location (this is where the GHC.framework
63 # is assembled)
64 DSTROOT=/tmp/GHC.dst
65
66 # Tools directory for a system volume install
67 TOOLS_SYSTEM=$(DSTROOT)/Library/Frameworks/GHC.framework/Tools
68
69 PACKAGEMAKER=/Developer/usr/bin/packagemaker
70
71 # Build and package GHC.framework for /Library/Frameworks
72 #
73 # * Be careful to clean out Xcode's build product location first, as Xcode
74 #   sets permissions such that a second install on top of an existing one
75 #   fails
76 # * Make there are no contents component descriptions in the .pmdoc.  These are
77 #   created by the PackageMaker GUI and have per default the wrong ownership
78 #   and permissions for all files (as well as prevent correct setting of those
79 #   for files that are not in the content list).
80 framework-pkg:
81         -chmod -fR u+w $(DSTROOT)
82         -$(RM) -rf $(DSTROOT)
83         mkdir -p $(TOOLS_SYSTEM)
84         cp installer-scripts/Uninstaller $(TOOLS_SYSTEM)
85         xcodebuild -target GHC-systemwide clean build\
86                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
87                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
88                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
89                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)
90         xcodebuild -target GHC-systemwide install\
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         -$(RM) -f GHC-system.pmdoc/*-contents.xml
96         $(PACKAGEMAKER) -v --doc GHC-system.pmdoc\
97                         $(PACKAGEMAKER_TARGET) -o $(TOP)/$(PACKAGE_NAME)
98
99 # Instead of making 'binary-dist' a Makefile dependency, we let xcodebuild call
100 # 'make binary-dist'.  This has the advantage that xcode knows the framework
101 # path into which the distribution should be installed and can instruct 
102 # binary-dist to put it directly into the right place without copying the whole
103 # tree yet another time.
104 #
105 framework-binary-dist:
106         xcodebuild -target GHC-relocatable clean build\
107                    CURRENT_PROJECT_VERSION=$(CURRENT_PROJECT_VERSION)\
108                    SHORT_VERSION_STRING=$(SHORT_VERSION_STRING)\
109                    FRAMEWORK_VERSION=$(FRAMEWORK_VERSION)\
110                    CURRENT_LIBRARY_VERSION=$(FRAMEWORK_VERSION)
111         @echo "FIXME: call the packager"; exit 1
112         # FIXME: The approach with the binary-dist in the package has the
113         # problem that the BOM is wrong and the installer relocation feature
114         # isn't sufficient as the layout in the binary-dist and the installed
115         # tree is different