Bugzilla Bug 302212: enable Mac OS X x86 builds to target SDKs. The patch NSS_3_10_BRANCH
authorwtchang%redhat.com
Thu, 25 Aug 2005 21:52:26 +0000
branchNSS_3_10_BRANCH
changeset 6050 4884bbd9aa71ece65b9fabc6dea337517bdc4870
parent 5996 7ff92bd59a6124f75dd2830edbd650789000ec0e
child 6052 375baa1807cda99d5d277e38b42f7a718900aa17
push idunknown
push userunknown
push dateunknown
bugs302212
Bugzilla Bug 302212: enable Mac OS X x86 builds to target SDKs. The patch is contributed by Mark Mentovai <mark@moxienet.com>. r=wtc,Josh Aas,Simon Fraser. Tag: NSS_3_10_BRANCH
security/coreconf/Darwin.mk
--- a/security/coreconf/Darwin.mk
+++ b/security/coreconf/Darwin.mk
@@ -46,40 +46,35 @@ RANLIB		= ranlib
 ifeq (86,$(findstring 86,$(OS_TEST)))
 OS_REL_CFLAGS	= -Di386
 CPU_ARCH	= i386
 else
 OS_REL_CFLAGS	= -Dppc
 CPU_ARCH	= ppc
 endif
 
-ifneq (,$(NEXT_ROOT))
+ifneq (,$(MACOS_SDK_DIR))
     GCC_VERSION_FULL := $(shell $(CC) -v 2>&1 | grep "gcc version" | sed -e "s/^.*gcc version[  ]*//" | awk '{ print $$1 }')
     GCC_VERSION_MAJOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$1 }')
     GCC_VERSION_MINOR := $(shell echo $(GCC_VERSION_FULL) | awk -F. '{ print $$2 }')
-    GCC_VERSION := $(GCC_VERSION_MAJOR).$(GCC_VERSION_MINOR)
-
-    DARWIN_SDK_CFLAGS := -nostdinc
+    GCC_VERSION = $(GCC_VERSION_MAJOR).$(GCC_VERSION_MINOR)
 
     ifeq (,$(filter-out 2 3,$(GCC_VERSION_MAJOR)))
         # GCC <= 3
-        DARWIN_TARGET_ARCH_LIB := darwin
-        DARWIN_SDK_CFLAGS += -isystem $(NEXT_ROOT)/usr/include/gcc/darwin/$(GCC_VERSION)
+        DARWIN_SDK_CFLAGS = -nostdinc -isystem $(MACOS_SDK_DIR)/usr/include/gcc/darwin/$(GCC_VERSION) -isystem $(MACOS_SDK_DIR)/usr/include -F$(MACOS_SDK_DIR)/System/Library/Frameworks
+        ifneq (,$(shell find $(MACOS_SDK_DIR)/Library/Frameworks -maxdepth 0))
+            DARWIN_SDK_CFLAGS += -F$(MACOS_SDK_DIR)/Library/Frameworks
+        endif
+        DARWIN_SDK_LDFLAGS = -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
+        NEXT_ROOT = $(MACOS_SDK_DIR)
+        export NEXT_ROOT
     else
         # GCC >= 4
-        CPU_ARCH_LONG := $(shell uname -p)
-        DARWIN_TARGET_ARCH_LIB := $(CPU_ARCH_LONG)-apple-darwin$(shell echo $NEXT_ROOT | perl -pe 's/MacOSX10\.([\d]*)//;if ($$1) {$$_=$$1+4;} else {$$_="'${OS_RELEASE}'";s/(\d+)//;$$_=$$1;}')
-        DARWIN_SDK_CFLAGS += -isystem $(NEXT_ROOT)/usr/lib/gcc/$(DARWIN_TARGET_ARCH_LIB)/$(GCC_VERSION_FULL)/include
-    endif
-
-    DARWIN_SDK_CFLAGS += -isystem $(NEXT_ROOT)/usr/include -F$(NEXT_ROOT)/System/Library/Frameworks
-    DARWIN_SDK_LDFLAGS := -L$(NEXT_ROOT)/usr/lib/gcc/$(DARWIN_TARGET_ARCH_LIB) -L$(NEXT_ROOT)/usr/lib/gcc/$(DARWIN_TARGET_ARCH_LIB)/$(GCC_VERSION_FULL) -L$(NEXT_ROOT)/usr/lib
-
-    ifneq (,$(shell find $(NEXT_ROOT)/Library/Frameworks -maxdepth 0))
-        DARWIN_SDK_CFLAGS += -F$(NEXT_ROOT)/Library/Frameworks
+        DARWIN_SDK_CFLAGS = -isysroot $(MACOS_SDK_DIR)
+        DARWIN_SDK_LDFLAGS = -Wl,-syslibroot,$(MACOS_SDK_DIR)
     endif
 
     LDFLAGS += $(DARWIN_SDK_LDFLAGS)
 endif
 
 # "Commons" are tentative definitions in a global scope, like this:
 #     int x;
 # The meaning of a common is ambiguous.  It may be a true definition:
@@ -93,16 +88,17 @@ endif
 OS_CFLAGS	= $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wmost -fpascal-strings -no-cpp-precomp -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS)
 
 ifdef BUILD_OPT
 OPTIMIZER	= -O2
 endif
 
 ARCH		= darwin
 
+DSO_CFLAGS	= -fPIC
 # May override this with -bundle to create a loadable module.
 DSO_LDOPTS	= -dynamiclib -compatibility_version 1 -current_version 1 -install_name @executable_path/$(notdir $@) -headerpad_max_install_names $(DARWIN_SDK_LDFLAGS)
 
 MKSHLIB		= $(CC) -arch $(CPU_ARCH) $(DSO_LDOPTS)
 DLL_SUFFIX	= dylib
 PROCESS_MAP_FILE = grep -v ';+' $(LIBRARY_NAME).def | grep -v ';-' | \
                 sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,^,_,' > $@