2 # Copyright (C) 1999-2016 Apple Inc. All rights reserved.
5 export VERSDIR := $(shell /bin/pwd)
9 export SRCROOT := $(shell /bin/pwd)
12 export OBJROOT = $(SRCROOT)/BUILD/obj
15 export DSTROOT = $(SRCROOT)/BUILD/dst
18 export SYMROOT = $(SRCROOT)/BUILD/sym
21 export MallocNanoZone := 1
24 # Avoid make default rules, make becomes faster
27 export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
28 export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
29 export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
30 export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
31 export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
32 export MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir
35 # Dispatch non-xnu build aliases to their own build
36 # systems. All xnu variants start with MakeInc_top.
39 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
41 include $(MakeInc_cmd)
43 ifneq ($(findstring Libsyscall_,$(RC_ProjectName)),)
44 TARGET=-target $(RC_ProjectName)
50 SDKROOT ?= macosx.internal
54 xcodebuild $@ $(TARGET) \
56 "SRCROOT=$(SRCROOT)/libsyscall" \
57 "OBJROOT=$(OBJROOT)" \
58 "SYMROOT=$(SYMROOT)" \
59 "DSTROOT=$(DSTROOT)" \
62 Libsyscall_driverkit: install
64 .PHONY: Libsyscall_driverkit
71 else ifeq ($(RC_ProjectName),libkxld)
73 include $(MakeInc_cmd)
77 installhdrs install clean:
78 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
81 $(_v)$(MKDIR) $(SRCROOT)
82 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
83 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
85 else ifeq ($(RC_ProjectName),libkxld_host)
87 include $(MakeInc_cmd)
91 installhdrs install clean:
92 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
95 $(_v)$(MKDIR) $(SRCROOT)
96 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
97 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
99 else ifeq ($(RC_ProjectName),libkmod)
107 "SRCROOT=$(SRCROOT)/libkern/kmod" \
108 "OBJROOT=$(OBJROOT)" \
109 "SYMROOT=$(SYMROOT)" \
110 "DSTROOT=$(DSTROOT)" \
118 else ifeq ($(RC_ProjectName),xnu_tests)
120 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
121 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
122 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
135 else # all other RC_ProjectName
137 ifndef CURRENT_BUILD_CONFIG
139 # avoid having to include MakeInc.cmd
142 else ifeq ($(VERBOSE),YES)
149 # Setup for parallel sub-makes, taking into account physical and logical
150 # CPUs. If the system does not support SMT, use N+1.
151 # If MAKEJOBS or -jN is passed on the make line, that takes precedence.
153 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
154 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
155 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
161 all all_desktop all_embedded \
162 all_release_embedded all_development_embedded \
163 installhdrs installhdrs_desktop installhdrs_embedded \
164 installhdrs_release_embedded installhdrs_development_embedded \
165 install install_desktop install_embedded \
166 install_release_embedded install_development_embedded \
168 cscope tags TAGS checkstyle restyle check_uncrustify uncrustify \
173 # Targets for internal build system debugging
175 print_exports print_exports_first_build_config \
182 ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
184 DEFAULT_TARGET := build
187 .PHONY: $(TOP_TARGETS)
189 default: $(DEFAULT_TARGET)
191 ifneq ($(REMOTEBUILD),)
193 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
196 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
199 else # CURRENT_BUILD_CONFIG
201 include $(MakeInc_cmd)
202 include $(MakeInc_def)
215 CONFIG_SUBDIRS = config tools san
217 INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
218 INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
219 INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
220 INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
221 INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
223 EXPINC_SUBDIRS = $(ALL_SUBDIRS)
224 EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
225 EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
226 EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
227 EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
229 SETUP_SUBDIRS = SETUP san bsd
231 COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
232 COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
233 COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
234 COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
236 INSTTEXTFILES_SUBDIRS = \
239 include $(MakeInc_kernel)
240 include $(MakeInc_rule)
241 include $(MakeInc_dir)
243 endif # CURRENT_BUILD_CONFIG
245 endif # all other RC_ProjectName
247 installapi_libkdd installhdrs_libkdd install_libkdd:
249 xcodebuild -target Default $(subst _libkdd,,$@) \
251 "SRCROOT=$(SRCROOT)/libkdd" \
252 "OBJROOT=$(OBJROOT)" \
253 "SYMROOT=$(SYMROOT)" \
254 "DSTROOT=$(DSTROOT)" \
258 installapi_libkdd_tests installhdrs_libkdd_tests install_libkdd_tests:
260 xcodebuild -target tests $(subst _libkdd_tests,,$@) \
262 "SRCROOT=$(SRCROOT)/libkdd" \
263 "OBJROOT=$(OBJROOT)" \
264 "SYMROOT=$(SYMROOT)" \
265 "DSTROOT=$(DSTROOT)" \
269 installapi_libkdd_host installhdrs_libkdd_host install_libkdd_host:
271 xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@) \
273 "SRCROOT=$(SRCROOT)/libkdd" \
274 "OBJROOT=$(OBJROOT)" \
275 "SYMROOT=$(SYMROOT)" \
276 "DSTROOT=$(DSTROOT)" \
280 # "xnu_tests" and "testbots" are targets that can be invoked via a standalone
281 # "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
282 # Define the target here in the outermost scope of the initial Makefile
285 $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
286 SRCROOT=$(SRCROOT)/tools/tests
287 $(MAKE) -C $(SRCROOT)/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
288 SRCROOT=$(SRCROOT)/tests