1 # stuff to include in every test Makefile
5 # set default to be host
8 # set default to be all
9 VALID_ARCHS ?= "i386 x86_64 armv6"
12 MYDIR=$(shell cd ../../bin;pwd)
14 OBJECTDUMP = ObjectDump
15 OBJCIMAGEINFO = objcimageinfo
16 MACHOCHECK = machocheck
21 ifdef BUILT_PRODUCTS_DIR
22 # if run within Xcode, add the just built tools to the command path
23 PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH}
24 COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH}
25 LD_PATH = ${BUILT_PRODUCTS_DIR}
26 LD = ${BUILT_PRODUCTS_DIR}/ld
27 OBJECTDUMP = ${BUILT_PRODUCTS_DIR}/ObjectDump
28 OBJCIMAGEINFO = ${BUILT_PRODUCTS_DIR}/objcimageinfo
29 MACHOCHECK = ${BUILT_PRODUCTS_DIR}/machocheck
30 REBASE = ${BUILT_PRODUCTS_DIR}/rebase
31 UNWINDDUMP = ${BUILT_PRODUCTS_DIR}/unwinddump
32 DYLDINFO = ${BUILT_PRODUCTS_DIR}/dyldinfo
34 ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
35 # if run from Terminal inside unit-test directory
36 RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd)
37 DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
38 PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
39 COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH}
42 OBJECTDUMP = ${DEBUGDIR}/ObjectDump
43 OBJCIMAGEINFO = ${DEBUGDIR}/objcimageinfo
44 MACHOCHECK = ${DEBUGDIR}/machocheck
45 REBASE = ${DEBUGDIR}/rebase
46 UNWINDDUMP = ${DEBUGDIR}/unwinddump
47 DYLDINFO = ${DEBUGDIR}/dyldinfo
49 PATH := ${MYDIR}:${PATH}:
50 COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
55 export GCC_EXEC_PREFIX=garbage
57 IOS_SDK = $(shell xcodebuild -sdk iphoneos.internal -version Path 2>/dev/null)
58 OSX_SDK = $(shell xcodebuild -sdk macosx.internal -version Path 2>/dev/null)
60 OSX_SDK = /Developer/SDKs/MacOSX10.6.sdk
63 CC = $(shell xcrun -find clang) -arch ${ARCH} -mmacosx-version-min=10.8 -isysroot $(OSX_SDK)
65 LDFLAGS = -syslibroot $(OSX_SDK)
67 VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
68 VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
69 LD_NEW_LINKEDIT = -macosx_version_min 10.6
71 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -isysroot $(OSX_SDK)
72 CXXFLAGS = -Wall -stdlib=libc++
75 LDFLAGS := -syslibroot $(IOS_SDK)
76 override FILEARCH = arm
77 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
78 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
79 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
80 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
81 LD_SYSROOT = -syslibroot $(IOS_SDK)
82 LD_NEW_LINKEDIT = -ios_version_min 4.0
88 LDFLAGS := -syslibroot $(IOS_SDK)
89 override FILEARCH = arm
90 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
91 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
92 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
93 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
94 LD_SYSROOT = -syslibroot $(IOS_SDK)
95 LD_NEW_LINKEDIT = -ios_version_min 4.0
101 LDFLAGS := -syslibroot $(IOS_SDK)
104 override ARCH = armv6
105 override FILEARCH = arm
106 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
107 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
108 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
109 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
110 LD_SYSROOT = -syslibroot $(IOS_SDK)
111 LD_NEW_LINKEDIT = -ios_version_min 4.0
116 ifeq ($(ARCH),thumb2)
117 LDFLAGS := -syslibroot $(IOS_SDK)
120 override ARCH = armv7
121 override FILEARCH = arm
122 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
123 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
124 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
125 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
126 LD_SYSROOT = -syslibroot $(IOS_SDK)
127 LD_NEW_LINKEDIT = -ios_version_min 4.0
133 LDFLAGS := -syslibroot $(IOS_SDK)
134 CC = $(shell xcrun --sdk iphoneos.internal -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=9.0 -isysroot $(IOS_SDK)
135 CXX = $(shell xcrun --sdk iphoneos.internal -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=9.0 -isysroot $(IOS_SDK)
136 VERSION_NEW_LINKEDIT = -miphoneos-version-min=7.0
137 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
138 LD_SYSROOT = -syslibroot $(IOS_SDK)
139 LD_NEW_LINKEDIT = -ios_version_min 7.0
140 OTOOL = $(shell xcrun --sdk iphoneos.internal -find otool)
148 # utilites for Makefiles
149 PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
150 PASS_IFF_SUCCESS = ${PASS_IFF}
151 PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
152 PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
153 FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
154 FAIL_IFF_SUCCESS = ${FAIL_IFF}
155 PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
156 FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
157 FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
158 FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
159 FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
160 PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
161 FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
162 FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null