2 # Copyright (C) 1999-2013 Apple Inc. All rights reserved.
6 export VERSDIR := $(shell /bin/pwd)
10 export SRCROOT := $(shell /bin/pwd)
13 export OBJROOT = $(SRCROOT)/BUILD/obj
16 export DSTROOT = $(SRCROOT)/BUILD/dst
19 export SYMROOT = $(SRCROOT)/BUILD/sym
22 export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
23 export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
24 export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
25 export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
26 export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
27 export MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir
30 # Dispatch non-xnu build aliases to their own build
31 # systems. All xnu variants start with MakeInc_top.
34 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
36 ifeq ($(RC_ProjectName),Libsyscall_headers_Sim)
37 TARGET=-target Libsyscall_headers_Sim
44 xcodebuild $@ $(TARGET) \
45 "SRCROOT=$(SRCROOT)/libsyscall" \
46 "OBJROOT=$(OBJROOT)" \
47 "SYMROOT=$(SYMROOT)" \
48 "DSTROOT=$(DSTROOT)" \
56 else ifeq ($(RC_ProjectName),libkxld)
58 include $(MakeInc_cmd)
62 installhdrs install clean:
63 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
66 $(_v)$(MKDIR) $(SRCROOT)
67 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
68 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
70 else ifeq ($(RC_ProjectName),libkxld_host)
72 include $(MakeInc_cmd)
76 installhdrs install clean:
77 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
80 $(_v)$(MKDIR) $(SRCROOT)
81 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
82 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
84 else ifeq ($(RC_ProjectName),libkmod)
91 "SRCROOT=$(SRCROOT)/libkern/kmod" \
92 "OBJROOT=$(OBJROOT)" \
93 "SYMROOT=$(SYMROOT)" \
94 "DSTROOT=$(DSTROOT)" \
102 else ifeq ($(RC_ProjectName),xnu_quick_test)
103 # This rule should be removed once rdar://22820602 is complete.
115 else ifeq ($(RC_ProjectName),xnu_tests)
128 else # all other RC_ProjectName
130 ifndef CURRENT_BUILD_CONFIG
132 # avoid having to include MakeInc.cmd
135 else ifeq ($(VERBOSE),YES)
142 # Setup for parallel sub-makes, taking into account physical and logical
143 # CPUs. If the system does not support SMT, use N+1.
144 # If MAKEJOBS or -jN is passed on the make line, that takes precedence.
146 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
147 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
148 ifeq ($(SYSCTL_HW_PHYSICALCPU),$(SYSCTL_HW_LOGICALCPU))
149 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_PHYSICALCPU) + 1)
151 MAKEJOBS := --jobs=$(SYSCTL_HW_LOGICALCPU)
158 all all_desktop all_embedded \
159 all_release_embedded all_development_embedded \
160 installhdrs installhdrs_desktop installhdrs_embedded \
161 installhdrs_release_embedded installhdrs_development_embedded \
162 install install_desktop install_embedded \
163 install_release_embedded install_development_embedded \
165 cscope tags TAGS reindent \
170 # Targets for internal build system debugging
172 print_exports print_exports_first_build_config \
179 ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
181 DEFAULT_TARGET := build
184 .PHONY: $(TOP_TARGETS)
186 default: $(DEFAULT_TARGET)
188 ifneq ($(REMOTEBUILD),)
190 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
193 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
196 else # CURRENT_BUILD_CONFIG
198 include $(MakeInc_cmd)
199 include $(MakeInc_def)
211 CONFIG_SUBDIRS = config tools
213 INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
214 INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
215 INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
216 INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
217 INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
219 EXPINC_SUBDIRS = $(ALL_SUBDIRS)
220 EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
221 EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
222 EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
223 EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
225 SETUP_SUBDIRS = SETUP
227 COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
228 COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
229 COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
230 COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
232 INSTTEXTFILES_SUBDIRS = \
235 include $(MakeInc_kernel)
236 include $(MakeInc_rule)
237 include $(MakeInc_dir)
239 endif # CURRENT_BUILD_CONFIG
241 endif # all other RC_ProjectName
243 installhdrs_libkdd install_libkdd:
245 xcodebuild $(subst _libkdd,,$@) \
246 "SRCROOT=$(SRCROOT)/libkdd" \
247 "OBJROOT=$(OBJROOT)" \
248 "SYMROOT=$(SYMROOT)" \
249 "DSTROOT=$(DSTROOT)" \
253 # "xnu_tests" and "testbots" are targets that can be invoked via a standalone
254 # "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
255 # Define the target here in the outermost scope of the initial Makefile
257 xnu_tests xnu_quick_test:
258 $(MAKE) -C $(SRCROOT)/tools/tests \
259 SRCROOT=$(SRCROOT)/tools/tests
261 # This target is defined to compile and run xnu_quick_test under testbots
263 $(MAKE) -C $(SRCROOT)/tools/tests/xnu_quick_test \
264 SRCROOT=$(SRCROOT)/tools/tests/xnu_quick_test \
265 MORECFLAGS="-DRUN_UNDER_TESTBOTS=1" \