1 # -*- mode: makefile;-*-
3 # Copyright (C) 2010-2016 Apple Inc. All rights reserved.
5 # MakeInc.top is the top-level makefile for the xnu
6 # build system. All the main XBS targets
7 # (like "installhdrs") are defined here, as
8 # well as globals that can be overridden on
9 # the command-line by the user.
11 # This makefile's main purpose is to bootstrap
12 # the user's intent ("build these 3 kernels")
13 # into 3 single-architecture builds that each
14 # invoke the recursive make build system.
15 # As such, we have no knowledge of how to build
16 # a kernel or perform actions other than
17 # invoking a sub-make with a different
18 # current directory, makefile, and target. One
19 # side effect of this is that each
20 # single-architecture build is responsible for
21 # inserting its build products into the final
22 # multi-architecture output files. To avoid
23 # races, these aggregating stages for
24 # "primary" build configs are done in serial.
27 export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
29 include $(MakeInc_cmd)
33 # Architecture Configuration options
36 # Default to current kernel architecture
38 ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
39 override DEFAULT_ARCH_CONFIG := ARM
40 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
41 override DEFAULT_ARCH_CONFIG := X86_64
43 override DEFAULT_ARCH_CONFIG := X86_64
46 # Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS
49 ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
51 ARCH_CONFIGS := DEFAULT
56 # Kernel Configuration options
59 DEFAULT_PRODUCT_CONFIGS :=
61 ifeq ($(RC_ProjectName),xnu_debug)
62 override DEFAULT_KERNEL_CONFIG := DEBUG
63 else ifeq ($(RC_ProjectName),xnu_kasan)
64 override KERNEL_CONFIGS := KASAN
65 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
66 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
67 else ifeq ($(PLATFORM),MacOSX)
68 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
70 override DEFAULT_KERNEL_CONFIG := RELEASE
73 # If KERNEL_CONFIGS is specified it should override default
75 KERNEL_CONFIGS := DEFAULT
78 # If PRODUCT_CONFIGS is specified it should override default
79 ifndef PRODUCT_CONFIGS
80 PRODUCT_CONFIGS := $(DEFAULT_PRODUCT_CONFIGS)
84 # Machine Configuration options
87 override DEFAULT_I386_MACHINE_CONFIG := NONE
88 override DEFAULT_X86_64_MACHINE_CONFIG := NONE
89 override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
92 # This is typically never specified (TARGET_CONFIGS is used)
93 ifndef MACHINE_CONFIGS
94 MACHINE_CONFIGS := DEFAULT
98 # Target configuration options. NOTE - target configurations will
99 # override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
101 # Target configs come in groups of three parameters. The first is the
102 # kernel configuration, the second is the architecture configuration,
103 # and the third is the machine configuration. You may pass in as
104 # many groups of configurations as you wish. Each item passed in is
105 # seperated by whitespace.
108 # TARGET_CONFIGS="release ppc default debug i386 default release arm MX31ADS"
109 # Parameters may be in upper or lower case (they are converted to upper).
111 # "default" parameter is a special case. It means use the default value for
112 # that parameter. Here are the default values for each configuration:
114 # default kernel configuration = DEFAULT_KERNEL_CONFIG
115 # default architecture configuration = system architecture where you are running make.
118 ifeq ($(PLATFORM),MacOSX)
120 # Defaults for "make all_desktop"
121 ifeq ($(KERNEL_CONFIGS),DEFAULT)
122 KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
124 KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
129 ifndef TARGET_CONFIGS
130 ifneq ($(PRODUCT_CONFIGS),)
131 # generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS
132 TARGET_CONFIGS := $(foreach my_devicemap_config,$(foreach my_product_config,$(shell printf "%s" "$(PRODUCT_CONFIGS)" | $(TR) A-Z a-z),$(call function_lookup_product,$(my_product_config))),$(foreach my_kernel_config,$(KERNEL_CONFIGS),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
133 TARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_product_config,$(shell printf "%s" "$(PRODUCT_CONFIGS)" | $(TR) A-Z a-z),$(call function_lookup_product_alias,$(my_product_config))),$(foreach my_kernel_config,$(KERNEL_CONFIGS),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
134 else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),)
135 # generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map
136 TARGET_CONFIGS := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,RELEASE,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
137 TARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,RELEASE,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
138 else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),)
139 # generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map
140 TARGET_CONFIGS := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,DEVELOPMENT,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
141 TARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,DEVELOPMENT,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
142 else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
143 # generate TARGET_CONFIGS for all kernel configs and products in the device map
144 TARGET_CONFIGS := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
145 TARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
146 else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
147 # generate TARGET_CONFIGS for all kernel configs for B&I
148 TARGET_CONFIGS := $(foreach my_kern_config, $(KERNEL_CONFIGS_DESKTOP), $(foreach my_arch_config, $(ARCH_CONFIGS), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
149 TARGET_CONFIGS_ALIASES :=
151 # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
152 TARGET_CONFIGS := $(foreach my_kern_config, $(KERNEL_CONFIGS), $(foreach my_arch_config, $(ARCH_CONFIGS), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
153 TARGET_CONFIGS_ALIASES :=
157 ifeq ($(TARGET_CONFIGS),)
158 $(error No TARGET_CONFIGS specified)
161 TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
162 TARGET_CONFIGS_ALIASES_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS_ALIASES)" | $(TR) a-z A-Z))
165 # Build Configurations
167 # TARGET_CONFIGS is unwieldy for use in Makefiles. Convert them to
168 # "build configurations" which are tuples joined by "^". For
169 # example, "RELEASE I386 DEFAULT DEVELOPMENT ARM DEFAULT" becomes
170 # "RELEASE^I386^NONE DEVELOPMENT^ARM^T8002", which can be looped
171 # over trivially. PRIMARY_BUILD_CONFIGS is the first config
172 # for each architecture, used primarily for machine-dependent recursion.
174 BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
176 PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config)))))
177 PRIMARY_BUILD_CONFIGS = $(strip $(foreach arch, $(PRIMARY_ARCHS), $(firstword $(foreach build_config, $(BUILD_CONFIGS), $(if $(filter $(arch),$(call function_extract_arch_config_from_build_config, $(build_config))), $(build_config), )))))
178 NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS)))
179 FIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS))
181 ifneq ($(TARGET_CONFIGS_ALIASES_UC),)
182 ALIAS_CONFIGS = $(call function_create_alias_configs, $(TARGET_CONFIGS_ALIASES_UC))
187 # $(warning PRIMARY_ARCHS is $(PRIMARY_ARCHS))
188 # $(warning TARGET_CONFIGS is $(TARGET_CONFIGS))
189 # $(warning BUILD_CONFIGS is $(BUILD_CONFIGS))
190 # $(warning PRIMARY_BUILD_CONFIGS is $(PRIMARY_BUILD_CONFIGS))
191 # $(warning NON_PRIMARY_BUILD_CONFIGS is $(NON_PRIMARY_BUILD_CONFIGS))
192 # $(warning TARGET_CONFIGS_ALIASES is $(TARGET_CONFIGS_ALIASES))
193 # $(warning ALIAS_CONFIGS is $(ALIAS_CONFIGS))
195 MEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
197 # Assume LTO scaling by default, unless it is being explicitly passed on the command-line
198 LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1)
200 ifeq ($(LARGE_BUILD_FOOTPRINT),1)
201 RAM_PER_KERNEL_BUILD := 4294967296
203 RAM_PER_KERNEL_BUILD := 268435456
206 KERNEL_BUILDS_IN_PARALLEL := $(shell if [ $(MEMORY_SIZE) -le $$((1 * $(RAM_PER_KERNEL_BUILD))) ]; then echo 1; elif [ $(MEMORY_SIZE) -gt $$(($(SYSCTL_HW_PHYSICALCPU) * $(RAM_PER_KERNEL_BUILD))) ]; then echo $(SYSCTL_HW_PHYSICALCPU); else expr $(MEMORY_SIZE) / $(RAM_PER_KERNEL_BUILD); fi )
207 # $(warning Building $(KERNEL_BUILDS_IN_PARALLEL) kernels in parallel)
210 # TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
212 # $(1) is the name of the makefile target to invoke for the each build config
213 # after setting up the parallel hierarchy in the TARGET directory
214 # $(2) is an optional suffix on the TARGET directory, which might even be
216 # $(3) are any dependencies for the bootstrap target
217 # $(4) are any dependencies that are expanded per-build config to another bootstrap target
218 # $(5) is how many build configurations to build in parallel
219 # $(6) is which build configs to build in parallel
221 # Since building many configurations in parallel may overwhelm the system,
222 # we try to throttle behavior into more managable S "stripes" of N/S
223 # configurations by generating sequential dependencies between configs
224 # in each stripe. That ensures that only S kernel builds are occurring
225 # at once at any point in time
227 define TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
229 # Create a list of synthesized targets for each build config
230 $(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
232 .PHONY: $$($(1)_bootstrap_target_list)
234 $(1)_generated_stripe_dependencies = $$(call _function_generate_stripe_groupings,$(1),$(5),$(call reverse,$(6)))
235 ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
236 $$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies))
238 $$(eval $$($(1)_generated_stripe_dependencies))
240 $$($(1)_bootstrap_target_list): $(1)_bootstrap_% : $(1)_stripe_dep_for_% $$(addsuffix _bootstrap_%,$(4)) $(3)
241 $$(_v)$$(MKDIR) $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)
243 -C $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2) \
244 -f $${SRCROOT}/Makefile \
245 CURRENT_KERNEL_CONFIG=$$(call function_extract_kernel_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
246 CURRENT_ARCH_CONFIG=$$(call function_extract_arch_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
247 CURRENT_MACHINE_CONFIG=$$(call function_extract_machine_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
248 CURRENT_BUILD_CONFIG=$$(patsubst $(1)_bootstrap_%,%,$$@) \
249 PRIMARY_BUILD_CONFIGS="$(PRIMARY_BUILD_CONFIGS)" \
250 SOURCE=$${SRCROOT}/ \
251 RELATIVE_SOURCE_PATH=. \
252 TARGET=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)/ \
253 OBJPATH=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
256 .PHONY: $(1)_bootstrap
258 $(1)_bootstrap: $$($(1)_bootstrap_target_list)
262 # TOP_LEVEL_STRIPE_DEPENDENCY_template
264 # $(1) is the Makefile target we are building for
265 # $(2) is the build config that must build first
266 # $(3) is the build config that must build after $(2)
268 define TOP_LEVEL_STRIPE_DEPENDENCY_template
270 .PHONY: $(1)_stripe_dep_for_$(3)
272 $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
276 # $(1) is the Makefile target we are building for
277 # $(2) is the stripe size
278 # $(3) is the list of the build configs in the current group
279 # $(4) is the list of remaining build configs
280 _function_generate_stripe_groupings_recursive = $(foreach stripe_index,$(call sequence,$(2)),$(if $(word $(stripe_index),$(4)),$(call TOP_LEVEL_STRIPE_DEPENDENCY_template,$(1),$(word $(stripe_index),$(3)),$(word $(stripe_index),$(4))))) $(if $(word $(call increment,$(2)),$(4)),$(call _function_generate_stripe_groupings_recursive,$(1),$(2),$(wordlist 1,$(2),$(4)),$(wordlist $(call increment,$(2)),$(words $(4)),$(4))))
282 # $(1) is the Makefile target we are building for
283 # $(2) is the stripe size
284 # $(3) is the list of the build configs
285 _function_generate_stripe_groupings = $(call _function_generate_stripe_groupings_recursive,$(1),$(2),,$(3))
288 # Setup pass for build system tools
291 generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG))
292 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
293 $(warning Generate makefile fragment: $(generated_top_level_build_setup))
295 $(eval $(generated_top_level_build_setup))
299 # invalidate current kernel in $(SYMROOT). Timestamp must be +1 from a previous kernel build
300 setup: build_setup_bootstrap
301 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new
302 $(_v)while [ \! $(OBJROOT)/.mach_kernel.timestamp.new -nt $(OBJROOT)/.mach_kernel.timestamp ]; do \
304 $(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new; \
306 $(_v)$(MV) $(OBJROOT)/.mach_kernel.timestamp.new $(OBJROOT)/.mach_kernel.timestamp
307 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp.new
308 $(_v)while [ \! $(OBJROOT)/.symbolset.timestamp.new -nt $(OBJROOT)/.symbolset.timestamp ]; do \
310 $(TOUCH) $(OBJROOT)/.symbolset.timestamp.new; \
312 $(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
315 # Install kernel header files
317 .PHONY: exporthdrs exporthdrs_mi exporthdrs_md
319 exporthdrs: exporthdrs_mi exporthdrs_md
322 # Install machine independent kernel header files
325 generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
326 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
327 $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi))
329 $(eval $(generated_top_level_build_exporthdrs_mi))
331 exporthdrs_mi: build_exporthdrs_mi_bootstrap
334 # Install machine dependent kernel header files
337 generated_top_level_build_exporthdrs_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_md,,setup,,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
338 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
339 $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md))
341 $(eval $(generated_top_level_build_exporthdrs_md))
343 exporthdrs_md: build_exporthdrs_md_bootstrap
346 # Install kernel header files
349 .PHONY: installhdrs installhdrs_mi installhdrs_md
351 ifeq ($(RC_ProjectName),xnu_debug)
354 else ifeq ($(RC_ProjectName),xnu_kasan)
359 installhdrs: installhdrs_mi installhdrs_md
362 .PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop
364 installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs
366 installhdrs_development_embedded:
369 # Install machine independent header files
372 generated_top_level_build_installhdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_installhdrs_mi,,setup,build_exporthdrs_mi,1,$(FIRST_BUILD_CONFIG))
373 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
374 $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi))
376 $(eval $(generated_top_level_build_installhdrs_mi))
378 installhdrs_mi: build_installhdrs_mi_bootstrap
381 # Install machine dependent kernel header files
384 generated_top_level_build_installhdrs_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_installhdrs_md,,setup,build_exporthdrs_md,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
385 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
386 $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md))
388 $(eval $(generated_top_level_build_installhdrs_md))
390 installhdrs_md: build_installhdrs_md_bootstrap
393 # Install text files (man pages, dtrace scripts, etc.)
396 generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG))
397 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
398 $(warning Generate makefile fragment: $(generated_top_level_textfiles_install))
400 $(eval $(generated_top_level_textfiles_install))
402 .PHONY: install_textfiles
404 install_textfiles: textfiles_install_bootstrap
407 # Build all architectures for all Configuration/Architecture options
410 generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
411 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
412 $(warning Generate makefile fragment: $(generated_top_level_build_all))
414 $(eval $(generated_top_level_build_all))
418 build: build_all_bootstrap
421 # Post-process build results
424 generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
425 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
426 $(warning Generate makefile fragment: $(generated_top_level_config_all))
428 $(eval $(generated_top_level_config_all))
432 all config: config_all_bootstrap
434 .PHONY: all_embedded all_release_embedded all_development_embedded all_desktop
436 all_embedded all_release_embedded all_development_embedded all_desktop: all
439 # Install kernel files
442 generated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
443 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
444 $(warning Generate makefile fragment: $(generated_top_level_build_install_primary))
446 $(eval $(generated_top_level_build_install_primary))
448 .PHONY: install_primary
450 install_primary: build_install_primary_bootstrap
452 generated_top_level_build_install_non_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_non_primary,,setup,config_all,$(KERNEL_BUILDS_IN_PARALLEL),$(NON_PRIMARY_BUILD_CONFIGS))
453 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
454 $(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary))
456 $(eval $(generated_top_level_build_install_non_primary))
458 .PHONY: install_non_primary
460 install_non_primary: build_install_non_primary_bootstrap
462 generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
463 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
464 $(warning Generate makefile fragment: $(generated_top_level_config_install))
466 $(eval $(generated_top_level_config_install))
468 .PHONY: install_config final_touch_config_timestamps
470 install_config: config_install_bootstrap final_touch_config_timestamps
472 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
473 final_touch_config_timestamps: config_install_bootstrap
474 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp
477 # Aggregate install targets, which install everything appropriate for the current build alias/make target
482 ifeq ($(RC_ProjectName),xnu_debug)
483 install: install_kernels
484 else ifeq ($(RC_ProjectName),xnu_kasan)
485 install: install_config install_kernels
486 else ifeq ($(RC_ProjectName),xnu_headers_Sim)
490 install: installhdrs install_textfiles install_config install_kernels install_aliases
493 .PHONY: install_embedded install_release_embedded install_development_embedded install_desktop
495 # By default, all kernel files, headers, text files, and pseudo-kexts are installed
496 install_embedded install_release_embedded install_desktop: install
498 # These special configs only install the kernel files
499 install_development_embedded: install_kernels install_aliases
501 .PHONY: install_kernels final_touch_kernel_timestamps install_aliases
503 install_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
505 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
506 final_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
507 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
509 # Copy kernels that are aliases of another configuration
510 generated_top_level_install_alias = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,install_alias,,install_kernels,,$(KERNEL_BUILDS_IN_PARALLEL),$(ALIAS_CONFIGS))
511 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
512 $(warning Generate makefile fragment: $(generated_top_level_install_alias))
514 $(eval $(generated_top_level_install_alias))
516 install_aliases: install_alias_bootstrap
519 # Install source tree
524 @echo INSTALLSRC $(SRCROOT)
525 $(_v)$(MKDIR) $(SRCROOT)
526 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
527 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
531 # Clean up source tree
535 CLEAN_RM_DIRS= $(OBJROOT) $(SYMROOT) $(DSTROOT) \
536 $(SRCROOT)/tools/test/BUILD \
537 $(SRCROOT)/tools/tests/darwintests/build \
538 $(SRCROOT)/tools/tests/testkext/build \
539 $(SRCROOT)/libkdd/build \
540 $(SRCROOT)/tools/tests/unit_tests/BUILD \
541 $(SRCROOT)/tools/tests/execperf/BUILD \
542 $(SRCROOT)/tools/tests/packetdrill/BUILD \
543 $(SRCROOT)/tools/tests/perf_index/BUILD
545 CLEAN_ACTION_DIRS= $(SRCROOT)/tools/tests/MPMMTest \
546 $(SRCROOT)/tools/tests/TLBcoherency \
547 $(SRCROOT)/tools/tests/kqueue_tests \
548 $(SRCROOT)/tools/tests/libMicro \
549 $(SRCROOT)/tools/tests/mktimer \
550 $(SRCROOT)/tools/tests/zero-to-n \
551 $(SRCROOT)/tools/tests/personas
555 $(_v)rm -f cscope.* 2> /dev/null
556 $(_v)rm -f TAGS 2> /dev/null
557 $(_v)for cdir in $(CLEAN_RM_DIRS); do \
558 if [ -d $${cdir} ] ; then \
559 echo "Removing $${cdir}"; \
560 rm -fr $${cdir} 2> /dev/null || true ; \
564 $(_v)for mcdir in $(CLEAN_ACTION_DIRS); do \
565 make -C $${mcdir} clean; \
570 # Build source file list for cscope database and tags
575 @echo "Building file list for cscope and tags"
576 @find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
577 @find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
578 @find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
579 @find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
580 @find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
581 @find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
582 @cat $(OBJROOT)/cscope.genhdrs/* >> _cscope.files 2> /dev/null || true
583 @echo -k -q -c > cscope.files 2> /dev/null
584 @sort -u < _cscope.files >> cscope.files 2> /dev/null
585 @rm -f _cscope.files _cscope.files2 2> /dev/null
588 # Build cscope database
591 @echo "Building cscope database"
592 @cscope -bvU 2> /dev/null
598 @echo "Building ctags"
599 @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
600 echo "Phantom files detected!" 2>&1 > /dev/null
601 @-[ -f TAGS ] || ${MAKE} -f $(firstword $(MAKEFILE_LIST)) TAGS
604 @echo "Building etags"
605 @-cat cscope.files | etags -l auto -S - 2> /dev/null
606 @rm -f cscope.files 2> /dev/null
609 # Re-indent source code using xnu clang-format style
614 $(_v)$(SRCROOT)/tools/reindent.sh
621 .PHONY: print_exports
626 generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG))
627 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
628 $(warning Generate makefile fragment: $(generated_top_level_print_exports))
630 $(eval $(generated_top_level_print_exports))
632 .PHONY: print_exports_first_build_config
634 print_exports_first_build_config: print_exports_bootstrap