2 Product=$(shell tconf --product)
3 Embedded=$(shell tconf --test TARGET_OS_EMBEDDED)
5 SDKVERSION=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
7 ifeq "$(Embedded)" "YES"
9 SDKPATH = $(shell xcodebuild -sdk $(SDKROOT) -version Path)
10 CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
11 LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
13 XILogFLAG = -framework XILog
14 CFLAGS += -mmacosx-version-min=$(SDKVERSION)
15 LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
19 CC = xcrun -sdk $(SDKROOT) cc
30 include $(MAKEFILEPATH)/CoreOS/ReleaseControl/Common.make
31 MY_ARCH = $(patsubst %, -arch %, $(RC_ARCHS))
32 install:: xnu_quick_test
35 SRCROOT=$(shell /bin/pwd)
38 OBJROOT=$(SRCROOT)/BUILD/obj
41 DSTROOT=$(SRCROOT)/BUILD/dst
46 # this hack should be removed once tconf gets
47 # <rdar://problem/6618734>
48 ifeq "$(Product)" "iPhone"
51 ifeq "$(Product)" "AppleTV"
57 MY_ARCH = $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
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)
67 # The current implementation of the content protection test requires IOKit.
68 ifeq "$(Product)" "iPhone"
69 LIBFLAGS += -framework IOKit
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
80 ifneq "$(Product)" "iPhone"
81 MY_OBJECTS += $(OBJROOT)/32bit_inode_tests.o
83 MY_OBJECTS += $(OBJROOT)/content_protection_test.o
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
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.
101 testbots: xnu_quick_test
102 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
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
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
116 ifneq "$(Product)" "iPhone"
117 $(CC) $(LIBFLAGS) -arch i386 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-i386
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
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
134 mkdir -p $(DSTROOT)/helpers
142 $(OBJROOT)/main.o : main.c tests.h
143 $(CC) $(CFLAGS) -c main.c -o $@
145 $(OBJROOT)/memory_tests.o : memory_tests.c tests.h
146 $(CC) $(CFLAGS) -c memory_tests.c -o $@
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 $@
153 $(CC) -arch i386 -arch x86_64 $(CFLAGS) -c misc.c -o $@
156 $(OBJROOT)/sema_tests.o : sema_tests.c tests.h
157 $(CC) $(CFLAGS) -c sema_tests.c -o $@
159 $(OBJROOT)/shared_memory_tests.o : shared_memory_tests.c tests.h
160 $(CC) $(CFLAGS) -c shared_memory_tests.c -o $@
162 $(OBJROOT)/socket_tests.o : socket_tests.c tests.h
163 $(CC) $(CFLAGS) -c socket_tests.c -o $@
165 $(OBJROOT)/tests.o : tests.c tests.h
166 $(CC) $(CFLAGS) -c tests.c -o $@
168 $(OBJROOT)/xattr_tests.o : xattr_tests.c tests.h
169 $(CC) $(CFLAGS) -c xattr_tests.c -o $@
171 $(OBJROOT)/machvm_tests.o : machvm_tests.c tests.h
172 $(CC) $(CFLAGS) -c machvm_tests.c -o $@
174 $(OBJROOT)/sched_tests.o : sched_tests.c tests.h
175 $(CC) $(CFLAGS) -c sched_tests.c -o $@
177 $(OBJROOT)/kqueue_tests.o : kqueue_tests.c tests.h
178 $(CC) $(CFLAGS) -c kqueue_tests.c -o $@
180 $(OBJROOT)/32bit_inode_tests.o : 32bit_inode_tests.c tests.h
181 $(CC) $(CFLAGS) -c 32bit_inode_tests.c -o $@
183 $(OBJROOT)/commpage_tests.o : commpage_tests.c tests.h
184 $(CC) $(CFLAGS) -c commpage_tests.c -o $@
186 $(OBJROOT)/atomic_fifo_queue_test.o : atomic_fifo_queue_test.c tests.h
187 $(CC) $(CFLAGS) -c atomic_fifo_queue_test.c -o $@
189 $(OBJROOT)/content_protection_test.o : content_protection_test.c tests.h
190 $(CC) $(CFLAGS) -c content_protection_test.c -o $@
192 $(OBJROOT)/pipes_tests.o : pipes_tests.c tests.h
193 $(CC) $(CFLAGS) -c pipes_tests.c -o $@
198 sudo rm -Rf $(DSTROOT)/xnu_quick_test
199 sudo rm -Rf $(DSTROOT)/helpers/*
200 rm -Rf $(OBJROOT)/*.o