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