]> git.saurik.com Git - apple/ld64.git/blame_incremental - unit-tests/include/common.makefile
ld64-224.1.tar.gz
[apple/ld64.git] / unit-tests / include / common.makefile
... / ...
CommitLineData
1# stuff to include in every test Makefile
2
3SHELL = /bin/sh
4
5# set default to be host
6ARCH ?= $(shell arch)
7
8# set default to be all
9VALID_ARCHS ?= "i386 x86_64 armv6"
10
11
12MYDIR=$(shell cd ../../bin;pwd)
13LD = ld
14OBJECTDUMP = ObjectDump
15MACHOCHECK = machocheck
16OTOOL = otool
17REBASE = rebase
18DYLDINFO = dyldinfo
19
20ifdef 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
31else
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
49endif
50export PATH
51export COMPILER_PATH
52export GCC_EXEC_PREFIX=garbage
53
54ifeq ($(ARCH),ppc)
55 SDKExtra = -isysroot /Developer/SDKs/MacOSX10.6.sdk
56endif
57
58CC = $(shell xcrun -find clang) -arch ${ARCH} ${SDKExtra}
59CCFLAGS = -Wall
60ASMFLAGS =
61VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
62VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
63LD_NEW_LINKEDIT = -macosx_version_min 10.6
64
65CXX = $(shell xcrun -find clang++) -arch ${ARCH} ${SDKExtra}
66CXXFLAGS = -Wall -stdlib=libc++
67
68IOS_SDK = $(shell xcodebuild -sdk iphoneos7.0.internal -version Path)
69
70ifeq ($(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
79else
80 FILEARCH = $(ARCH)
81endif
82
83ifeq ($(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
92else
93 FILEARCH = $(ARCH)
94endif
95
96ifeq ($(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
108else
109 FILEARCH = $(ARCH)
110endif
111
112ifeq ($(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
124else
125 FILEARCH = $(ARCH)
126endif
127
128ifeq ($(ARCH),arm64)
129 LDFLAGS := -syslibroot $(IOS_SDK)
130 CC = $(shell xcrun --sdk iphoneos.internal -find clang) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=7.0 -isysroot $(IOS_SDK)
131 CXX = $(shell xcrun --sdk iphoneos.internal -find clang++) -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=7.0 -isysroot $(IOS_SDK)
132 VERSION_NEW_LINKEDIT = -miphoneos-version-min=7.0
133 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
134 LD_SYSROOT = -syslibroot $(IOS_SDK)
135 LD_NEW_LINKEDIT = -ios_version_min 7.0
136else
137 FILEARCH = $(ARCH)
138endif
139
140RM = rm
141RMFLAGS = -rf
142
143# utilites for Makefiles
144PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
145PASS_IFF_SUCCESS = ${PASS_IFF}
146PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
147PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
148FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
149FAIL_IFF_SUCCESS = ${FAIL_IFF}
150PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
151FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
152FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
153FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
154FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
155PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
156FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
157FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null