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