diff options
author | mark%moxienet.com <devnull@localhost> | 2006-01-05 15:40:16 +0000 |
---|---|---|
committer | mark%moxienet.com <devnull@localhost> | 2006-01-05 15:40:16 +0000 |
commit | d0433deb96b854d46a2088475409468aa2f9ab18 (patch) | |
tree | b6e69c8c300f88b553669c9a4c1a89782e650a7e | |
parent | 17ceae83a35a924e87267dcc0be6a655fe3ab474 (diff) | |
download | nspr-hg-d0433deb96b854d46a2088475409468aa2f9ab18.tar.gz |
302212 Mac OS X x86 and Xcode 2.2/gcc 4.0.1 builds can't target SDKs. Use -isysroot and -Wl,-syslibroot with gcc 4.0.0, -isysroot only with gcc 4.0.1. Core r=josh r=cls sr=bryner, NSPR and NSS r=josh sr=wtchang, all portions a=bsmedberg for 1.8.1 and 1.8.0.1.
-rw-r--r-- | config/autoconf.mk.in | 7 | ||||
-rw-r--r-- | configure.in | 140 | ||||
-rw-r--r-- | pr/src/linking/Makefile.in | 2 |
3 files changed, 100 insertions, 49 deletions
diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index a01a8e55..41ae1751 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -119,3 +119,10 @@ MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@ ifdef MACOSX_DEPLOYMENT_TARGET export MACOSX_DEPLOYMENT_TARGET endif + +MACOS_SDK_DIR = @MACOS_SDK_DIR@ + +NEXT_ROOT = @NEXT_ROOT@ +ifdef NEXT_ROOT +export NEXT_ROOT +endif diff --git a/configure.in b/configure.in index 3b2d9780..534f24f7 100644 --- a/configure.in +++ b/configure.in @@ -20,6 +20,7 @@ dnl dnl Contributor(s): dnl Christopher Seawood <cls@seawood.org> dnl Howard Chu <hyc@symas.com> +dnl Mark Mentovai <mark@moxienet.com> dnl dnl Alternatively, the contents of this file may be used under the dnl terms of the GNU General Public License Version 2 or later (the @@ -69,6 +70,8 @@ NOSUCHFILE=/no-such-file LIBNSPR='-L$(dist_libdir) -lnspr$(MOD_MAJOR_VERSION)' LIBPLC='-L$(dist_libdir) -lplc$(MOD_MAJOR_VERSION)' CYGWIN_WRAPPER= +MACOS_SDK_DIR= +NEXT_ROOT= dnl Link in libraries necessary to resolve all symbols for shared libs RESOLVE_LINK_SYMBOLS= @@ -226,6 +229,13 @@ AC_ARG_ENABLE(mdupdate, USE_MDUPDATE=1 fi ]) +dnl ======================================================== +dnl = Mac OS X SDK support +dnl ======================================================== +AC_ARG_WITH(macos-sdk, + [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)], + MACOS_SDK_DIR=$withval) + AC_ARG_ENABLE(macos-target, [ --enable-macos-target=VER Set the minimum MacOS version needed at runtime @@ -917,13 +927,16 @@ case "$target" in AC_DEFINE(DARWIN) AC_DEFINE(HAVE_BSD_FLOCK) CFLAGS="$CFLAGS -Wmost -fno-common" - if echo $OS_TEST | grep -c 86 2>/dev/null; then - AC_DEFINE(i386) - CPU_ARCH=i386 - else - AC_DEFINE(ppc) - CPU_ARCH=ppc - fi + case "${target_cpu}" in + i*86*) + AC_DEFINE(i386) + CPU_ARCH=i386 + ;; + *) + AC_DEFINE(ppc) + CPU_ARCH=ppc + ;; + esac DSO_CFLAGS=-fPIC DSO_LDOPTS='-dynamiclib -compatibility_version 1 -current_version 1 -all_load -install_name @executable_path/$@ -headerpad_max_install_names' # Use the standard preprocessor (cpp) @@ -961,52 +974,81 @@ case "$target" in ;; esac fi - fi - # do the right thing for SDK support - if test "$NEXT_ROOT"; then - dnl Synced to the MACOS_SDK_DIR block in Mozilla's top-level - dnl configure.in - - dnl Current known valid versions for GCC_VERSION are 2.95.2 3.1 3.3 4.0. - dnl 4.0 identifies itself as 4.0.x, so strip the decidecimal for - dnl the environment and includedir purposes (when using an SDK, below), - dnl but remember the full version number for the libdir (SDK). - - changequote(,) - CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` - GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'` - GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'` - changequote([,]) - GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'` - - if test "$GCC_VERSION_MAJOR" -lt "4" ; then - dnl gcc < 4.0 only supports PowerPC, OK to hard-code - TARGET_ARCH_LIB="darwin" - TARGET_ARCH_INCLUDE="ppc-darwin" - SDK_C_INCLUDE="-isystem ${NEXT_ROOT}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${NEXT_ROOT}/usr/include -F${NEXT_ROOT}/System/Library/Frameworks" - else - dnl If gcc >= 4, use cpu-apple-darwin#, where # is the version - dnl of the Darwin release corresponding to the target Mac OS X - dnl release. For OS X >= 10.1.1, take the minor version number and - dnl add 4 to get the Darwin major version number. If it can't be - dnl determined, use current Darwin major version number and hope - dnl that there's a symlink. - TARGET_ARCH_LIB=${target_cpu}-${target_vendor}-darwin`echo $NEXT_ROOT | $PERL -pe 's/MacOSX10\.([\d]*)//;if ($1) {$_=$1+4;} else {$_="'${target_os}'";s/(\d+)//;$_=$1;}'` - TARGET_ARCH_INCLUDE=$TARGET_ARCH_LIB - SDK_C_INCLUDE="-isystem ${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL}/include -isystem ${NEXT_ROOT}/usr/include -F${NEXT_ROOT}/System/Library/Frameworks" - fi + dnl MACOS_SDK_DIR will be set to the SDK location whenever one is + dnl in use. NEXT_ROOT will be set and exported if it's needed for + dnl ld. - if test -d "${NEXT_ROOT}/Library/Frameworks" ; then - SDK_C_INCLUDE="$SDK_C_INCLUDE -F${NEXT_ROOT}/Library/Frameworks" - fi + if test "$MACOS_SDK_DIR"; then + dnl Sync this section with the one in Mozilla's top level. - CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}" + if test ! -d "$MACOS_SDK_DIR"; then + AC_MSG_ERROR([SDK not found. When using --with-macos-sdk, you must +specify a valid SDK. SDKs are installed when the optional cross-development +tools are selected during the Xcode/Developer Tools installation.]) + fi - dnl CPP needs to be set for AC_CHECK_HEADER. - CPP="$CPP -nostdinc ${SDK_C_INCLUDE}" + changequote(,) + CC_VERSION=`$CC -v 2>&1 | grep 'gcc version'` + GCC_VERSION_FULL=`echo $CC_VERSION | $PERL -pe 's/^.*gcc version ([^ ]*).*/$1/'` + GCC_VERSION=`echo $GCC_VERSION_FULL | $PERL -pe '(split(/\./))[0]>=4&&s/(^\d*\.\d*).*/$1/;'` + changequote([,]) + GCC_VERSION_MAJOR=`echo $GCC_VERSION_FULL | $PERL -pe 's/(^\d*).*/$1/;'` + if test "$GCC_VERSION_MAJOR" -lt "4" ; then + SDK_C_FRAMEWORK="-F${MACOS_SDK_DIR}/System/Library/Frameworks" + if test -d "${MACOS_SDK_DIR}/Library/Frameworks" ; then + SDK_C_FRAMEWORK="$SDK_C_FRAMEWORK -F${MACOS_SDK_DIR}/Library/Frameworks" + fi - OS_LIBS="-L${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB} -L${NEXT_ROOT}/usr/lib/gcc/${TARGET_ARCH_LIB}/${GCC_VERSION_FULL} -L${NEXT_ROOT}/usr/lib $OS_LIBS" + SDK_C_INCLUDE="-isystem ${MACOS_SDK_DIR}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOS_SDK_DIR}/usr/include ${SDK_C_FRAMEWORK}" + + CFLAGS="$CFLAGS -nostdinc ${SDK_C_INCLUDE}" + + dnl CPP needs to be set for AC_CHECK_HEADER. + CPP="$CPP -nostdinc ${SDK_C_INCLUDE}" + + dnl ld support for -syslibroot is compiler-agnostic, but only + dnl available on Tiger. Although it's possible to switch on + dnl the build host's OS release to use ld -syslibroot when + dnl available, ld -syslibroot cause warnings as long as + dnl NEXT_ROOT is set. NEXT_ROOT should be set because both + dnl both the compiler and linker use it. + dnl + dnl LDFLAGS is for the utilities built in config (now and + dnl nsinstall). DSO_LDOPTS is used when linking shared + dnl libraries. + MACOS_SDK_LIBS="-L${MACOS_SDK_DIR}/usr/lib/gcc/darwin -L${MACOS_SDK_DIR}/usr/lib/gcc/darwin/${GCC_VERSION_FULL} -L${MACOS_SDK_DIR}/usr/lib ${SDK_C_FRAMEWORK}" + LDFLAGS="${MACOS_SDK_LIBS} $LDFLAGS" + DSO_LDOPTS="${MACOS_SDK_LIBS} $DSO_LDOPTS" + export NEXT_ROOT=$MACOS_SDK_DIR + else + dnl gcc >= 4.0 uses different paths than above, but knows + dnl how to find them itself. + CFLAGS="$CFLAGS -isysroot ${MACOS_SDK_DIR}" + + dnl CPP needs to be set for AC_CHECK_HEADER. + CPP="$CPP -isysroot ${MACOS_SDK_DIR}" + + dnl If gcc >= 4.0.0, we're guaranteed to be on Tiger, which + dnl has an ld that supports -syslibroot. Don't set + dnl NEXT_ROOT because it will be ignored and cause + dnl warnings when -syslibroot is specified. + dnl + dnl Both LDFLAGS and DSO_LDOPTS are set here, see the + dnl gcc < 4.0 case for the explanation. + if test "$GCC_VERSION_FULL" != "4.0.0" ; then + dnl gcc > 4.0.0 will pass -syslibroot to ld automatically + dnl based on the -isysroot it receives. + LDFLAGS="$LDFLAGS -isysroot ${MACOS_SDK_DIR}" + DSO_LDOPTS="$DSO_LDOPTS -isysroot ${MACOS_SDK_DIR}" + else + dnl gcc 4.0.0 doesn't pass -syslibroot to ld, it needs + dnl to be explicit. + LDFLAGS="$LDFLAGS -Wl,-syslibroot,${MACOS_SDK_DIR}" + DSO_LDOPTS="$DSO_LDOPTS -Wl,-syslibroot,${MACOS_SDK_DIR}" + fi + fi + fi fi ;; @@ -2659,6 +2701,8 @@ AC_SUBST(OS_DLLFLAGS) AC_SUBST(CYGWIN_WRAPPER) AC_SUBST(VISIBILITY_FLAGS) AC_SUBST(WRAP_SYSTEM_INCLUDES) +AC_SUBST(MACOS_SDK_DIR) +AC_SUBST(NEXT_ROOT) dnl ======================================================== dnl Generate output files. diff --git a/pr/src/linking/Makefile.in b/pr/src/linking/Makefile.in index 71fbf571..ee418453 100644 --- a/pr/src/linking/Makefile.in +++ b/pr/src/linking/Makefile.in @@ -69,7 +69,7 @@ endif # On Mac OS X use flat #includes. ifeq ($(OS_TARGET),MacOSX) -INCLUDES += -I$(NEXT_ROOT)/Developer/Headers/FlatCarbon +INCLUDES += -I$(MACOS_SDK_DIR)/Developer/Headers/FlatCarbon endif DEFINES += -D_NSPR_BUILD_ |