]>
Commit | Line | Data |
---|---|---|
1 | SDKROOT ?= / | |
2 | Product=$(shell tconf --product) | |
3 | Embedded=$(shell tconf --test TARGET_OS_EMBEDDED) | |
4 | ||
5 | SDKVERSION=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1) | |
6 | ||
7 | ifeq "$(Embedded)" "YES" | |
8 | XILogFLAG = | |
9 | SDKPATH = $(shell xcodebuild -sdk $(SDKROOT) -version Path) | |
10 | CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION) | |
11 | LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION) | |
12 | else | |
13 | XILogFLAG = -framework XILog | |
14 | CFLAGS += -mmacosx-version-min=$(SDKVERSION) | |
15 | LIBFLAGS += -mmacosx-version-min=$(SDKVERSION) | |
16 | endif | |
17 | ||
18 | HOSTCC = cc | |
19 | CC = xcrun -sdk $(SDKROOT) cc | |
20 | ||
21 | ifdef RC_BUILDIT | |
22 | DOING_BUILDIT=yes | |
23 | endif | |
24 | ||
25 | ifdef RC_OS | |
26 | DOING_BUILDIT=yes | |
27 | endif | |
28 | ||
29 | ifdef DOING_BUILDIT | |
30 | include $(MAKEFILEPATH)/CoreOS/ReleaseControl/Common.make | |
31 | MY_ARCH = $(patsubst %, -arch %, $(RC_ARCHS)) | |
32 | install:: xnu_quick_test | |
33 | else | |
34 | ifndef SRCROOT | |
35 | SRCROOT=$(shell /bin/pwd) | |
36 | endif | |
37 | ifndef OBJROOT | |
38 | OBJROOT=$(SRCROOT)/BUILD/obj | |
39 | endif | |
40 | ifndef DSTROOT | |
41 | DSTROOT=$(SRCROOT)/BUILD/dst | |
42 | endif | |
43 | ||
44 | ifndef ARCH | |
45 | ARCH=i386 x86_64 | |
46 | # this hack should be removed once tconf gets | |
47 | # <rdar://problem/6618734> | |
48 | ifeq "$(Product)" "iPhone" | |
49 | ARCH=armv7 | |
50 | endif | |
51 | ifeq "$(Product)" "AppleTV" | |
52 | ARCH=i386 | |
53 | endif | |
54 | endif | |
55 | ||
56 | ifdef ARCH | |
57 | MY_ARCH = $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs. | |
58 | endif | |
59 | ||
60 | CFLAGS += $(MY_ARCH) | |
61 | endif | |
62 | ||
63 | ||
64 | CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations | |
65 | LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/ $(XILogFLAG) | |
66 | ||
67 | # The current implementation of the content protection test requires IOKit. | |
68 | ifeq "$(Product)" "iPhone" | |
69 | LIBFLAGS += -framework IOKit | |
70 | endif | |
71 | ||
72 | MY_OBJECTS = $(OBJROOT)/main.o $(OBJROOT)/memory_tests.o $(OBJROOT)/misc.o \ | |
73 | $(OBJROOT)/sema_tests.o $(OBJROOT)/shared_memory_tests.o \ | |
74 | $(OBJROOT)/socket_tests.o $(OBJROOT)/tests.o \ | |
75 | $(OBJROOT)/xattr_tests.o $(OBJROOT)/kqueue_tests.o \ | |
76 | $(OBJROOT)/machvm_tests.o $(OBJROOT)/commpage_tests.o \ | |
77 | $(OBJROOT)/atomic_fifo_queue_test.o $(OBJROOT)/sched_tests.o \ | |
78 | $(OBJROOT)/pipes_tests.o | |
79 | ||
80 | ifneq "$(Product)" "iPhone" | |
81 | MY_OBJECTS += $(OBJROOT)/32bit_inode_tests.o | |
82 | else | |
83 | MY_OBJECTS += $(OBJROOT)/content_protection_test.o | |
84 | endif | |
85 | ||
86 | # In networked home directories, the chown will fail; we notice and print a helpful message | |
87 | CHOWN_COMMAND=sudo chown root $(DSTROOT)/xnu_quick_test | |
88 | PERM_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." | |
89 | xnu_quick_test : $(OBJROOT) $(DSTROOT) $(MY_OBJECTS) helpers | |
90 | sudo rm -rf $(DSTROOT)/xnu_quick_test | |
91 | $(CC) $(MY_ARCH) $(LIBFLAGS) -o $(DSTROOT)/xnu_quick_test $(MY_OBJECTS) | |
92 | @echo $(CHOWN_COMMAND) # Hack so we don't echo help-message echo | |
93 | @$(CHOWN_COMMAND) || echo $(PERM_ADVICE) | |
94 | sudo chmod 4755 $(DSTROOT)/xnu_quick_test | |
95 | ||
96 | # This target is defined for testbots. | |
97 | # Before compiling this target, MORECFLAGS must be set to "-D RUN_UNDER_TESTBOTS=1", check README file for more details | |
98 | # NOTE: -f[ailures] MAX_FAILS_ALLOWED option is set to 100 to make sure we completely run the test suite and | |
99 | # report all the failures. | |
100 | ||
101 | testbots: xnu_quick_test | |
102 | @(cd $(DSTROOT) ; ./xnu_quick_test -f 100) | |
103 | ||
104 | # The helper binaries are used to test exec()'ing between 64bit and 32bit. | |
105 | # Creates test binaries with page zero sizes = 4KB and 4GB. Also creates 32-bit | |
106 | # helper processes for the 64-bit version of xnu_quick_test to test the conversion | |
107 | # from a 32-bit process to a 64-bit process. | |
108 | helpers : helpers/sleep.c helpers/launch.c helpers/arch.c helpers/data_exec.c helperdir $(OBJROOT)/misc.o | |
109 | ifneq "$(Product)" "iPhone" | |
110 | $(CC) -arch i386 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-i386 | |
111 | endif | |
112 | ifeq "$(Product)" "MacOSX" | |
113 | $(CC) -arch x86_64 -pagezero_size 0x100000000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4G | |
114 | $(CC) -arch x86_64 -pagezero_size 0x1000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4K | |
115 | endif | |
116 | ifneq "$(Product)" "iPhone" | |
117 | $(CC) $(LIBFLAGS) -arch i386 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-i386 | |
118 | endif | |
119 | ifeq "$(Product)" "MacOSX" | |
120 | $(CC) $(LIBFLAGS) -arch x86_64 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-x86_64 | |
121 | $(CC) $(MY_ARCH) helpers/arch.c -o $(DSTROOT)/helpers/arch | |
122 | $(CC) $(MY_ARCH) helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec | |
123 | $(CC) -arch i386 -DNXDATA32TESTNONX helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec32nonxspawn | |
124 | ||
125 | endif | |
126 | ifeq "$(Product)" "iPhone" | |
127 | $(CC) $(CFLAGS) helpers/sleep.c -o $(DSTROOT)/helpers/sleep-arm | |
128 | $(CC) $(LIBFLAGS) $(CFLAGS) $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-arm | |
129 | $(CC) $(MY_ARCH) $(CFLAGS) helpers/arch.c -o $(DSTROOT)/helpers/arch | |
130 | endif | |
131 | ||
132 | ||
133 | helperdir : | |
134 | mkdir -p $(DSTROOT)/helpers | |
135 | ||
136 | $(OBJROOT) : | |
137 | mkdir -p $(OBJROOT); | |
138 | ||
139 | $(DSTROOT) : | |
140 | mkdir -p $(DSTROOT); | |
141 | ||
142 | $(OBJROOT)/main.o : main.c tests.h | |
143 | $(CC) $(CFLAGS) -c main.c -o $@ | |
144 | ||
145 | $(OBJROOT)/memory_tests.o : memory_tests.c tests.h | |
146 | $(CC) $(CFLAGS) -c memory_tests.c -o $@ | |
147 | ||
148 | # misc.o has to be built 3-way for the helpers to link | |
149 | $(OBJROOT)/misc.o : misc.c tests.h | |
150 | ifeq "$(Product)" "iPhone" | |
151 | $(CC) -arch armv7 $(CFLAGS) -c misc.c -o $@ | |
152 | else | |
153 | $(CC) -arch i386 -arch x86_64 $(CFLAGS) -c misc.c -o $@ | |
154 | endif | |
155 | ||
156 | $(OBJROOT)/sema_tests.o : sema_tests.c tests.h | |
157 | $(CC) $(CFLAGS) -c sema_tests.c -o $@ | |
158 | ||
159 | $(OBJROOT)/shared_memory_tests.o : shared_memory_tests.c tests.h | |
160 | $(CC) $(CFLAGS) -c shared_memory_tests.c -o $@ | |
161 | ||
162 | $(OBJROOT)/socket_tests.o : socket_tests.c tests.h | |
163 | $(CC) $(CFLAGS) -c socket_tests.c -o $@ | |
164 | ||
165 | $(OBJROOT)/tests.o : tests.c tests.h | |
166 | $(CC) $(CFLAGS) -c tests.c -o $@ | |
167 | ||
168 | $(OBJROOT)/xattr_tests.o : xattr_tests.c tests.h | |
169 | $(CC) $(CFLAGS) -c xattr_tests.c -o $@ | |
170 | ||
171 | $(OBJROOT)/machvm_tests.o : machvm_tests.c tests.h | |
172 | $(CC) $(CFLAGS) -c machvm_tests.c -o $@ | |
173 | ||
174 | $(OBJROOT)/sched_tests.o : sched_tests.c tests.h | |
175 | $(CC) $(CFLAGS) -c sched_tests.c -o $@ | |
176 | ||
177 | $(OBJROOT)/kqueue_tests.o : kqueue_tests.c tests.h | |
178 | $(CC) $(CFLAGS) -c kqueue_tests.c -o $@ | |
179 | ||
180 | $(OBJROOT)/32bit_inode_tests.o : 32bit_inode_tests.c tests.h | |
181 | $(CC) $(CFLAGS) -c 32bit_inode_tests.c -o $@ | |
182 | ||
183 | $(OBJROOT)/commpage_tests.o : commpage_tests.c tests.h | |
184 | $(CC) $(CFLAGS) -c commpage_tests.c -o $@ | |
185 | ||
186 | $(OBJROOT)/atomic_fifo_queue_test.o : atomic_fifo_queue_test.c tests.h | |
187 | $(CC) $(CFLAGS) -c atomic_fifo_queue_test.c -o $@ | |
188 | ||
189 | $(OBJROOT)/content_protection_test.o : content_protection_test.c tests.h | |
190 | $(CC) $(CFLAGS) -c content_protection_test.c -o $@ | |
191 | ||
192 | $(OBJROOT)/pipes_tests.o : pipes_tests.c tests.h | |
193 | $(CC) $(CFLAGS) -c pipes_tests.c -o $@ | |
194 | ||
195 | ifndef DOING_BUILDIT | |
196 | .PHONY : clean | |
197 | clean : | |
198 | sudo rm -Rf $(DSTROOT)/xnu_quick_test | |
199 | sudo rm -Rf $(DSTROOT)/helpers/* | |
200 | rm -Rf $(OBJROOT)/*.o | |
201 | endif |