From 5b846fa36eee0f96c4c47128706d0131f8bb4113 Mon Sep 17 00:00:00 2001 From: Manuel M T Chakravarty Date: Thu, 21 Feb 2008 22:44:49 +0000 Subject: [PATCH] Mac OS X deployment target: piping opts through Makefiles --- aclocal.m4 | 28 ++++++++++++++-------------- compiler/Makefile | 9 +++++++++ configure.ac | 20 ++++++++++---------- libraries/Makefile | 7 +++++-- libraries/Makefile.local | 10 +++++++--- mk/config.mk.in | 15 +++++++++++++-- rts/Makefile | 5 +++++ utils/ghc-pkg/Makefile | 9 +++++++++ utils/hasktags/Makefile | 9 +++++++++ utils/hp2ps/Makefile | 3 +++ utils/hpc/Makefile | 9 +++++++++ utils/hsc2hs/Makefile | 9 +++++++++ utils/lndir/Makefile | 6 ++++++ utils/prof/cgprof/Makefile | 6 ++++++ utils/pwd/Makefile | 9 +++++++++ utils/runghc/Makefile | 9 +++++++++ utils/unlit/Makefile | 6 ++++++ 17 files changed, 138 insertions(+), 31 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index c72d15d..3df243f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1091,31 +1091,31 @@ AC_DEFUN([CHECK_GMP], 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]) - case $MACOS_DEPLOYMENT_TARGET in + case $FP_MACOSX_DEPLOYMENT_TARGET in 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 - if test "x$MACOS_DEPLOYMENT_TARGET" = "xnone"; then + if test "x$FP_MACOSX_DEPLOYMENT_TARGET" = "xnone"; then 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 - AC_MSG_RESULT([${MACOS_DEPLOYMENT_VERSION} (${MACOS_DEPLOYMENT_SDK})]) + AC_MSG_RESULT([${MACOSX_DEPLOYMENT_VERSION} (${MACOSX_DEPLOYMENT_SDK})]) fi fi ]) diff --git a/compiler/Makefile b/compiler/Makefile index 0095419..cdc8b3c 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -473,6 +473,15 @@ bootstrapped = NO 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 # diff --git a/configure.ac b/configure.ac index cab4f19..cd8b0ff 100644 --- a/configure.ac +++ b/configure.ac @@ -821,20 +821,20 @@ AC_SUBST(DotnetSupport) 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 - 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], -[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 diff --git a/libraries/Makefile b/libraries/Makefile index 9a8cd40..5af0f7e 100644 --- a/libraries/Makefile +++ b/libraries/Makefile @@ -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)) +DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \ + $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS)) .PHONY: subdirs @@ -176,7 +178,7 @@ installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS) 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 \ @@ -191,7 +193,8 @@ ifBuildable/ifBuildable: ifBuildable.hs 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 diff --git a/libraries/Makefile.local b/libraries/Makefile.local index e3e1e8f..57dbfef 100644 --- a/libraries/Makefile.local +++ b/libraries/Makefile.local @@ -1,5 +1,6 @@ # 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 @@ -15,5 +16,8 @@ AR := $(SAVE_AR) 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)) diff --git a/mk/config.mk.in b/mk/config.mk.in index da5d957..0e0a613 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -187,8 +187,19 @@ XMLDocWays= # 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 ################################################################################ # diff --git a/rts/Makefile b/rts/Makefile index db1c31e..d88a823 100644 --- a/rts/Makefile +++ b/rts/Makefile @@ -177,6 +177,11 @@ LIB_LD_OPTS = -L$(shell $(GHC_PKG_INPLACE) field base library-dirs | sed -e 's/l 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 = \" diff --git a/utils/ghc-pkg/Makefile b/utils/ghc-pkg/Makefile index 383524a..b27a2f1 100644 --- a/utils/ghc-pkg/Makefile +++ b/utils/ghc-pkg/Makefile @@ -4,6 +4,15 @@ include $(TOP)/mk/boilerplate.mk # ----------------------------------------------------------------------------- # 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: diff --git a/utils/hasktags/Makefile b/utils/hasktags/Makefile index aa81c13..20c52ba 100644 --- a/utils/hasktags/Makefile +++ b/utils/hasktags/Makefile @@ -1,6 +1,15 @@ 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" diff --git a/utils/hp2ps/Makefile b/utils/hp2ps/Makefile index 7952bbb..09c193f 100644 --- a/utils/hp2ps/Makefile +++ b/utils/hp2ps/Makefile @@ -1,6 +1,9 @@ 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 diff --git a/utils/hpc/Makefile b/utils/hpc/Makefile index a59aa09..3b1d731 100644 --- a/utils/hpc/Makefile +++ b/utils/hpc/Makefile @@ -1,6 +1,15 @@ 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" diff --git a/utils/hsc2hs/Makefile b/utils/hsc2hs/Makefile index ca3fcd0..7518841 100644 --- a/utils/hsc2hs/Makefile +++ b/utils/hsc2hs/Makefile @@ -5,6 +5,15 @@ 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 diff --git a/utils/lndir/Makefile b/utils/lndir/Makefile index c8223df..4334c0d 100644 --- a/utils/lndir/Makefile +++ b/utils/lndir/Makefile @@ -1,6 +1,12 @@ 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 diff --git a/utils/prof/cgprof/Makefile b/utils/prof/cgprof/Makefile index bac0ab7..acd71e9 100644 --- a/utils/prof/cgprof/Makefile +++ b/utils/prof/cgprof/Makefile @@ -1,6 +1,12 @@ 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) diff --git a/utils/pwd/Makefile b/utils/pwd/Makefile index c753ae8..0935a64 100644 --- a/utils/pwd/Makefile +++ b/utils/pwd/Makefile @@ -1,6 +1,15 @@ 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" diff --git a/utils/runghc/Makefile b/utils/runghc/Makefile index 654ffad..ef55c32 100644 --- a/utils/runghc/Makefile +++ b/utils/runghc/Makefile @@ -1,6 +1,15 @@ 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" diff --git a/utils/unlit/Makefile b/utils/unlit/Makefile index dfa1b8d..6323129 100644 --- a/utils/unlit/Makefile +++ b/utils/unlit/Makefile @@ -1,6 +1,12 @@ 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 -- 1.7.10.4