]> git.saurik.com Git - apple/ld64.git/blame - unit-tests/include/common.makefile
ld64-224.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)
55e3d2f6
A
13LD = ld
14OBJECTDUMP = ObjectDump
15MACHOCHECK = machocheck
16OTOOL = otool
17REBASE = rebase
a645023d 18DYLDINFO = dyldinfo
d696c285 19
d696c285 20ifdef BUILT_PRODUCTS_DIR
55e3d2f6 21 # if run within Xcode, add the just built tools to the command path
a61fdf0a 22 PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH}
afe874b1
A
23 COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH}
24 LD_PATH = ${BUILT_PRODUCTS_DIR}
55e3d2f6
A
25 LD = ${BUILT_PRODUCTS_DIR}/ld
26 OBJECTDUMP = ${BUILT_PRODUCTS_DIR}/ObjectDump
27 MACHOCHECK = ${BUILT_PRODUCTS_DIR}/machocheck
28 REBASE = ${BUILT_PRODUCTS_DIR}/rebase
a645023d
A
29 UNWINDDUMP = ${BUILT_PRODUCTS_DIR}/unwinddump
30 DYLDINFO = ${BUILT_PRODUCTS_DIR}/dyldinfo
a61fdf0a 31else
2f2f92e4 32 ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
55e3d2f6 33 # if run from Terminal inside unit-test directory
a645023d 34 RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd)
55e3d2f6 35 DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
a645023d 36 PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
afe874b1
A
37 COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH}
38 LD_PATH = ${DEBUGDIR}
a645023d
A
39 LD = ${DEBUGDIR}/ld
40 OBJECTDUMP = ${DEBUGDIR}/ObjectDump
41 MACHOCHECK = ${DEBUGDIR}/machocheck
42 REBASE = ${DEBUGDIR}/rebase
43 UNWINDDUMP = ${DEBUGDIR}/unwinddump
44 DYLDINFO = ${DEBUGDIR}/dyldinfo
2f2f92e4
A
45 else
46 PATH := ${MYDIR}:${PATH}:
47 COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
48 endif
d696c285 49endif
a61fdf0a
A
50export PATH
51export COMPILER_PATH
afe874b1 52export GCC_EXEC_PREFIX=garbage
d696c285 53
a645023d
A
54ifeq ($(ARCH),ppc)
55 SDKExtra = -isysroot /Developer/SDKs/MacOSX10.6.sdk
56endif
d696c285 57
ebf6f434 58CC = $(shell xcrun -find clang) -arch ${ARCH} ${SDKExtra}
afe874b1 59CCFLAGS = -Wall
d696c285 60ASMFLAGS =
afe874b1
A
61VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
62VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
63LD_NEW_LINKEDIT = -macosx_version_min 10.6
d696c285 64
ebf6f434 65CXX = $(shell xcrun -find clang++) -arch ${ARCH} ${SDKExtra}
b1f7435d 66CXXFLAGS = -Wall -stdlib=libc++
d696c285 67
d425e388 68IOS_SDK = $(shell xcodebuild -sdk iphoneos7.0.internal -version Path)
ebf6f434 69
2f2f92e4 70ifeq ($(ARCH),armv6)
afe874b1 71 LDFLAGS := -syslibroot $(IOS_SDK)
55e3d2f6 72 override FILEARCH = arm
b1f7435d
A
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)
afe874b1
A
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
55e3d2f6
A
79else
80 FILEARCH = $(ARCH)
81endif
82
83ifeq ($(ARCH),armv7)
afe874b1 84 LDFLAGS := -syslibroot $(IOS_SDK)
2f2f92e4 85 override FILEARCH = arm
ebf6f434
A
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)
afe874b1
A
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
2f2f92e4
A
92else
93 FILEARCH = $(ARCH)
94endif
95
96ifeq ($(ARCH),thumb)
afe874b1 97 LDFLAGS := -syslibroot $(IOS_SDK)
2f2f92e4
A
98 CCFLAGS += -mthumb
99 CXXFLAGS += -mthumb
100 override ARCH = armv6
101 override FILEARCH = arm
ebf6f434
A
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)
afe874b1
A
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
2f2f92e4
A
108else
109 FILEARCH = $(ARCH)
110endif
111
55e3d2f6 112ifeq ($(ARCH),thumb2)
afe874b1 113 LDFLAGS := -syslibroot $(IOS_SDK)
55e3d2f6
A
114 CCFLAGS += -mthumb
115 CXXFLAGS += -mthumb
116 override ARCH = armv7
117 override FILEARCH = arm
ebf6f434
A
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)
afe874b1
A
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
55e3d2f6
A
124else
125 FILEARCH = $(ARCH)
126endif
127
f80fe69f
A
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
a645023d 139
d696c285
A
140RM = rm
141RMFLAGS = -rf
142
143# utilites for Makefiles
55e3d2f6 144PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
a61fdf0a 145PASS_IFF_SUCCESS = ${PASS_IFF}
55e3d2f6
A
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
a61fdf0a 149FAIL_IFF_SUCCESS = ${FAIL_IFF}
55e3d2f6
A
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
a61fdf0a
A
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