]> git.saurik.com Git - apple/ld64.git/blame - unit-tests/include/common.makefile
ld64-274.1.tar.gz
[apple/ld64.git] / unit-tests / include / common.makefile
CommitLineData
d696c285
A
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
a645023d 9VALID_ARCHS ?= "i386 x86_64 armv6"
a61fdf0a 10
afe874b1 11
a61fdf0a 12MYDIR=$(shell cd ../../bin;pwd)
0a8dc3df
A
13LD = ld
14OBJECTDUMP = ObjectDump
15OBJCIMAGEINFO = objcimageinfo
16MACHOCHECK = machocheck
17OTOOL = xcrun otool
18REBASE = rebase
19DYLDINFO = dyldinfo
d696c285 20
d696c285 21ifdef 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 33else
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 52endif
a61fdf0a
A
53export PATH
54export COMPILER_PATH
afe874b1 55export GCC_EXEC_PREFIX=garbage
d696c285 56
0a8dc3df
A
57IOS_SDK = $(shell xcodebuild -sdk iphoneos.internal -version Path 2>/dev/null)
58OSX_SDK = $(shell xcodebuild -sdk macosx.internal -version Path 2>/dev/null)
a645023d 59ifeq ($(ARCH),ppc)
0a8dc3df 60 OSX_SDK = /Developer/SDKs/MacOSX10.6.sdk
a645023d 61endif
d696c285 62
0a8dc3df 63CC = $(shell xcrun -find clang) -arch ${ARCH} -mmacosx-version-min=10.8 -isysroot $(OSX_SDK)
afe874b1 64CCFLAGS = -Wall
0a8dc3df 65LDFLAGS = -syslibroot $(OSX_SDK)
d696c285 66ASMFLAGS =
afe874b1
A
67VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
68VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
69LD_NEW_LINKEDIT = -macosx_version_min 10.6
d696c285 70
0a8dc3df 71CXX = $(shell xcrun -find clang++) -arch ${ARCH} -isysroot $(OSX_SDK)
b1f7435d 72CXXFLAGS = -Wall -stdlib=libc++
d696c285 73
2f2f92e4 74ifeq ($(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
83else
84 FILEARCH = $(ARCH)
85endif
86
87ifeq ($(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
96else
97 FILEARCH = $(ARCH)
98endif
99
100ifeq ($(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
112else
113 FILEARCH = $(ARCH)
114endif
115
55e3d2f6 116ifeq ($(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
128else
129 FILEARCH = $(ARCH)
130endif
131
f80fe69f
A
132ifeq ($(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
141else
142 FILEARCH = $(ARCH)
143endif
a645023d 144
d696c285
A
145RM = rm
146RMFLAGS = -rf
147
148# utilites for Makefiles
55e3d2f6 149PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
a61fdf0a 150PASS_IFF_SUCCESS = ${PASS_IFF}
55e3d2f6
A
151PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
152PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
153FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
a61fdf0a 154FAIL_IFF_SUCCESS = ${FAIL_IFF}
55e3d2f6
A
155PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
156FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
157FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
158FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
159FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
a61fdf0a
A
160PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
161FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
162FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null