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
22 ifdef BUILT_PRODUCTS_DIR
23 # if run within Xcode, add the just built tools to the command path
24 PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH}
25 COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH}
26 LD_PATH = ${BUILT_PRODUCTS_DIR}
27 LD = ${BUILT_PRODUCTS_DIR}/ld
28 OBJECTDUMP = ${BUILT_PRODUCTS_DIR}/ObjectDump
29 OBJCIMAGEINFO = ${BUILT_PRODUCTS_DIR}/objcimageinfo
30 MACHOCHECK = ${BUILT_PRODUCTS_DIR}/machocheck
31 REBASE = ${BUILT_PRODUCTS_DIR}/rebase
32 UNWINDDUMP = ${BUILT_PRODUCTS_DIR}/unwinddump
33 DYLDINFO = ${BUILT_PRODUCTS_DIR}/dyldinfo
35 ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
36 # if run from Terminal inside unit-test directory
37 RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd)
38 DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
39 PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
40 COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH}
43 OBJECTDUMP = ${DEBUGDIR}/ObjectDump
44 OBJCIMAGEINFO = ${DEBUGDIR}/objcimageinfo
45 MACHOCHECK = ${DEBUGDIR}/machocheck
46 REBASE = ${DEBUGDIR}/rebase
47 UNWINDDUMP = ${DEBUGDIR}/unwinddump
48 DYLDINFO = ${DEBUGDIR}/dyldinfo
50 PATH := ${MYDIR}:${PATH}:
51 COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
56 export GCC_EXEC_PREFIX=garbage
58 IOS_SDK = $(shell xcodebuild -sdk iphoneos.internal -version Path 2>/dev/null)
59 OSX_SDK = $(shell xcodebuild -sdk macosx.internal -version Path 2>/dev/null)
61 OSX_SDK = /Developer/SDKs/MacOSX10.6.sdk
64 CC = $(shell xcrun -find clang) -arch ${ARCH} -mmacosx-version-min=10.8 -isysroot $(OSX_SDK)
65 AS = $(shell xcrun -f as) -arch ${ARCH} -mmacosx-version-min=10.8
67 LDFLAGS = -syslibroot $(OSX_SDK)
69 VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
70 VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
71 LD_NEW_LINKEDIT = -macosx_version_min 10.6
73 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -mmacosx-version-min=10.9 -isysroot $(OSX_SDK)
74 CXXFLAGS = -Wall -stdlib=libc++
77 LDFLAGS := -syslibroot $(IOS_SDK)
78 override FILEARCH = arm
79 AS = $(shell xcrun -f as) -arch ${ARCH} -miphoneos-version-min=5.0
80 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
81 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
82 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
83 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
84 LD_SYSROOT = -syslibroot $(IOS_SDK)
85 LD_NEW_LINKEDIT = -ios_version_min 4.0
91 LDFLAGS := -syslibroot $(IOS_SDK)
92 override FILEARCH = arm
93 AS = $(shell xcrun -f as) -arch ${ARCH} -miphoneos-version-min=5.0
94 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
95 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
96 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
97 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
98 LD_SYSROOT = -syslibroot $(IOS_SDK)
99 LD_NEW_LINKEDIT = -ios_version_min 4.0
105 LDFLAGS := -syslibroot $(IOS_SDK)
108 override ARCH = armv6
109 override FILEARCH = arm
110 AS = $(shell xcrun -f as) -arch ${ARCH} -miphoneos-version-min=5.0
111 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
112 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
113 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
114 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
115 LD_SYSROOT = -syslibroot $(IOS_SDK)
116 LD_NEW_LINKEDIT = -ios_version_min 4.0
121 ifeq ($(ARCH),thumb2)
122 LDFLAGS := -syslibroot $(IOS_SDK)
125 override ARCH = armv7
126 override FILEARCH = arm
127 AS = $(shell xcrun -f as) -arch ${ARCH} -miphoneos-version-min=5.0
128 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
129 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
130 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
131 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
132 LD_SYSROOT = -syslibroot $(IOS_SDK)
133 LD_NEW_LINKEDIT = -ios_version_min 4.0
139 LDFLAGS := -syslibroot $(IOS_SDK)
140 AS = $(shell xcrun -f as) -arch ${ARCH} -miphoneos-version-min=5.0
141 CC = $(shell xcrun --sdk iphoneos.internal -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=9.0 -isysroot $(IOS_SDK)
142 CXX = $(shell xcrun --sdk iphoneos.internal -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=9.0 -isysroot $(IOS_SDK)
143 VERSION_NEW_LINKEDIT = -miphoneos-version-min=7.0
144 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
145 LD_SYSROOT = -syslibroot $(IOS_SDK)
146 LD_NEW_LINKEDIT = -ios_version_min 7.0
147 OTOOL = $(shell xcrun --sdk iphoneos.internal -find otool)
155 # utilites for Makefiles
156 PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
157 PASS_IFF_SUCCESS = ${PASS_IFF}
158 PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
159 PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
160 FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
161 FAIL_IFF_SUCCESS = ${FAIL_IFF}
162 PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
163 FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
164 FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
165 FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
166 FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
167 PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
168 FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
169 FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null