]>
Commit | Line | Data |
---|---|---|
d696c285 A |
1 | # stuff to include in every test Makefile |
2 | ||
3 | SHELL = /bin/sh | |
4 | ||
5 | # set default to be host | |
6 | ARCH ?= $(shell arch) | |
7 | ||
8 | # set default to be all | |
a645023d | 9 | VALID_ARCHS ?= "i386 x86_64 armv6" |
a61fdf0a | 10 | |
afe874b1 | 11 | |
a61fdf0a | 12 | MYDIR=$(shell cd ../../bin;pwd) |
0a8dc3df A |
13 | LD = ld |
14 | OBJECTDUMP = ObjectDump | |
15 | OBJCIMAGEINFO = objcimageinfo | |
16 | MACHOCHECK = machocheck | |
17 | OTOOL = xcrun otool | |
18 | REBASE = rebase | |
19 | DYLDINFO = dyldinfo | |
d696c285 | 20 | |
d696c285 | 21 | ifdef BUILT_PRODUCTS_DIR |
55e3d2f6 | 22 | # if run within Xcode, add the just built tools to the command path |
a61fdf0a | 23 | PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH} |
afe874b1 | 24 | COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH} |
0a8dc3df A |
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 | |
a61fdf0a | 33 | else |
2f2f92e4 | 34 | ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" "" |
55e3d2f6 | 35 | # if run from Terminal inside unit-test directory |
a645023d | 36 | RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd) |
55e3d2f6 | 37 | DEBUGDIR=$(shell cd ../../../build/Debug;pwd) |
a645023d | 38 | PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH} |
afe874b1 | 39 | COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH} |
0a8dc3df A |
40 | LD_PATH = ${DEBUGDIR} |
41 | LD = ${DEBUGDIR}/ld | |
42 | OBJECTDUMP = ${DEBUGDIR}/ObjectDump | |
43 | OBJCIMAGEINFO = ${DEBUGDIR}/objcimageinfo | |
44 | MACHOCHECK = ${DEBUGDIR}/machocheck | |
45 | REBASE = ${DEBUGDIR}/rebase | |
46 | UNWINDDUMP = ${DEBUGDIR}/unwinddump | |
47 | DYLDINFO = ${DEBUGDIR}/dyldinfo | |
2f2f92e4 A |
48 | else |
49 | PATH := ${MYDIR}:${PATH}: | |
50 | COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}: | |
51 | endif | |
d696c285 | 52 | endif |
a61fdf0a A |
53 | export PATH |
54 | export COMPILER_PATH | |
afe874b1 | 55 | export GCC_EXEC_PREFIX=garbage |
d696c285 | 56 | |
0a8dc3df A |
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) | |
a645023d | 59 | ifeq ($(ARCH),ppc) |
0a8dc3df | 60 | OSX_SDK = /Developer/SDKs/MacOSX10.6.sdk |
a645023d | 61 | endif |
d696c285 | 62 | |
0a8dc3df | 63 | CC = $(shell xcrun -find clang) -arch ${ARCH} -mmacosx-version-min=10.8 -isysroot $(OSX_SDK) |
afe874b1 | 64 | CCFLAGS = -Wall |
0a8dc3df | 65 | LDFLAGS = -syslibroot $(OSX_SDK) |
d696c285 | 66 | ASMFLAGS = |
afe874b1 A |
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 | |
d696c285 | 70 | |
0a8dc3df | 71 | CXX = $(shell xcrun -find clang++) -arch ${ARCH} -isysroot $(OSX_SDK) |
b1f7435d | 72 | CXXFLAGS = -Wall -stdlib=libc++ |
d696c285 | 73 | |
2f2f92e4 | 74 | ifeq ($(ARCH),armv6) |
afe874b1 | 75 | LDFLAGS := -syslibroot $(IOS_SDK) |
55e3d2f6 | 76 | override FILEARCH = arm |
b1f7435d A |
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) | |
afe874b1 A |
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 | |
55e3d2f6 A |
83 | else |
84 | FILEARCH = $(ARCH) | |
85 | endif | |
86 | ||
87 | ifeq ($(ARCH),armv7) | |
afe874b1 | 88 | LDFLAGS := -syslibroot $(IOS_SDK) |
2f2f92e4 | 89 | override FILEARCH = arm |
ebf6f434 A |
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) | |
afe874b1 A |
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 | |
2f2f92e4 A |
96 | else |
97 | FILEARCH = $(ARCH) | |
98 | endif | |
99 | ||
100 | ifeq ($(ARCH),thumb) | |
afe874b1 | 101 | LDFLAGS := -syslibroot $(IOS_SDK) |
2f2f92e4 A |
102 | CCFLAGS += -mthumb |
103 | CXXFLAGS += -mthumb | |
104 | override ARCH = armv6 | |
105 | override FILEARCH = arm | |
ebf6f434 A |
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) | |
afe874b1 A |
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 | |
2f2f92e4 A |
112 | else |
113 | FILEARCH = $(ARCH) | |
114 | endif | |
115 | ||
55e3d2f6 | 116 | ifeq ($(ARCH),thumb2) |
afe874b1 | 117 | LDFLAGS := -syslibroot $(IOS_SDK) |
55e3d2f6 A |
118 | CCFLAGS += -mthumb |
119 | CXXFLAGS += -mthumb | |
120 | override ARCH = armv7 | |
121 | override FILEARCH = arm | |
ebf6f434 A |
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) | |
afe874b1 A |
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 | |
55e3d2f6 A |
128 | else |
129 | FILEARCH = $(ARCH) | |
130 | endif | |
131 | ||
f80fe69f A |
132 | ifeq ($(ARCH),arm64) |
133 | LDFLAGS := -syslibroot $(IOS_SDK) | |
eaf282aa A |
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) | |
f80fe69f A |
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 | |
eaf282aa | 140 | OTOOL = $(shell xcrun --sdk iphoneos.internal -find otool) |
f80fe69f A |
141 | else |
142 | FILEARCH = $(ARCH) | |
143 | endif | |
a645023d | 144 | |
d696c285 A |
145 | RM = rm |
146 | RMFLAGS = -rf | |
147 | ||
148 | # utilites for Makefiles | |
55e3d2f6 | 149 | PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl |
a61fdf0a | 150 | PASS_IFF_SUCCESS = ${PASS_IFF} |
55e3d2f6 A |
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 | |
a61fdf0a | 154 | FAIL_IFF_SUCCESS = ${FAIL_IFF} |
55e3d2f6 A |
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 | |
a61fdf0a A |
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 |