2 Product=$(shell tconf --product)
3 Embedded=$(shell tconf --test TARGET_OS_EMBEDDED)
5 ifeq "$(Embedded)" "YES"
7 SDKPATH = $(shell xcodebuild -sdk $(SDKROOT) -version Path)
8 CFLAGS += -isysroot $(SDKPATH)
9 LIBFLAGS += -isysroot $(SDKPATH)
11 XILogFLAG = -framework XILog
15 CC = xcrun -sdk $(SDKROOT) gcc
26 include $(MAKEFILEPATH)/CoreOS/ReleaseControl/Common.make
27 MY_ARCH = $(patsubst %, -arch %, $(RC_ARCHS))
28 install:: xnu_quick_test
31 SRCROOT=$(shell /bin/pwd)
34 OBJROOT=$(SRCROOT)/BUILD/obj
37 DSTROOT=$(SRCROOT)/BUILD/dst
42 # this hack should be removed once tconf gets
43 # <rdar://problem/6618734>
44 ifeq "$(Product)" "iPhone"
47 ifeq "$(Product)" "AppleTV"
53 MY_ARCH = $(patsubst %, -arch %, $(ARCH)) # allows building multiple archs.
60 CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS)
61 LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/ $(XILogFLAG)
63 MY_OBJECTS = $(OBJROOT)/main.o $(OBJROOT)/memory_tests.o $(OBJROOT)/misc.o \
64 $(OBJROOT)/sema_tests.o $(OBJROOT)/shared_memory_tests.o \
65 $(OBJROOT)/socket_tests.o $(OBJROOT)/tests.o \
66 $(OBJROOT)/xattr_tests.o $(OBJROOT)/kqueue_tests.o \
67 $(OBJROOT)/machvm_tests.o $(OBJROOT)/commpage_tests.o \
68 $(OBJROOT)/atomic_fifo_queue_test.o $(OBJROOT)/sched_tests.o
70 ifneq "$(Product)" "iPhone"
71 MY_OBJECTS += $(OBJROOT)/32bit_inode_tests.o
74 # In networked home directories, the chown will fail; we notice and print a helpful message
75 CHOWN_COMMAND=sudo chown root $(DSTROOT)/xnu_quick_test
76 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."
77 xnu_quick_test : $(OBJROOT) $(DSTROOT) $(MY_OBJECTS) helpers
78 sudo rm -rf $(DSTROOT)/xnu_quick_test
79 $(CC) $(MY_ARCH) $(LIBFLAGS) -o $(DSTROOT)/xnu_quick_test $(MY_OBJECTS)
80 @echo $(CHOWN_COMMAND) # Hack so we don't echo help-message echo
81 @$(CHOWN_COMMAND) || echo $(PERM_ADVICE)
82 sudo chmod 4755 $(DSTROOT)/xnu_quick_test
84 # This target is defined for testbots.
85 # Before compiling this target, MORECFLAGS must be set to "-D RUN_UNDER_TESTBOTS=1", check README file for more details
86 # NOTE: -f[ailures] MAX_FAILS_ALLOWED option is set to 100 to make sure we completely run the test suite and
87 # report all the failures.
89 testbots: xnu_quick_test
90 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
92 # The helper binaries are used to test exec()'ing between 64bit and 32bit.
93 # Creates test binaries with page zero sizes = 4KB and 4GB. Also creates 32-bit
94 # helper processes for the 64-bit version of xnu_quick_test to test the conversion
95 # from a 32-bit process to a 64-bit process.
96 helpers : helpers/sleep.c helpers/launch.c helpers/arch.c helpers/data_exec.c helperdir $(OBJROOT)/misc.o
97 ifneq "$(Product)" "iPhone"
98 $(CC) -arch i386 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-i386
100 ifeq "$(Product)" "MacOSX"
101 $(CC) -arch x86_64 -pagezero_size 0x100000000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4G
102 $(CC) -arch x86_64 -pagezero_size 0x1000 helpers/sleep.c -o $(DSTROOT)/helpers/sleep-x86_64-4K
104 ifneq "$(Product)" "iPhone"
105 $(CC) $(LIBFLAGS) -arch i386 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-i386
107 ifeq "$(Product)" "MacOSX"
108 $(CC) $(LIBFLAGS) -arch x86_64 $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-x86_64
109 $(CC) $(MY_ARCH) helpers/arch.c -o $(DSTROOT)/helpers/arch
110 $(CC) $(MY_ARCH) helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec
111 $(CC) -arch i386 -DNXDATA32TESTNONX helpers/data_exec.c -o $(DSTROOT)/helpers/data_exec32nonxspawn
114 ifeq "$(Product)" "iPhone"
115 $(CC) -arch armv6 -isysroot $(SDKROOT) $(CFLAGS) helpers/sleep.c -o $(DSTROOT)/helpers/sleep-arm
116 $(CC) $(LIBFLAGS) -arch armv6 -isysroot $(SDKROOT) $(OBJROOT)/misc.o helpers/launch.c -o $(DSTROOT)/helpers/launch-arm
117 $(CC) $(MY_ARCH) -isysroot $(SDKROOT) helpers/arch.c -o $(DSTROOT)/helpers/arch
122 mkdir -p $(DSTROOT)/helpers
130 $(OBJROOT)/main.o : main.c tests.h
131 $(CC) $(CFLAGS) -c main.c -o $@
133 $(OBJROOT)/memory_tests.o : memory_tests.c tests.h
134 $(CC) $(CFLAGS) -c memory_tests.c -o $@
136 # misc.o has to be built 3-way for the helpers to link
137 $(OBJROOT)/misc.o : misc.c tests.h
138 ifeq "$(Product)" "iPhone"
139 $(CC) -arch armv6 $(CFLAGS) -c misc.c -o $@
141 $(CC) -arch i386 -arch x86_64 $(CFLAGS) -c misc.c -o $@
144 $(OBJROOT)/sema_tests.o : sema_tests.c tests.h
145 $(CC) $(CFLAGS) -c sema_tests.c -o $@
147 $(OBJROOT)/shared_memory_tests.o : shared_memory_tests.c tests.h
148 $(CC) $(CFLAGS) -c shared_memory_tests.c -o $@
150 $(OBJROOT)/socket_tests.o : socket_tests.c tests.h
151 $(CC) $(CFLAGS) -c socket_tests.c -o $@
153 $(OBJROOT)/tests.o : tests.c tests.h
154 $(CC) $(CFLAGS) -c tests.c -o $@
156 $(OBJROOT)/xattr_tests.o : xattr_tests.c tests.h
157 $(CC) $(CFLAGS) -c xattr_tests.c -o $@
159 $(OBJROOT)/machvm_tests.o : machvm_tests.c tests.h
160 $(CC) $(CFLAGS) -c machvm_tests.c -o $@
162 $(OBJROOT)/sched_tests.o : sched_tests.c tests.h
163 $(CC) $(CFLAGS) -c sched_tests.c -o $@
165 $(OBJROOT)/kqueue_tests.o : kqueue_tests.c tests.h
166 $(CC) $(CFLAGS) -c kqueue_tests.c -o $@
168 $(OBJROOT)/32bit_inode_tests.o : 32bit_inode_tests.c tests.h
169 $(CC) $(CFLAGS) -c 32bit_inode_tests.c -o $@
171 $(OBJROOT)/commpage_tests.o : commpage_tests.c tests.h
172 $(CC) $(CFLAGS) -c commpage_tests.c -o $@
174 $(OBJROOT)/atomic_fifo_queue_test.o : atomic_fifo_queue_test.c tests.h
175 $(CC) $(CFLAGS) -c atomic_fifo_queue_test.c -o $@
181 sudo rm -Rf $(DSTROOT)/xnu_quick_test
182 sudo rm -Rf $(DSTROOT)/helpers/*
183 rm -Rf $(OBJROOT)/*.o