]> git.saurik.com Git - apple/ld64.git/blob - unit-tests/include/common.makefile
ld64-241.9.tar.gz
[apple/ld64.git] / unit-tests / include / common.makefile
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
9 VALID_ARCHS ?= "i386 x86_64 armv6"
10
11
12 MYDIR=$(shell cd ../../bin;pwd)
13 LD = ld
14 OBJECTDUMP = ObjectDump
15 MACHOCHECK = machocheck
16 OTOOL = xcrun otool
17 REBASE = rebase
18 DYLDINFO = dyldinfo
19
20 ifdef BUILT_PRODUCTS_DIR
21 # if run within Xcode, add the just built tools to the command path
22 PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH}
23 COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH}
24 LD_PATH = ${BUILT_PRODUCTS_DIR}
25 LD = ${BUILT_PRODUCTS_DIR}/ld
26 OBJECTDUMP = ${BUILT_PRODUCTS_DIR}/ObjectDump
27 MACHOCHECK = ${BUILT_PRODUCTS_DIR}/machocheck
28 REBASE = ${BUILT_PRODUCTS_DIR}/rebase
29 UNWINDDUMP = ${BUILT_PRODUCTS_DIR}/unwinddump
30 DYLDINFO = ${BUILT_PRODUCTS_DIR}/dyldinfo
31 else
32 ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
33 # if run from Terminal inside unit-test directory
34 RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd)
35 DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
36 PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
37 COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH}
38 LD_PATH = ${DEBUGDIR}
39 LD = ${DEBUGDIR}/ld
40 OBJECTDUMP = ${DEBUGDIR}/ObjectDump
41 MACHOCHECK = ${DEBUGDIR}/machocheck
42 REBASE = ${DEBUGDIR}/rebase
43 UNWINDDUMP = ${DEBUGDIR}/unwinddump
44 DYLDINFO = ${DEBUGDIR}/dyldinfo
45 else
46 PATH := ${MYDIR}:${PATH}:
47 COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
48 endif
49 endif
50 export PATH
51 export COMPILER_PATH
52 export GCC_EXEC_PREFIX=garbage
53
54 ifeq ($(ARCH),ppc)
55 SDKExtra = -isysroot /Developer/SDKs/MacOSX10.6.sdk
56 endif
57
58 CC = $(shell xcrun -find clang) -arch ${ARCH} ${SDKExtra}
59 CCFLAGS = -Wall
60 ASMFLAGS =
61 VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
62 VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
63 LD_NEW_LINKEDIT = -macosx_version_min 10.6
64
65 CXX = $(shell xcrun -find clang++) -arch ${ARCH} ${SDKExtra}
66 CXXFLAGS = -Wall -stdlib=libc++
67
68 IOS_SDK = $(shell xcodebuild -sdk iphoneos8.0.internal -version Path 2>/dev/null)
69
70 ifeq ($(ARCH),armv6)
71 LDFLAGS := -syslibroot $(IOS_SDK)
72 override FILEARCH = arm
73 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
74 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
75 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
76 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
77 LD_SYSROOT = -syslibroot $(IOS_SDK)
78 LD_NEW_LINKEDIT = -ios_version_min 4.0
79 else
80 FILEARCH = $(ARCH)
81 endif
82
83 ifeq ($(ARCH),armv7)
84 LDFLAGS := -syslibroot $(IOS_SDK)
85 override FILEARCH = arm
86 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
87 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
88 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
89 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
90 LD_SYSROOT = -syslibroot $(IOS_SDK)
91 LD_NEW_LINKEDIT = -ios_version_min 4.0
92 else
93 FILEARCH = $(ARCH)
94 endif
95
96 ifeq ($(ARCH),thumb)
97 LDFLAGS := -syslibroot $(IOS_SDK)
98 CCFLAGS += -mthumb
99 CXXFLAGS += -mthumb
100 override ARCH = armv6
101 override FILEARCH = arm
102 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
103 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
104 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
105 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
106 LD_SYSROOT = -syslibroot $(IOS_SDK)
107 LD_NEW_LINKEDIT = -ios_version_min 4.0
108 else
109 FILEARCH = $(ARCH)
110 endif
111
112 ifeq ($(ARCH),thumb2)
113 LDFLAGS := -syslibroot $(IOS_SDK)
114 CCFLAGS += -mthumb
115 CXXFLAGS += -mthumb
116 override ARCH = armv7
117 override FILEARCH = arm
118 CC = $(shell xcrun -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
119 CXX = $(shell xcrun -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
120 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
121 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
122 LD_SYSROOT = -syslibroot $(IOS_SDK)
123 LD_NEW_LINKEDIT = -ios_version_min 4.0
124 else
125 FILEARCH = $(ARCH)
126 endif
127
128 ifeq ($(ARCH),arm64)
129 LDFLAGS := -syslibroot $(IOS_SDK)
130 CC = /Applications/Xcode.app/Contents/Developer/Toolchains/iOS7.1.xctoolchain/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=7.0 -isysroot $(IOS_SDK)
131 #CC = $(shell xcrun --sdk iphoneos.internal -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=7.0 -isysroot $(IOS_SDK)
132 #CC = /Applications/Xcode.app/Contents/Developer/Toolchains/iOS7.0.xctoolchain/usr/bin/clang-loh -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=7.0 -isysroot $(IOS_SDK)
133 CXX = $(shell xcrun --sdk iphoneos.internal -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=7.0 -isysroot $(IOS_SDK)
134 VERSION_NEW_LINKEDIT = -miphoneos-version-min=7.0
135 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
136 LD_SYSROOT = -syslibroot $(IOS_SDK)
137 LD_NEW_LINKEDIT = -ios_version_min 7.0
138 OTOOL = /Applications/Xcode.app/Contents/Developer/Toolchains/iOS7.1.xctoolchain/usr/bin/otool
139 #OTOOL = $(shell xcrun --sdk iphoneos.internal -find otool)
140 else
141 FILEARCH = $(ARCH)
142 endif
143
144 RM = rm
145 RMFLAGS = -rf
146
147 # utilites for Makefiles
148 PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
149 PASS_IFF_SUCCESS = ${PASS_IFF}
150 PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
151 PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
152 FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
153 FAIL_IFF_SUCCESS = ${FAIL_IFF}
154 PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
155 FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
156 FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
157 FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
158 FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
159 PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
160 FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
161 FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null