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 MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
22 export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
23 export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
24 export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
25 export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
26 export MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir
29 # Dispatch non-xnu build aliases to their own build
30 # systems. All xnu variants start with MakeInc_top.
33 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
35 ifeq ($(RC_ProjectName),Libsyscall_headers_Sim)
36 TARGET=-target Libsyscall_headers_Sim
42 SDKROOT ?= macosx.internal
46 xcodebuild $@ $(TARGET) \
47 "SRCROOT=$(SRCROOT)/libsyscall" \
48 "OBJROOT=$(OBJROOT)" \
49 "SYMROOT=$(SYMROOT)" \
50 "DSTROOT=$(DSTROOT)" \
58 else ifeq ($(RC_ProjectName),libkxld)
60 include $(MakeInc_cmd)
64 installhdrs install clean:
65 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
68 $(_v)$(MKDIR) $(SRCROOT)
69 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
70 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
72 else ifeq ($(RC_ProjectName),libkxld_host)
74 include $(MakeInc_cmd)
78 installhdrs install clean:
79 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
82 $(_v)$(MKDIR) $(SRCROOT)
83 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
84 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
86 else ifeq ($(RC_ProjectName),libkmod)
93 "SRCROOT=$(SRCROOT)/libkern/kmod" \
94 "OBJROOT=$(OBJROOT)" \
95 "SYMROOT=$(SYMROOT)" \
96 "DSTROOT=$(DSTROOT)" \
104 else ifeq ($(RC_ProjectName),xnu_tests)
106 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
107 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
108 ifeq ($(SYSCTL_HW_PHYSICALCPU),$(SYSCTL_HW_LOGICALCPU))
109 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_PHYSICALCPU) + 1)
111 MAKEJOBS := --jobs=$(SYSCTL_HW_LOGICALCPU)
125 else # all other RC_ProjectName
127 ifndef CURRENT_BUILD_CONFIG
129 # avoid having to include MakeInc.cmd
132 else ifeq ($(VERBOSE),YES)
139 # Setup for parallel sub-makes, taking into account physical and logical
140 # CPUs. If the system does not support SMT, use N+1.
141 # If MAKEJOBS or -jN is passed on the make line, that takes precedence.
143 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
144 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
145 ifeq ($(SYSCTL_HW_PHYSICALCPU),$(SYSCTL_HW_LOGICALCPU))
146 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_PHYSICALCPU) + 1)
148 MAKEJOBS := --jobs=$(SYSCTL_HW_LOGICALCPU)
155 all all_desktop all_embedded \
156 all_release_embedded all_development_embedded \
157 installhdrs installhdrs_desktop installhdrs_embedded \
158 installhdrs_release_embedded installhdrs_development_embedded \
159 install install_desktop install_embedded \
160 install_release_embedded install_development_embedded \
162 cscope tags TAGS checkstyle restyle check_uncrustify uncrustify \
167 # Targets for internal build system debugging
169 print_exports print_exports_first_build_config \
176 ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
178 DEFAULT_TARGET := build
181 .PHONY: $(TOP_TARGETS)
183 default: $(DEFAULT_TARGET)
185 ifneq ($(REMOTEBUILD),)
187 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
190 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
193 else # CURRENT_BUILD_CONFIG
195 include $(MakeInc_cmd)
196 include $(MakeInc_def)
209 CONFIG_SUBDIRS = config tools san
211 INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
212 INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
213 INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
214 INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
215 INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
217 EXPINC_SUBDIRS = $(ALL_SUBDIRS)
218 EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
219 EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
220 EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
221 EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
223 SETUP_SUBDIRS = SETUP osfmk san
225 COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
226 COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
227 COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
228 COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
230 INSTTEXTFILES_SUBDIRS = \
233 include $(MakeInc_kernel)
234 include $(MakeInc_rule)
235 include $(MakeInc_dir)
237 endif # CURRENT_BUILD_CONFIG
239 endif # all other RC_ProjectName
241 installapi_libkdd installhdrs_libkdd install_libkdd:
243 xcodebuild -target Default $(subst _libkdd,,$@) \
244 "SRCROOT=$(SRCROOT)/libkdd" \
245 "OBJROOT=$(OBJROOT)" \
246 "SYMROOT=$(SYMROOT)" \
247 "DSTROOT=$(DSTROOT)" \
251 installapi_libkdd_tests installhdrs_libkdd_tests install_libkdd_tests:
253 xcodebuild -target tests $(subst _libkdd_tests,,$@) \
254 "SRCROOT=$(SRCROOT)/libkdd" \
255 "OBJROOT=$(OBJROOT)" \
256 "SYMROOT=$(SYMROOT)" \
257 "DSTROOT=$(DSTROOT)" \
261 installapi_libkdd_host installhdrs_libkdd_host install_libkdd_host:
263 xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@) \
264 "SRCROOT=$(SRCROOT)/libkdd" \
265 "OBJROOT=$(OBJROOT)" \
266 "SYMROOT=$(SYMROOT)" \
267 "DSTROOT=$(DSTROOT)" \
271 # "xnu_tests" and "testbots" are targets that can be invoked via a standalone
272 # "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
273 # Define the target here in the outermost scope of the initial Makefile
276 $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
277 SRCROOT=$(SRCROOT)/tools/tests
278 $(MAKE) -C $(SRCROOT)/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
279 SRCROOT=$(SRCROOT)/tests