]> git.saurik.com Git - apple/ld64.git/blame - unit-tests/include/common.makefile
ld64-127.2.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
A
11IOS_SDK = /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.Internal.sdk
12
a61fdf0a 13MYDIR=$(shell cd ../../bin;pwd)
55e3d2f6
A
14LD = ld
15OBJECTDUMP = ObjectDump
16MACHOCHECK = machocheck
17OTOOL = otool
18REBASE = rebase
a645023d 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
A
24 COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${COMPILER_PATH}
25 LD_PATH = ${BUILT_PRODUCTS_DIR}
55e3d2f6
A
26 LD = ${BUILT_PRODUCTS_DIR}/ld
27 OBJECTDUMP = ${BUILT_PRODUCTS_DIR}/ObjectDump
28 MACHOCHECK = ${BUILT_PRODUCTS_DIR}/machocheck
29 REBASE = ${BUILT_PRODUCTS_DIR}/rebase
a645023d
A
30 UNWINDDUMP = ${BUILT_PRODUCTS_DIR}/unwinddump
31 DYLDINFO = ${BUILT_PRODUCTS_DIR}/dyldinfo
a61fdf0a 32else
2f2f92e4 33 ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
55e3d2f6 34 # if run from Terminal inside unit-test directory
a645023d 35 RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd)
55e3d2f6 36 DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
a645023d 37 PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
afe874b1
A
38 COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${COMPILER_PATH}
39 LD_PATH = ${DEBUGDIR}
a645023d
A
40 LD = ${DEBUGDIR}/ld
41 OBJECTDUMP = ${DEBUGDIR}/ObjectDump
42 MACHOCHECK = ${DEBUGDIR}/machocheck
43 REBASE = ${DEBUGDIR}/rebase
44 UNWINDDUMP = ${DEBUGDIR}/unwinddump
45 DYLDINFO = ${DEBUGDIR}/dyldinfo
2f2f92e4
A
46 else
47 PATH := ${MYDIR}:${PATH}:
48 COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
49 endif
d696c285 50endif
a61fdf0a
A
51export PATH
52export COMPILER_PATH
afe874b1 53export GCC_EXEC_PREFIX=garbage
d696c285 54
a645023d
A
55ifeq ($(ARCH),ppc)
56 SDKExtra = -isysroot /Developer/SDKs/MacOSX10.6.sdk
57endif
d696c285 58
a645023d 59CC = cc -arch ${ARCH} ${SDKExtra}
afe874b1 60CCFLAGS = -Wall
d696c285 61ASMFLAGS =
afe874b1
A
62VERSION_NEW_LINKEDIT = -mmacosx-version-min=10.6
63VERSION_OLD_LINKEDIT = -mmacosx-version-min=10.4
64LD_NEW_LINKEDIT = -macosx_version_min 10.6
d696c285 65
a645023d 66CXX = c++ -arch ${ARCH} ${SDKExtra}
69a49097 67CXXFLAGS = -Wall
d696c285 68
2f2f92e4 69ifeq ($(ARCH),armv6)
afe874b1 70 LDFLAGS := -syslibroot $(IOS_SDK)
55e3d2f6 71 override FILEARCH = arm
afe874b1
A
72 CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
73 CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
74 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
75 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
76 LD_SYSROOT = -syslibroot $(IOS_SDK)
77 LD_NEW_LINKEDIT = -ios_version_min 4.0
55e3d2f6
A
78else
79 FILEARCH = $(ARCH)
80endif
81
82ifeq ($(ARCH),armv7)
afe874b1 83 LDFLAGS := -syslibroot $(IOS_SDK)
2f2f92e4 84 override FILEARCH = arm
afe874b1
A
85 CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
86 CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
87 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
88 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
89 LD_SYSROOT = -syslibroot $(IOS_SDK)
90 LD_NEW_LINKEDIT = -ios_version_min 4.0
2f2f92e4
A
91else
92 FILEARCH = $(ARCH)
93endif
94
95ifeq ($(ARCH),thumb)
afe874b1 96 LDFLAGS := -syslibroot $(IOS_SDK)
2f2f92e4
A
97 CCFLAGS += -mthumb
98 CXXFLAGS += -mthumb
99 override ARCH = armv6
100 override FILEARCH = arm
afe874b1
A
101 CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
102 CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
103 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
104 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
105 LD_SYSROOT = -syslibroot $(IOS_SDK)
106 LD_NEW_LINKEDIT = -ios_version_min 4.0
2f2f92e4
A
107else
108 FILEARCH = $(ARCH)
109endif
110
55e3d2f6 111ifeq ($(ARCH),thumb2)
afe874b1 112 LDFLAGS := -syslibroot $(IOS_SDK)
55e3d2f6
A
113 CCFLAGS += -mthumb
114 CXXFLAGS += -mthumb
115 override ARCH = armv7
116 override FILEARCH = arm
afe874b1
A
117 CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
118 CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch ${ARCH} -ccc-install-dir ${LD_PATH} -miphoneos-version-min=5.0 -isysroot $(IOS_SDK)
119 VERSION_NEW_LINKEDIT = -miphoneos-version-min=4.0
120 VERSION_OLD_LINKEDIT = -miphoneos-version-min=3.0
121 LD_SYSROOT = -syslibroot $(IOS_SDK)
122 LD_NEW_LINKEDIT = -ios_version_min 4.0
55e3d2f6
A
123else
124 FILEARCH = $(ARCH)
125endif
126
a645023d 127
d696c285
A
128RM = rm
129RMFLAGS = -rf
130
131# utilites for Makefiles
55e3d2f6 132PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
a61fdf0a 133PASS_IFF_SUCCESS = ${PASS_IFF}
55e3d2f6
A
134PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
135PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
136FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
a61fdf0a 137FAIL_IFF_SUCCESS = ${FAIL_IFF}
55e3d2f6
A
138PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
139FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
140FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
141FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
142FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
a61fdf0a
A
143PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
144FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
145FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null