Mac OS X deployment target: piping opts through Makefiles
authorManuel M T Chakravarty <chak@cse.unsw.edu.au>
Thu, 21 Feb 2008 22:44:49 +0000 (22:44 +0000)
committerManuel M T Chakravarty <chak@cse.unsw.edu.au>
Thu, 21 Feb 2008 22:44:49 +0000 (22:44 +0000)
17 files changed:
aclocal.m4
compiler/Makefile
configure.ac
libraries/Makefile
libraries/Makefile.local
mk/config.mk.in
rts/Makefile
utils/ghc-pkg/Makefile
utils/hasktags/Makefile
utils/hp2ps/Makefile
utils/hpc/Makefile
utils/hsc2hs/Makefile
utils/lndir/Makefile
utils/prof/cgprof/Makefile
utils/pwd/Makefile
utils/runghc/Makefile
utils/unlit/Makefile

index c72d15d..3df243f 100644 (file)
@@ -1091,31 +1091,31 @@ AC_DEFUN([CHECK_GMP],
 AC_REQUIRE([AC_PROG_CC])
 ])
 
 AC_REQUIRE([AC_PROG_CC])
 ])
 
-# FP_MACOS_DEPLOYMENT_TARGET
-# --------------------------
-AC_DEFUN([FP_MACOS_DEPLOYMENT_TARGET],
+# FP_CHECK_MACOSX_DEPLOYMENT_TARGET
+# ---------------------------------
+AC_DEFUN([FP_CHECK_MACOSX_DEPLOYMENT_TARGET],
 [
 if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple"; then
   AC_MSG_CHECKING([Mac OS X deployment target])
 [
 if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple"; then
   AC_MSG_CHECKING([Mac OS X deployment target])
-  case $MACOS_DEPLOYMENT_TARGET in
+  case $FP_MACOSX_DEPLOYMENT_TARGET in
     none)  ;;
     none)  ;;
-    10.4)  MACOS_DEPLOYMENT_VERSION=10.4
-          MACOS_DEPLOYMENT_SDK=/Developer/SDKs/MacOSX10.4u.sdk
+    10.4)  MACOSX_DEPLOYMENT_VERSION=10.4
+          MACOSX_DEPLOYMENT_SDK=/Developer/SDKs/MacOSX10.4u.sdk
           ;;
           ;;
-    10.4u) MACOS_DEPLOYMENT_VERSION=10.4
-          MACOS_DEPLOYMENT_SDK=/Developer/SDKs/MacOSX10.4u.sdk
+    10.4u) MACOSX_DEPLOYMENT_VERSION=10.4
+          MACOSX_DEPLOYMENT_SDK=/Developer/SDKs/MacOSX10.4u.sdk
           ;;
           ;;
-    *)     MACOS_DEPLOYMENT_VERSION=$MACOS_DEPLOYMENT_TARGET
-          MACOS_DEPLOYMENT_SDK=/Developer/SDKs/MacOSX${MACOS_DEPLOYMENT_TARGET}.sdk
+    *)     MACOSX_DEPLOYMENT_VERSION=$FP_MACOSX_DEPLOYMENT_TARGET
+          MACOSX_DEPLOYMENT_SDK=/Developer/SDKs/MacOSX${FP_MACOSX_DEPLOYMENT_TARGET}.sdk
           ;;
   esac
           ;;
   esac
-  if test "x$MACOS_DEPLOYMENT_TARGET" = "xnone"; then
+  if test "x$FP_MACOSX_DEPLOYMENT_TARGET" = "xnone"; then
     AC_MSG_RESULT(none)
   else
     AC_MSG_RESULT(none)
   else
-    if test ! -d $MACOS_DEPLOYMENT_SDK; then
-      AC_MSG_ERROR([Unknown deployment target $MACOS_DEPLOYMENT_TARGET])
+    if test ! -d $MACOSX_DEPLOYMENT_SDK; then
+      AC_MSG_ERROR([Unknown deployment target $FP_MACOSX_DEPLOYMENT_TARGET])
     fi
     fi
-    AC_MSG_RESULT([${MACOS_DEPLOYMENT_VERSION} (${MACOS_DEPLOYMENT_SDK})])
+    AC_MSG_RESULT([${MACOSX_DEPLOYMENT_VERSION} (${MACOSX_DEPLOYMENT_SDK})])
   fi
 fi
 ])
   fi
 fi
 ])
index 0095419..cdc8b3c 100644 (file)
@@ -473,6 +473,15 @@ bootstrapped = NO
 endif
 endif
 
 endif
 endif
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifneq "$(findstring $(stage), 2 3)" ""
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 # -----------------------------------------------------------------------------
 # Building a compiler with interpreter support
 #
 # -----------------------------------------------------------------------------
 # Building a compiler with interpreter support
 #
index cab4f19..cd8b0ff 100644 (file)
@@ -821,20 +821,20 @@ AC_SUBST(DotnetSupport)
 
 dnl ** Mac OS X: explicit deployment target
 dnl --------------------------------------------------------------
 
 dnl ** Mac OS X: explicit deployment target
 dnl --------------------------------------------------------------
-AC_ARG_WITH([macos-deployment-target],
-[AC_HELP_STRING([--macos-deployment-target=VERSION],
-        [Build for Mac OS VERSION and higher  [default= version of build host]])],
-[MACOS_DEPLOYMENT_TARGET="$withval"
+AC_ARG_WITH([macosx-deployment-target],
+[AC_HELP_STRING([--with-macosx-deployment-target=VERSION],
+        [Build for Mac OS VERSION and higher  (default= version of build host)])],
+[FP_MACOSX_DEPLOYMENT_TARGET="$withval"
  if test "x$TargetOS_CPP-$TargetVendor_CPP" != "xdarwin-apple"; then
    # ignore everywhere, but on Mac OS
  if test "x$TargetOS_CPP-$TargetVendor_CPP" != "xdarwin-apple"; then
    # ignore everywhere, but on Mac OS
-   AC_MSG_WARN([--macos-deployment-target is only available on Mac OS X])
-   MACOS_DEPLOYMENT_TARGET=none
+   AC_MSG_WARN([--macosx-deployment-target is only available on Mac OS X])
+   FP_MACOSX_DEPLOYMENT_TARGET=none
  fi],
  fi],
-[MACOS_DEPLOYMENT_TARGET=none]
+[FP_MACOSX_DEPLOYMENT_TARGET=none]
 )
 )
-FP_MACOS_DEPLOYMENT_TARGET
-AC_SUBST(MACOS_DEPLOYMENT_VERSION)
-AC_SUBST(MACOS_DEPLOYMENT_SDK)
+FP_CHECK_MACOSX_DEPLOYMENT_TARGET
+AC_SUBST(MACOSX_DEPLOYMENT_VERSION)
+AC_SUBST(MACOSX_DEPLOYMENT_SDK)
 
 dnl --------------------------------------------------------------
 dnl End of configure script option section
 
 dnl --------------------------------------------------------------
 dnl End of configure script option section
index 9a8cd40..5af0f7e 100644 (file)
@@ -143,6 +143,8 @@ BOOTSTRAP_LIBS = Cabal filepath
 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
 BOOTSTRAP_INC_1_UP = -DCABAL_VERSION=1,3 $(addprefix -i../bootstrapping.,$(BOOTSTRAP_LIBS))
 BOOTSTRAP_INC_2_UP = -DCABAL_VERSION=1,3 $(addprefix -i../../bootstrapping.,$(BOOTSTRAP_LIBS))
 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
 BOOTSTRAP_INC_1_UP = -DCABAL_VERSION=1,3 $(addprefix -i../bootstrapping.,$(BOOTSTRAP_LIBS))
 BOOTSTRAP_INC_2_UP = -DCABAL_VERSION=1,3 $(addprefix -i../../bootstrapping.,$(BOOTSTRAP_LIBS))
+DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \
+                 $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
 
 .PHONY: subdirs
 
 
 .PHONY: subdirs
 
@@ -176,7 +178,7 @@ installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
 ifeq "$(stage)" "2"
        cd installPackage && ../$(HC) -Wall -cpp \
                                    --make installPackage -o installPackage \
 ifeq "$(stage)" "2"
        cd installPackage && ../$(HC) -Wall -cpp \
                                    --make installPackage -o installPackage \
-                                   $(BOOTSTRAP_INC_1_UP)
+                                   $(BOOTSTRAP_INC_1_UP) $(DEPLOYMENT_OPTS)
 else
        cd installPackage && $(GHC) -Wall -cpp \
                                    --make installPackage -o installPackage \
 else
        cd installPackage && $(GHC) -Wall -cpp \
                                    --make installPackage -o installPackage \
@@ -191,7 +193,8 @@ ifBuildable/ifBuildable: ifBuildable.hs
        mkdir ifBuildable
        $(CP) ifBuildable.hs ifBuildable/
 ifeq "$(stage)" "2"
        mkdir ifBuildable
        $(CP) ifBuildable.hs ifBuildable/
 ifeq "$(stage)" "2"
-       cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable
+       cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable \
+                                $(DEPLOYMENT_OPTS)
 else
        cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
 endif
 else
        cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
 endif
index e3e1e8f..57dbfef 100644 (file)
@@ -1,5 +1,6 @@
 # Local GHC-build-tree customization for Cabal makefiles.  We want to build
 # Local GHC-build-tree customization for Cabal makefiles.  We want to build
-# libraries using flags that the user has put in build.mk/validate.mk.
+# libraries using flags that the user has put in build.mk/validate.mk and
+# appropriate flags for Mac OS X deployment targets.
 
 # Careful here: including boilerplate.mk breaks things, because paths.mk and
 # opts.mk overrides some of the variable settings in the Cabal Makefile, so
 
 # Careful here: including boilerplate.mk breaks things, because paths.mk and
 # opts.mk overrides some of the variable settings in the Cabal Makefile, so
@@ -15,5 +16,8 @@ AR  := $(SAVE_AR)
 LD  := $(SAVE_LD)
 
 # Now add flags from the GHC build system to the Cabal build:
 LD  := $(SAVE_LD)
 
 # Now add flags from the GHC build system to the Cabal build:
-GHC_OPTS += $(SRC_HC_OPTS)
-GHC_OPTS += $(GhcLibHcOpts)
+GHC_CC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+GHC_OPTS    += $(SRC_HC_OPTS)
+GHC_OPTS    += $(GhcLibHcOpts)
+GHC_OPTS    += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+LIB_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
index da5d957..0e0a613 100644 (file)
@@ -187,8 +187,19 @@ XMLDocWays=
 
 # Mac OS X deployment target (to cross-compile for older OS versions)
 #
 
 # Mac OS X deployment target (to cross-compile for older OS versions)
 #
-MACOS_DEPLOYMENT_VERSION = @MACOS_DEPLOYMENT_VERSION@
-MACOS_DEPLOYMENT_SDK = @MACOS_DEPLOYMENT_SDK@
+MACOSX_DEPLOYMENT_VERSION = @MACOSX_DEPLOYMENT_VERSION@
+MACOSX_DEPLOYMENT_SDK = @MACOSX_DEPLOYMENT_SDK@
+
+ifneq "$(MACOSX_DEPLOYMENT_VERSION)" ""
+MACOSX_DEPLOYMENT_CC_OPTS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_VERSION) \
+                           -isysroot $(MACOSX_DEPLOYMENT_SDK)
+MACOSX_DEPLOYMENT_LD_OPTS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_VERSION) \
+                           -Wl,-syslibroot,$(MACOSX_DEPLOYMENT_SDK)
+# We don't extend SRC_CC_OPTS and friends here directly, as (a) they may get
+# overwritten in build.mk and (b) we must not use the deployment options in
+# stage 1 or we get a linker error if the bootstrap compiler is for a more 
+# recent OS version.
+endif
 
 ################################################################################
 #
 
 ################################################################################
 #
index db1c31e..d88a823 100644 (file)
@@ -177,6 +177,11 @@ LIB_LD_OPTS = -L$(shell $(GHC_PKG_INPLACE) field base library-dirs | sed -e 's/l
 endif
 endif
 
 endif
 endif
 
+# Mac OS X: make sure we compile for the right OS version
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+LIB_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+
 # XXX DQ is now the same on all platforms, so get rid of it
 DQ = \"
 
 # XXX DQ is now the same on all platforms, so get rid of it
 DQ = \"
 
index 383524a..b27a2f1 100644 (file)
@@ -4,6 +4,15 @@ include $(TOP)/mk/boilerplate.mk
 # -----------------------------------------------------------------------------
 # ghc-pkg.bin
 
 # -----------------------------------------------------------------------------
 # ghc-pkg.bin
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches
 
 # This causes libghccompat.a to be used:
 SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches
 
 # This causes libghccompat.a to be used:
index aa81c13..20c52ba 100644 (file)
@@ -1,6 +1,15 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
index 7952bbb..09c193f 100644 (file)
@@ -1,6 +1,9 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS)
+
 C_PROG         = hp2ps
 
 SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -Wall
 C_PROG         = hp2ps
 
 SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -Wall
index a59aa09..3b1d731 100644 (file)
@@ -1,6 +1,15 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
index ca3fcd0..7518841 100644 (file)
@@ -5,6 +5,15 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 # This causes libghccompat.a to be used:
 include $(GHC_COMPAT_DIR)/compat.mk
 
 # This causes libghccompat.a to be used:
 include $(GHC_COMPAT_DIR)/compat.mk
 
index c8223df..4334c0d 100644 (file)
@@ -1,6 +1,12 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Exclude for booting
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS)
+endif
+
 C_SRCS=lndir.c
 C_PROG=lndir
 
 C_SRCS=lndir.c
 C_PROG=lndir
 
index bac0ab7..acd71e9 100644 (file)
@@ -1,6 +1,12 @@
 TOP=../../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../../..
 include $(TOP)/mk/boilerplate.mk
 
+# Exclude for booting
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS)
+endif
+
 C_PROG = cgprof
 INSTALL_LIBEXECS=$(C_PROG)
 
 C_PROG = cgprof
 INSTALL_LIBEXECS=$(C_PROG)
 
index c753ae8..0935a64 100644 (file)
@@ -1,6 +1,15 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
index 654ffad..ef55c32 100644 (file)
@@ -1,6 +1,15 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Beyond stage 1, honour any Mac OS X depolyment target options.  If we use 
+# these options in stage 1 we get a linker error if the bootstrap compiler is
+#  for a more recent OS version
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
+SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
+endif
+
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
 # We have two version: the inplace version compiled by the bootstrap compiler
 #   and the install version compiled by the stage 1 compiler
 ifeq "$(stage)" "2"
index dfa1b8d..6323129 100644 (file)
@@ -1,6 +1,12 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 
+# Exclude for booting
+ifeq "$(stage)" "2"
+SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
+SRC_LD_OPTS += $(MACOSX_DEPLOYMENT_LD_OPTS)
+endif
+
 C_SRCS=unlit.c
 C_PROG=unlit
 SRC_CC_OPTS += -O
 C_SRCS=unlit.c
 C_PROG=unlit
 SRC_CC_OPTS += -O