]>
Commit | Line | Data |
---|---|---|
b0d623f7 | 1 | SDKROOT ?= / |
39236c6e | 2 | Product ?= $(shell xcodebuild -sdk $(SDKROOT) -version PlatformPath | head -1 | sed 's,^.*/\([^/]*\)\.platform$$,\1,') |
cf7d32b8 | 3 | |
39236c6e A |
4 | # This should not be a long term solution to <rdar://problem/11230738>; this |
5 | # makefile needs to be changed to identify its targets appropriately in the | |
6 | # absence of tconf, but we'll go with the quick change for now. | |
7 | ||
8 | ifeq "$(RC_TARGET_CONFIG)" "iPhone" | |
9 | Embedded?=YES | |
10 | else | |
11 | Embedded?=$(shell echo $(SDKROOT) | grep -iq iphoneos && echo YES || echo NO) | |
12 | endif | |
316670eb | 13 | |
cf7d32b8 | 14 | ifeq "$(Embedded)" "YES" |
39236c6e A |
15 | Product?=iPhone |
16 | else | |
17 | Product?=MacOSX | |
18 | endif | |
19 | ||
20 | SDKVERSION:=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1) | |
21 | ||
22 | ifeq "$(Product)" "iPhoneOS" | |
23 | SDKPATH := $(shell xcodebuild -sdk $(SDKROOT) -version Path) | |
316670eb A |
24 | CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION) |
25 | LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION) | |
cf7d32b8 | 26 | else |
316670eb A |
27 | CFLAGS += -mmacosx-version-min=$(SDKVERSION) |
28 | LIBFLAGS += -mmacosx-version-min=$(SDKVERSION) | |
39236c6e | 29 | Product ?= MacOSX |
cf7d32b8 A |
30 | endif |
31 | ||
39236c6e A |
32 | CC := xcrun -sdk $(SDKROOT) cc |
33 | HOSTCC := cc | |
cf7d32b8 | 34 | |
39236c6e A |
35 | SRCROOT?=$(shell /bin/pwd) |
36 | OBJROOT?=$(SRCROOT)/BUILD/obj | |
37 | DSTROOT?=$(SRCROOT)/BUILD/dst | |
38 | SYMROOT?=$(SRCROOT)/BUILD/sym | |
2d21ac55 | 39 | |
39236c6e A |
40 | SRCSUBPATH := $(SRCROOT) |
41 | OBJSUBPATH := $(OBJROOT) | |
2d21ac55 | 42 | |
39236c6e A |
43 | ifdef RC_ARCHS |
44 | ARCH:=$(RC_ARCHS) | |
2d21ac55 | 45 | else |
39236c6e A |
46 | ifeq "$(Product)" "MacOSX" |
47 | ARCH:=i386 x86_64 | |
48 | else ifeq "$(Product)" "iPhoneOS" | |
49 | ARCH:=armv7s armv7 | |
50 | else ifeq "$(Product)" "AppleTV" | |
51 | ARCH:=i386 | |
52 | endif | |
2d21ac55 A |
53 | endif |
54 | ||
39236c6e A |
55 | MY_ARCH := $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs. |
56 | ARCH_32 := $(filter-out %64, $(ARCH)) | |
57 | ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32)) | |
58 | ARCH_64 := $(filter %64, $(ARCH)) | |
59 | ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64)) | |
6d2010ae | 60 | |
316670eb | 61 | CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations |
39236c6e A |
62 | |
63 | LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/ | |
2d21ac55 | 64 | |
316670eb | 65 | # The current implementation of the content protection test requires IOKit. |
39236c6e | 66 | ifeq "$(Product)" "iPhoneOS" |
316670eb A |
67 | LIBFLAGS += -framework IOKit |
68 | endif | |
69 | ||
39236c6e A |
70 | MY_OBJECTS := $(OBJSUBPATH)/main.o $(OBJSUBPATH)/memory_tests.o $(OBJSUBPATH)/misc.o \ |
71 | $(OBJSUBPATH)/sema_tests.o $(OBJSUBPATH)/shared_memory_tests.o \ | |
72 | $(OBJSUBPATH)/socket_tests.o $(OBJSUBPATH)/tests.o \ | |
73 | $(OBJSUBPATH)/xattr_tests.o $(OBJSUBPATH)/kqueue_tests.o \ | |
74 | $(OBJSUBPATH)/machvm_tests.o $(OBJSUBPATH)/commpage_tests.o \ | |
75 | $(OBJSUBPATH)/atomic_fifo_queue_test.o $(OBJSUBPATH)/sched_tests.o \ | |
76 | $(OBJSUBPATH)/pipes_tests.o | |
2d21ac55 | 77 | |
39236c6e A |
78 | ifneq "$(Product)" "iPhoneOS" |
79 | MY_OBJECTS += $(OBJSUBPATH)/32bit_inode_tests.o | |
316670eb | 80 | else |
39236c6e | 81 | MY_OBJECTS += $(OBJSUBPATH)/content_protection_test.o |
b0d623f7 | 82 | endif |
2d21ac55 | 83 | |
39236c6e A |
84 | |
85 | xnu_quick_test : $(OBJSUBPATH) $(DSTROOT) $(SYMROOT) $(MY_OBJECTS) helpers | |
86 | ifndef RC_ProjectName | |
87 | rm -rf $(DSTROOT)/xnu_quick_test | |
88 | endif | |
89 | $(CC) -g $(MY_ARCH) $(LIBFLAGS) -o $(SYMROOT)/xnu_quick_test $(MY_OBJECTS) | |
90 | /usr/bin/dsymutil $(SYMROOT)/xnu_quick_test | |
91 | /usr/bin/ditto $(SYMROOT)/xnu_quick_test $(DSTROOT)/xnu_quick_test | |
2d21ac55 | 92 | |
6d2010ae A |
93 | # This target is defined for testbots. |
94 | # Before compiling this target, MORECFLAGS must be set to "-D RUN_UNDER_TESTBOTS=1", check README file for more details | |
95 | # NOTE: -f[ailures] MAX_FAILS_ALLOWED option is set to 100 to make sure we completely run the test suite and | |
96 | # report all the failures. | |
97 | ||
98 | testbots: xnu_quick_test | |
39236c6e | 99 | @(cd $(DSTROOT) ; ./xnu_quick_test -f 100) |
6d2010ae | 100 | |
2d21ac55 A |
101 | # The helper binaries are used to test exec()'ing between 64bit and 32bit. |
102 | # Creates test binaries with page zero sizes = 4KB and 4GB. Also creates 32-bit | |
103 | # helper processes for the 64-bit version of xnu_quick_test to test the conversion | |
104 | # from a 32-bit process to a 64-bit process. | |
39236c6e A |
105 | helpers : $(SRCSUBPATH)/helpers/sleep.c $(SRCSUBPATH)/helpers/launch.c $(SRCSUBPATH)/helpers/arch.c $(SRCSUBPATH)/helpers/data_exec.c helperdir $(OBJSUBPATH)/misc.o |
106 | ifneq "$(Product)" "iPhoneOS" | |
107 | ifneq "$(ARCH_32)" "" | |
108 | $(CC) -g $(ARCH_32_FLAGS) $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-i386 | |
109 | /usr/bin/ditto $(SYMROOT)/sleep-i386 $(DSTROOT)/helpers/ | |
110 | endif | |
cf7d32b8 A |
111 | endif |
112 | ifeq "$(Product)" "MacOSX" | |
39236c6e A |
113 | ifneq "$(ARCH_32)" "" |
114 | $(CC) -g $(LIBFLAGS) $(ARCH_32_FLAGS) $(OBJSUBPATH)/misc.o $(SRCSUBPATH)/helpers/launch.c -o $(SYMROOT)/launch-i386 | |
115 | $(CC) -g $(ARCH_32_FLAGS) -DNXDATA32TESTNONX $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec32nonxspawn | |
116 | /usr/bin/ditto $(SYMROOT)/launch-i386 $(SYMROOT)/data_exec32nonxspawn $(DSTROOT)/helpers/ | |
cf7d32b8 | 117 | endif |
39236c6e A |
118 | ifneq "$(ARCH_64)" "" |
119 | $(CC) -g $(ARCH_64_FLAGS) -pagezero_size 0x100000000 $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-x86_64-4G | |
120 | $(CC) -g $(ARCH_64_FLAGS) -pagezero_size 0x1000 $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-x86_64-4K | |
121 | $(CC) -g $(LIBFLAGS) $(ARCH_64_FLAGS) $(OBJSUBPATH)/misc.o $(SRCSUBPATH)/helpers/launch.c -o $(SYMROOT)/launch-x86_64 | |
122 | /usr/bin/ditto $(SYMROOT)/sleep-x86_64-4G $(SYMROOT)/sleep-x86_64-4K $(SYMROOT)/launch-x86_64 $(DSTROOT)/helpers/ | |
cf7d32b8 | 123 | endif |
39236c6e A |
124 | $(CC) -g $(MY_ARCH) $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec |
125 | /usr/bin/ditto $(SYMROOT)/data_exec $(DSTROOT)/helpers/ | |
cf7d32b8 | 126 | endif |
39236c6e A |
127 | ifeq "$(Product)" "iPhoneOS" |
128 | ifneq "$(ARCH_32)" "" | |
129 | $(CC) $(CFLAGS) $(ARCH_32_FLAGS) $(SRCSUBPATH)/helpers/sleep.c -o $(SYMROOT)/sleep-arm | |
130 | $(CC) $(LIBFLAGS) $(CFLAGS) $(ARCH_32_FLAGS) $(OBJSUBPATH)/misc.o $(SRCSUBPATH)/helpers/launch.c -o $(SYMROOT)/launch-arm | |
131 | /usr/bin/ditto $(SYMROOT)/sleep-arm $(SYMROOT)/launch-arm $(DSTROOT)/helpers/ | |
cf7d32b8 | 132 | endif |
39236c6e A |
133 | endif |
134 | $(CC) -g $(MY_ARCH) $(CFLAGS) $(SRCSUBPATH)/helpers/arch.c -o $(SYMROOT)/arch | |
135 | /usr/bin/ditto $(SYMROOT)/arch $(DSTROOT)/helpers/ | |
2d21ac55 A |
136 | |
137 | helperdir : | |
138 | mkdir -p $(DSTROOT)/helpers | |
139 | ||
39236c6e A |
140 | $(OBJSUBPATH) : |
141 | mkdir -p $(OBJSUBPATH); | |
2d21ac55 A |
142 | |
143 | $(DSTROOT) : | |
144 | mkdir -p $(DSTROOT); | |
145 | ||
39236c6e A |
146 | $(SYMROOT) : |
147 | mkdir -p $(SYMROOT) | |
148 | ||
149 | $(OBJSUBPATH)/main.o : $(SRCSUBPATH)/main.c $(SRCSUBPATH)/tests.h | |
150 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/main.c -o $@ | |
2d21ac55 | 151 | |
39236c6e A |
152 | $(OBJSUBPATH)/memory_tests.o : $(SRCSUBPATH)/memory_tests.c $(SRCSUBPATH)/tests.h |
153 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/memory_tests.c -o $@ | |
2d21ac55 | 154 | |
b0d623f7 | 155 | # misc.o has to be built 3-way for the helpers to link |
39236c6e A |
156 | $(OBJSUBPATH)/misc.o : $(SRCSUBPATH)/misc.c $(SRCSUBPATH)/tests.h |
157 | ifeq "$(Product)" "iPhoneOS" | |
158 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@ | |
cf7d32b8 | 159 | else |
39236c6e | 160 | $(CC) -arch i386 -arch x86_64 $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@ |
cf7d32b8 | 161 | endif |
2d21ac55 | 162 | |
39236c6e A |
163 | $(OBJSUBPATH)/sema_tests.o : $(SRCSUBPATH)/sema_tests.c $(SRCSUBPATH)/tests.h |
164 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sema_tests.c -o $@ | |
2d21ac55 | 165 | |
39236c6e A |
166 | $(OBJSUBPATH)/shared_memory_tests.o : $(SRCSUBPATH)/shared_memory_tests.c $(SRCSUBPATH)/tests.h |
167 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/shared_memory_tests.c -o $@ | |
2d21ac55 | 168 | |
39236c6e A |
169 | $(OBJSUBPATH)/socket_tests.o : $(SRCSUBPATH)/socket_tests.c $(SRCSUBPATH)/tests.h |
170 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/socket_tests.c -o $@ | |
2d21ac55 | 171 | |
39236c6e A |
172 | $(OBJSUBPATH)/tests.o : $(SRCSUBPATH)/tests.c $(SRCSUBPATH)/tests.h |
173 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/tests.c -o $@ | |
2d21ac55 | 174 | |
39236c6e A |
175 | $(OBJSUBPATH)/xattr_tests.o : $(SRCSUBPATH)/xattr_tests.c $(SRCSUBPATH)/tests.h |
176 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/xattr_tests.c -o $@ | |
2d21ac55 | 177 | |
39236c6e A |
178 | $(OBJSUBPATH)/machvm_tests.o : $(SRCSUBPATH)/machvm_tests.c $(SRCSUBPATH)/tests.h |
179 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/machvm_tests.c -o $@ | |
b0d623f7 | 180 | |
39236c6e A |
181 | $(OBJSUBPATH)/sched_tests.o : $(SRCSUBPATH)/sched_tests.c $(SRCSUBPATH)/tests.h |
182 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sched_tests.c -o $@ | |
6d2010ae | 183 | |
39236c6e A |
184 | $(OBJSUBPATH)/kqueue_tests.o : $(SRCSUBPATH)/kqueue_tests.c $(SRCSUBPATH)/tests.h |
185 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/kqueue_tests.c -o $@ | |
b0d623f7 | 186 | |
39236c6e A |
187 | $(OBJSUBPATH)/32bit_inode_tests.o : $(SRCSUBPATH)/32bit_inode_tests.c $(SRCSUBPATH)/tests.h |
188 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/32bit_inode_tests.c -o $@ | |
2d21ac55 | 189 | |
39236c6e A |
190 | $(OBJSUBPATH)/commpage_tests.o : $(SRCSUBPATH)/commpage_tests.c $(SRCSUBPATH)/tests.h |
191 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/commpage_tests.c -o $@ | |
6d2010ae | 192 | |
39236c6e A |
193 | $(OBJSUBPATH)/atomic_fifo_queue_test.o : $(SRCSUBPATH)/atomic_fifo_queue_test.c $(SRCSUBPATH)/tests.h |
194 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/atomic_fifo_queue_test.c -o $@ | |
6d2010ae | 195 | |
39236c6e A |
196 | $(OBJSUBPATH)/content_protection_test.o : $(SRCSUBPATH)/content_protection_test.c $(SRCSUBPATH)/tests.h |
197 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/content_protection_test.c -o $@ | |
316670eb | 198 | |
39236c6e A |
199 | $(OBJSUBPATH)/pipes_tests.o : $(SRCSUBPATH)/pipes_tests.c $(SRCSUBPATH)/tests.h |
200 | $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/pipes_tests.c -o $@ | |
6d2010ae | 201 | |
2d21ac55 A |
202 | .PHONY : clean |
203 | clean : | |
39236c6e A |
204 | rm -Rf $(DSTROOT)/xnu_quick_test |
205 | rm -Rf $(DSTROOT)/helpers/* | |
206 | rm -Rf $(OBJSUBPATH)/*.o |