]> git.saurik.com Git - apple/ld64.git/blobdiff - unit-tests/include/common.makefile
ld64-351.8.tar.gz
[apple/ld64.git] / unit-tests / include / common.makefile
index adb5468c1fba2b271daf573e85a2ee17bebefd71..c3a7864532d19c7a5576e09fe3b0b4417f12c409 100644 (file)
@@ -8,27 +8,28 @@ ARCH ?= $(shell arch)
 # set default to be all
 VALID_ARCHS ?= "i386 x86_64 armv6"
 
-IOS_SDK = /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.Internal.sdk
 
 MYDIR=$(shell cd ../../bin;pwd)
-LD                     = ld
-OBJECTDUMP     = ObjectDump
-MACHOCHECK     = machocheck
-OTOOL          = otool
-REBASE         = rebase
-DYLDINFO       = dyldinfo
+LD                             = ld
+OBJECTDUMP             = ObjectDump
+OBJCIMAGEINFO  = objcimageinfo
+MACHOCHECK             = machocheck
+OTOOL                  = xcrun otool
+REBASE                 = rebase
+DYLDINFO               = dyldinfo
 
 ifdef BUILT_PRODUCTS_DIR
        # if run within Xcode, add the just built tools to the command path
        PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH}
        COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH}
-       LD_PATH     = ${BUILT_PRODUCTS_DIR}
-       LD                      = ${BUILT_PRODUCTS_DIR}/ld
-       OBJECTDUMP      = ${BUILT_PRODUCTS_DIR}/ObjectDump
-       MACHOCHECK      = ${BUILT_PRODUCTS_DIR}/machocheck
-       REBASE          = ${BUILT_PRODUCTS_DIR}/rebase
-       UNWINDDUMP  = ${BUILT_PRODUCTS_DIR}/unwinddump
-       DYLDINFO        = ${BUILT_PRODUCTS_DIR}/dyldinfo
+       LD_PATH         = ${BUILT_PRODUCTS_DIR}
+       LD                              = ${BUILT_PRODUCTS_DIR}/ld
+       OBJECTDUMP              = ${BUILT_PRODUCTS_DIR}/ObjectDump
+       OBJCIMAGEINFO   = ${BUILT_PRODUCTS_DIR}/objcimageinfo
+       MACHOCHECK              = ${BUILT_PRODUCTS_DIR}/machocheck
+       REBASE                  = ${BUILT_PRODUCTS_DIR}/rebase
+       UNWINDDUMP      = ${BUILT_PRODUCTS_DIR}/unwinddump
+       DYLDINFO                = ${BUILT_PRODUCTS_DIR}/dyldinfo
 else
        ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
                # if run from Terminal inside unit-test directory
@@ -36,13 +37,14 @@ else
                DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
                PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
                COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH}
-               LD_PATH     = ${DEBUGDIR}
-               LD                      = ${DEBUGDIR}/ld
-               OBJECTDUMP      = ${DEBUGDIR}/ObjectDump
-               MACHOCHECK      = ${DEBUGDIR}/machocheck
-               REBASE          = ${DEBUGDIR}/rebase
-               UNWINDDUMP  = ${DEBUGDIR}/unwinddump
-               DYLDINFO        = ${DEBUGDIR}/dyldinfo
+               LD_PATH         = ${DEBUGDIR}
+               LD                              = ${DEBUGDIR}/ld
+               OBJECTDUMP              = ${DEBUGDIR}/ObjectDump
+               OBJCIMAGEINFO   = ${DEBUGDIR}/objcimageinfo
+               MACHOCHECK              = ${DEBUGDIR}/machocheck
+               REBASE                  = ${DEBUGDIR}/rebase
+               UNWINDDUMP      = ${DEBUGDIR}/unwinddump
+               DYLDINFO                = ${DEBUGDIR}/dyldinfo
        else
                PATH := ${MYDIR}:${PATH}:
                COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
@@ -52,25 +54,28 @@ export PATH
 export COMPILER_PATH
 export GCC_EXEC_PREFIX=garbage
 
+IOS_SDK = $(shell xcodebuild -sdk iphoneos.internal -version Path  2>/dev/null)
+OSX_SDK = $(shell xcodebuild -sdk macosx.internal -version Path  2>/dev/null)
 ifeq ($(ARCH),ppc)
-       SDKExtra = -isysroot /Developer/SDKs/MacOSX10.6.sdk
+       OSX_SDK = /Developer/SDKs/MacOSX10.6.sdk
 endif
 
-CC              = cc -arch ${ARCH} ${SDKExtra}
+CC              = $(shell xcrun -find clang) -arch ${ARCH} -mmacosx-version-min=10.8 -isysroot $(OSX_SDK)
 CCFLAGS = -Wall 
+LDFLAGS = -syslibroot $(OSX_SDK)
 ASMFLAGS =
 VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
 VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
 LD_NEW_LINKEDIT = -macosx_version_min 10.6
 
-CXX              = c++ -arch ${ARCH} ${SDKExtra}
-CXXFLAGS = -Wall
+CXX              = $(shell xcrun -find clang++) -arch ${ARCH} -isysroot $(OSX_SDK)
+CXXFLAGS = -Wall -stdlib=libc++ 
 
 ifeq ($(ARCH),armv6)
   LDFLAGS := -syslibroot $(IOS_SDK)
   override FILEARCH = arm
-  CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
-  CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK) 
+  CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK) 
   VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
   VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
   LD_SYSROOT = -syslibroot $(IOS_SDK)
@@ -82,8 +87,8 @@ endif
 ifeq ($(ARCH),armv7)
   LDFLAGS := -syslibroot $(IOS_SDK)
   override FILEARCH = arm
-  CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
-  CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
   VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
   VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
   LD_SYSROOT = -syslibroot $(IOS_SDK)
@@ -98,8 +103,8 @@ ifeq ($(ARCH),thumb)
   CXXFLAGS += -mthumb
   override ARCH = armv6
   override FILEARCH = arm
-  CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
-  CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
   VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
   VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
   LD_SYSROOT = -syslibroot $(IOS_SDK)
@@ -114,8 +119,8 @@ ifeq ($(ARCH),thumb2)
   CXXFLAGS += -mthumb
   override ARCH = armv7
   override FILEARCH = arm
-  CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
-  CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
+  CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
   VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
   VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
   LD_SYSROOT = -syslibroot $(IOS_SDK)
@@ -124,6 +129,18 @@ else
   FILEARCH = $(ARCH)
 endif
 
+ifeq ($(ARCH),arm64)
+  LDFLAGS := -syslibroot $(IOS_SDK)
+  CC  = $(shell xcrun --sdk iphoneos.internal -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=9.0 -isysroot $(IOS_SDK)
+  CXX = $(shell xcrun --sdk iphoneos.internal -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=9.0 -isysroot $(IOS_SDK)
+  VERSION_NEW_LINKEDIT = -miphoneos-version-min=7.0
+  VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
+  LD_SYSROOT = -syslibroot $(IOS_SDK)
+  LD_NEW_LINKEDIT = -ios_version_min 7.0
+  OTOOL =  $(shell xcrun --sdk iphoneos.internal -find otool)
+else
+  FILEARCH = $(ARCH)
+endif
 
 RM      = rm
 RMFLAGS = -rf