2 Product ?= $(shell xcodebuild -sdk $(SDKROOT) -version PlatformPath | head -1 | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
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.
8 ifeq "$(RC_TARGET_CONFIG)" "iPhone"
11 Embedded?=$(shell echo $(SDKROOT) | grep -iq iphoneos && echo YES || echo NO)
14 ifeq "$(Embedded)" "YES"
20 SDKVERSION:=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
22 ifeq "$(Product)" "iPhoneOS"
23 SDKPATH := $(shell xcodebuild -sdk $(SDKROOT) -version Path)
24 CFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
25 LIBFLAGS += -isysroot $(SDKPATH) -miphoneos-version-min=$(SDKVERSION)
27 CFLAGS += -mmacosx-version-min=$(SDKVERSION)
28 LIBFLAGS += -mmacosx-version-min=$(SDKVERSION)
32 CC := xcrun -sdk $(SDKROOT) cc
35 SRCROOT?=$(shell /bin/pwd)
36 OBJROOT?=$(SRCROOT)/BUILD/obj
37 DSTROOT?=$(SRCROOT)/BUILD/dst
38 SYMROOT?=$(SRCROOT)/BUILD/sym
40 SRCSUBPATH := $(SRCROOT)
41 OBJSUBPATH := $(OBJROOT)
46 ifeq "$(Product)" "MacOSX"
48 else ifeq "$(Product)" "iPhoneOS"
50 else ifeq "$(Product)" "AppleTV"
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))
61 CFLAGS += -g -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/ -F/AppleInternal/Library/Frameworks/ $(MORECFLAGS) -Wno-deprecated-declarations
63 LIBFLAGS += -I $(SDKPATH)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders -F/AppleInternal/Library/Frameworks/
65 # The current implementation of the content protection test requires IOKit.
66 ifeq "$(Product)" "iPhoneOS"
67 LIBFLAGS += -framework IOKit
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
78 ifneq "$(Product)" "iPhoneOS"
79 MY_OBJECTS += $(OBJSUBPATH)/32bit_inode_tests.o
81 MY_OBJECTS += $(OBJSUBPATH)/content_protection_test.o
85 xnu_quick_test : $(OBJSUBPATH) $(DSTROOT) $(SYMROOT) $(MY_OBJECTS) helpers
87 rm -rf $(DSTROOT)/xnu_quick_test
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
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.
98 testbots: xnu_quick_test
99 @(cd $(DSTROOT) ; ./xnu_quick_test -f 100)
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.
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/
112 ifeq "$(Product)" "MacOSX"
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/
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/
124 $(CC) -g $(MY_ARCH) $(SRCSUBPATH)/helpers/data_exec.c -o $(SYMROOT)/data_exec
125 /usr/bin/ditto $(SYMROOT)/data_exec $(DSTROOT)/helpers/
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/
134 $(CC) -g $(MY_ARCH) $(CFLAGS) $(SRCSUBPATH)/helpers/arch.c -o $(SYMROOT)/arch
135 /usr/bin/ditto $(SYMROOT)/arch $(DSTROOT)/helpers/
138 mkdir -p $(DSTROOT)/helpers
141 mkdir -p $(OBJSUBPATH);
149 $(OBJSUBPATH)/main.o : $(SRCSUBPATH)/main.c $(SRCSUBPATH)/tests.h
150 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/main.c -o $@
152 $(OBJSUBPATH)/memory_tests.o : $(SRCSUBPATH)/memory_tests.c $(SRCSUBPATH)/tests.h
153 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/memory_tests.c -o $@
155 # misc.o has to be built 3-way for the helpers to link
156 $(OBJSUBPATH)/misc.o : $(SRCSUBPATH)/misc.c $(SRCSUBPATH)/tests.h
157 ifeq "$(Product)" "iPhoneOS"
158 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
160 $(CC) -arch i386 -arch x86_64 $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/misc.c -o $@
163 $(OBJSUBPATH)/sema_tests.o : $(SRCSUBPATH)/sema_tests.c $(SRCSUBPATH)/tests.h
164 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sema_tests.c -o $@
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 $@
169 $(OBJSUBPATH)/socket_tests.o : $(SRCSUBPATH)/socket_tests.c $(SRCSUBPATH)/tests.h
170 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/socket_tests.c -o $@
172 $(OBJSUBPATH)/tests.o : $(SRCSUBPATH)/tests.c $(SRCSUBPATH)/tests.h
173 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/tests.c -o $@
175 $(OBJSUBPATH)/xattr_tests.o : $(SRCSUBPATH)/xattr_tests.c $(SRCSUBPATH)/tests.h
176 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/xattr_tests.c -o $@
178 $(OBJSUBPATH)/machvm_tests.o : $(SRCSUBPATH)/machvm_tests.c $(SRCSUBPATH)/tests.h
179 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/machvm_tests.c -o $@
181 $(OBJSUBPATH)/sched_tests.o : $(SRCSUBPATH)/sched_tests.c $(SRCSUBPATH)/tests.h
182 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/sched_tests.c -o $@
184 $(OBJSUBPATH)/kqueue_tests.o : $(SRCSUBPATH)/kqueue_tests.c $(SRCSUBPATH)/tests.h
185 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/kqueue_tests.c -o $@
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 $@
190 $(OBJSUBPATH)/commpage_tests.o : $(SRCSUBPATH)/commpage_tests.c $(SRCSUBPATH)/tests.h
191 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/commpage_tests.c -o $@
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 $@
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 $@
199 $(OBJSUBPATH)/pipes_tests.o : $(SRCSUBPATH)/pipes_tests.c $(SRCSUBPATH)/tests.h
200 $(CC) $(CFLAGS) $(MY_ARCH) -c $(SRCSUBPATH)/pipes_tests.c -o $@
204 rm -Rf $(DSTROOT)/xnu_quick_test
205 rm -Rf $(DSTROOT)/helpers/*
206 rm -Rf $(OBJSUBPATH)/*.o