]> git.saurik.com Git - apple/xnu.git/blame_incremental - tools/tests/xnu_quick_test/makefile
xnu-1456.1.26.tar.gz
[apple/xnu.git] / tools / tests / xnu_quick_test / makefile
... / ...
CommitLineData
1SDKROOT ?= /
2Product=$(shell tconf --product)
3Embedded=$(shell tconf --test TARGET_OS_EMBEDDED)
4
5ifeq "$(Embedded)" "YES"
6XILogFLAG =
7SDKPATH = $(shell xcodebuild -sdk $(SDKROOT) -version | grep Path | cut -f 2 -d " ")
8CFLAGS += -isysroot $(SDKPATH)
9LIBFLAGS += -isysroot $(SDKPATH)
10else
11XILogFLAG = -framework XILog
12endif
13
14HOSTCC = gcc
15CC = xcrun -sdk $(SDKROOT) gcc
16
17ifdef RC_BUILDIT
18DOING_BUILDIT=yes
19endif
20
21ifdef RC_OS
22DOING_BUILDIT=yes
23endif
24
25ifdef DOING_BUILDIT
26include $(MAKEFILEPATH)/CoreOS/ReleaseControl/Common.make
27MY_ARCH = $(patsubst %, -arch %, $(RC_ARCHS))
28install:: xnu_quick_test
29else
30 ifndef SRCROOT
31 SRCROOT=$(shell /bin/pwd)
32 endif
33 ifndef OBJROOT
34 OBJROOT=$(SRCROOT)/BUILD/obj
35 endif
36 ifndef DSTROOT
37 DSTROOT=$(SRCROOT)/BUILD/dst
38 endif
39
40 ifndef ARCH
41 ARCH=i386 x86_64 ppc
42 # this hack should be removed once tconf gets
43 # <rdar://problem/6618734>
44 ifeq "$(Product)" "iPhone"
45 ARCH=armv6
46 endif
47 ifeq "$(Product)" "AppleTV"
48 ARCH=i386
49 endif
50 endif
51
52 ifdef ARCH
53 MY_ARCH = $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
54 endif
55
56 CFLAGS += $(MY_ARCH)
57endif
58
59CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS)
60LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/ $(XILogFLAG)
61
62MY_OBJECTS = $(OBJROOT)/main.o $(OBJROOT)/memory_tests.o $(OBJROOT)/misc.o \
63 $(OBJROOT)/sema_tests.o $(OBJROOT)/shared_memory_tests.o \
64 $(OBJROOT)/socket_tests.o $(OBJROOT)/tests.o \
65 $(OBJROOT)/xattr_tests.o $(OBJROOT)/kqueue_tests.o \
66 $(OBJROOT)/machvm_tests.o
67
68ifneq "$(Product)" "iPhone"
69MY_OBJECTS += $(OBJROOT)/32bit_inode_tests.o
70endif
71
72# In networked home directories, the chown will fail; we notice and print a helpful message
73CHOWN_COMMAND=sudo chown root $(DSTROOT)/xnu_quick_test
74PERM_ADVICE="\tYou'll have to set the executable's permissions yourself: chown to root and chmod to 4755. You may need to move to a local volume to do that."
75xnu_quick_test : $(OBJROOT) $(DSTROOT) $(MY_OBJECTS) helpers
76 sudo rm -rf $(DSTROOT)/xnu_quick_test
77 $(CC) $(MY_ARCH) $(LIBFLAGS) -o $(DSTROOT)/xnu_quick_test $(MY_OBJECTS)
78 @echo $(CHOWN_COMMAND) # Hack so we don't echo help-message echo
79 @$(CHOWN_COMMAND) || echo $(PERM_ADVICE)
80 sudo chmod 4755 $(DSTROOT)/xnu_quick_test
81
82# The helper binaries are used to test exec()'ing between 64bit and 32bit.
83# Creates test binaries with page zero sizes = 4KB and 4GB. Also creates 32-bit
84# helper processes for the 64-bit version of xnu_quick_test to test the conversion
85# from a 32-bit process to a 64-bit process.
86helpers : helpers/sleep.c helpers/launch.c helpers/arch.c helpers/data_exec.c helperdir $(OBJROOT)/misc.o
87ifneq "$(Product)" "iPhone"
88 $(CC) -arch i386 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-i386
89endif
90ifeq "$(Product)" "MacOSX"
91 $(CC) -arch x86_64 -pagezero_size 0x100000000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4G
92 $(CC) -arch x86_64 -pagezero_size 0x1000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4K
93 $(CC) -arch ppc helpers/sleep.c -o $(DSTROOT)/helpers/sleep-ppc32
94endif
95ifneq "$(Product)" "iPhone"
96 $(CC) $(LIBFLAGS) -arch i386 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-i386
97endif
98ifeq "$(Product)" "MacOSX"
99 $(CC) $(LIBFLAGS) -arch x86_64 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-x86_64
100 $(CC) $(LIBFLAGS) -arch ppc $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-ppc
101 $(CC) $(MY_ARCH) helpers/arch.c -o $(DSTROOT)/helpers/arch
102 $(CC) $(MY_ARCH) helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec
103
104endif
105ifeq "$(Product)" "iPhone"
106 $(CC) -arch armv6 -isysroot $(SDKROOT) $(CFLAGS) helpers/sleep.c -o $(DSTROOT)/helpers/sleep-arm
107 $(CC) $(LIBFLAGS) -arch armv6 -isysroot $(SDKROOT) $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-arm
108endif
109
110
111helperdir :
112 mkdir -p $(DSTROOT)/helpers
113
114$(OBJROOT) :
115 mkdir -p $(OBJROOT);
116
117$(DSTROOT) :
118 mkdir -p $(DSTROOT);
119
120$(OBJROOT)/main.o : main.c tests.h
121 $(CC) $(CFLAGS) -c main.c -o $@
122
123$(OBJROOT)/memory_tests.o : memory_tests.c tests.h
124 $(CC) $(CFLAGS) -c memory_tests.c -o $@
125
126# misc.o has to be built 3-way for the helpers to link
127$(OBJROOT)/misc.o : misc.c tests.h
128ifeq "$(Product)" "iPhone"
129 $(CC) -arch armv6 $(CFLAGS) -c misc.c -o $@
130else
131 $(CC) -arch i386 -arch x86_64 -arch ppc $(CFLAGS) -c misc.c -o $@
132endif
133
134$(OBJROOT)/sema_tests.o : sema_tests.c tests.h
135 $(CC) $(CFLAGS) -c sema_tests.c -o $@
136
137$(OBJROOT)/shared_memory_tests.o : shared_memory_tests.c tests.h
138 $(CC) $(CFLAGS) -c shared_memory_tests.c -o $@
139
140$(OBJROOT)/socket_tests.o : socket_tests.c tests.h
141 $(CC) $(CFLAGS) -c socket_tests.c -o $@
142
143$(OBJROOT)/tests.o : tests.c tests.h
144 $(CC) $(CFLAGS) -c tests.c -o $@
145
146$(OBJROOT)/xattr_tests.o : xattr_tests.c tests.h
147 $(CC) $(CFLAGS) -c xattr_tests.c -o $@
148
149$(OBJROOT)/machvm_tests.o : machvm_tests.c tests.h
150 $(CC) $(CFLAGS) -c machvm_tests.c -o $@
151
152$(OBJROOT)/kqueue_tests.o : kqueue_tests.c tests.h
153 $(CC) $(CFLAGS) -c kqueue_tests.c -o $@
154
155$(OBJROOT)/32bit_inode_tests.o : 32bit_inode_tests.c tests.h
156 $(CC) $(CFLAGS) -c 32bit_inode_tests.c -o $@
157
158ifndef DOING_BUILDIT
159.PHONY : clean
160clean :
161 sudo rm -Rf $(DSTROOT)/xnu_quick_test
162 sudo rm -Rf $(DSTROOT)/helpers/*
163 rm -Rf $(OBJROOT)/*.o
164endif