]> git.saurik.com Git - apple/ld64.git/blame - unit-tests/include/common.makefile
ld64-123.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
A
10
11MYDIR=$(shell cd ../../bin;pwd)
55e3d2f6
A
12LD = ld
13OBJECTDUMP = ObjectDump
14MACHOCHECK = machocheck
15OTOOL = otool
16REBASE = rebase
a645023d 17DYLDINFO = dyldinfo
d696c285 18
d696c285 19ifdef BUILT_PRODUCTS_DIR
55e3d2f6 20 # if run within Xcode, add the just built tools to the command path
a61fdf0a
A
21 PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${PATH}
22 COMPILER_PATH := ${BUILT_PRODUCTS_DIR}:${MYDIR}:${COMPILER_PATH}
55e3d2f6
A
23 LD = ${BUILT_PRODUCTS_DIR}/ld
24 OBJECTDUMP = ${BUILT_PRODUCTS_DIR}/ObjectDump
25 MACHOCHECK = ${BUILT_PRODUCTS_DIR}/machocheck
26 REBASE = ${BUILT_PRODUCTS_DIR}/rebase
a645023d
A
27 UNWINDDUMP = ${BUILT_PRODUCTS_DIR}/unwinddump
28 DYLDINFO = ${BUILT_PRODUCTS_DIR}/dyldinfo
a61fdf0a 29else
2f2f92e4 30 ifneq "$(findstring /unit-tests/test-cases/, $(shell pwd))" ""
55e3d2f6 31 # if run from Terminal inside unit-test directory
2f2f92e4 32 RELEASEDIR=$(shell cd ../../../build/Release;pwd)
a645023d 33 RELEASEADIR=$(shell cd ../../../build/Release-assert;pwd)
55e3d2f6 34 DEBUGDIR=$(shell cd ../../../build/Debug;pwd)
a645023d
A
35 PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${PATH}
36 COMPILER_PATH := ${RELEASEADIR}:${RELEASEDIR}:${DEBUGDIR}:${MYDIR}:${COMPILER_PATH}
37 LD = ${DEBUGDIR}/ld
38 OBJECTDUMP = ${DEBUGDIR}/ObjectDump
39 MACHOCHECK = ${DEBUGDIR}/machocheck
40 REBASE = ${DEBUGDIR}/rebase
41 UNWINDDUMP = ${DEBUGDIR}/unwinddump
42 DYLDINFO = ${DEBUGDIR}/dyldinfo
2f2f92e4
A
43 else
44 PATH := ${MYDIR}:${PATH}:
45 COMPILER_PATH := ${MYDIR}:${COMPILER_PATH}:
46 endif
d696c285 47endif
a61fdf0a
A
48export PATH
49export COMPILER_PATH
d696c285 50
a645023d
A
51ifeq ($(ARCH),ppc)
52 SDKExtra = -isysroot /Developer/SDKs/MacOSX10.6.sdk
53endif
d696c285 54
a645023d 55CC = cc -arch ${ARCH} ${SDKExtra}
69a49097 56CCFLAGS = -Wall -std=c99
d696c285
A
57ASMFLAGS =
58
a645023d 59CXX = c++ -arch ${ARCH} ${SDKExtra}
69a49097 60CXXFLAGS = -Wall
d696c285 61
2f2f92e4 62ifeq ($(ARCH),armv6)
55e3d2f6
A
63 SDKExtra = -isysroot /Developer/SDKs/Extra
64 LDFLAGS := -syslibroot /Developer/SDKs/Extra
65 override FILEARCH = arm
66else
67 FILEARCH = $(ARCH)
68endif
69
70ifeq ($(ARCH),armv7)
71 SDKExtra = -isysroot /Developer/SDKs/Extra
72 LDFLAGS := -syslibroot /Developer/SDKs/Extra
2f2f92e4
A
73 override FILEARCH = arm
74else
75 FILEARCH = $(ARCH)
76endif
77
78ifeq ($(ARCH),thumb)
55e3d2f6
A
79 SDKExtra = -isysroot /Developer/SDKs/Extra
80 LDFLAGS := -syslibroot /Developer/SDKs/Extra
2f2f92e4
A
81 CCFLAGS += -mthumb
82 CXXFLAGS += -mthumb
83 override ARCH = armv6
84 override FILEARCH = arm
85else
86 FILEARCH = $(ARCH)
87endif
88
55e3d2f6
A
89ifeq ($(ARCH),thumb2)
90 SDKExtra = -isysroot /Developer/SDKs/Extra
91 LDFLAGS := -syslibroot /Developer/SDKs/Extra
92 CCFLAGS += -mthumb
93 CXXFLAGS += -mthumb
94 override ARCH = armv7
95 override FILEARCH = arm
96 CC = /Volumes/Leopard/Developer/Platforms/iPhoneOS.platform/usr/bin/gcc-4.2 -arch ${ARCH}
97else
98 FILEARCH = $(ARCH)
99endif
100
a645023d 101
d696c285
A
102RM = rm
103RMFLAGS = -rf
104
105# utilites for Makefiles
55e3d2f6 106PASS_IFF = ${MYDIR}/pass-iff-exit-zero.pl
a61fdf0a 107PASS_IFF_SUCCESS = ${PASS_IFF}
55e3d2f6
A
108PASS_IFF_EMPTY = ${MYDIR}/pass-iff-no-stdin.pl
109PASS_IFF_STDIN = ${MYDIR}/pass-iff-stdin.pl
110FAIL_IFF = ${MYDIR}/fail-iff-exit-zero.pl
a61fdf0a 111FAIL_IFF_SUCCESS = ${FAIL_IFF}
55e3d2f6
A
112PASS_IFF_ERROR = ${MYDIR}/pass-iff-exit-non-zero.pl
113FAIL_IF_ERROR = ${MYDIR}/fail-if-exit-non-zero.pl
114FAIL_IF_SUCCESS = ${MYDIR}/fail-if-exit-zero.pl
115FAIL_IF_EMPTY = ${MYDIR}/fail-if-no-stdin.pl
116FAIL_IF_STDIN = ${MYDIR}/fail-if-stdin.pl
a61fdf0a
A
117PASS_IFF_GOOD_MACHO = ${PASS_IFF} ${MACHOCHECK}
118FAIL_IF_BAD_MACHO = ${FAIL_IF_ERROR} ${MACHOCHECK}
119FAIL_IF_BAD_OBJ = ${FAIL_IF_ERROR} ${OBJECTDUMP} >/dev/null