1 # -*- mode: makefile;-*-
3 # Copyright (C) 2010-2014 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
47 # Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS
50 ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
52 ARCH_CONFIGS := DEFAULT
57 # Kernel Configuration options
60 ifeq ($(RC_ProjectName),xnu_debug)
61 override DEFAULT_KERNEL_CONFIG := DEBUG
62 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
63 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
64 else ifeq ($(PLATFORM),MacOSX)
65 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
67 override DEFAULT_KERNEL_CONFIG := RELEASE
70 # If KERNEL_CONFIGS is specified it should override default
72 KERNEL_CONFIGS := DEFAULT
76 # Machine Configuration options
79 override DEFAULT_I386_MACHINE_CONFIG := NONE
80 override DEFAULT_X86_64_MACHINE_CONFIG := NONE
81 override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
84 # This is typically never specified (TARGET_CONFIGS is used)
85 ifndef MACHINE_CONFIGS
86 MACHINE_CONFIGS := DEFAULT
90 # Target configuration options. NOTE - target configurations will
91 # override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
93 # Target configs come in groups of three parameters. The first is the
94 # kernel configuration, the second is the architecture configuration,
95 # and the third is the machine configuration. You may pass in as
96 # many groups of configurations as you wish. Each item passed in is
97 # seperated by whitespace.
100 # TARGET_CONFIGS="release ppc default debug i386 default release arm MX31ADS"
101 # Parameters may be in upper or lower case (they are converted to upper).
103 # "default" parameter is a special case. It means use the default value for
104 # that parameter. Here are the default values for each configuration:
106 # default kernel configuration = DEFAULT_KERNEL_CONFIG
107 # default architecture configuration = system architecture where you are running make.
110 ifeq ($(PLATFORM),MacOSX)
112 # Defaults for "make all_desktop"
113 ifeq ($(KERNEL_CONFIGS),DEFAULT)
114 KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
116 KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
121 ifndef TARGET_CONFIGS
122 ifneq ($(PRODUCT_CONFIGS),)
123 # generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS
124 TARGET_CONFIGS := $(foreach my_kernel_config,$(KERNEL_CONFIGS),$(foreach my_product_config,$(shell printf "%s" "$(PRODUCT_CONFIGS)" | $(TR) A-Z a-z),$(my_kernel_config) $(subst ;, ,$(call function_lookup_product,$(my_product_config)))))
125 else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),)
126 # generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map
127 TARGET_CONFIGS := $(foreach my_kernel_config,RELEASE,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(my_kernel_config) $(subst ;, ,$(call function_lookup_product,$(my_product_config))))))
128 else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),)
129 # generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map
130 TARGET_CONFIGS := $(foreach my_kernel_config,DEVELOPMENT,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(my_kernel_config) $(subst ;, ,$(call function_lookup_product,$(my_product_config))))))
131 else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
132 # generate TARGET_CONFIGS for all kernel configs and products in the device map
133 TARGET_CONFIGS := $(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(my_kernel_config) $(subst ;, ,$(call function_lookup_product,$(my_product_config))))))
134 else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
135 # generate TARGET_CONFIGS for all kernel configs for B&I
136 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))))
138 # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
139 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))))
143 ifeq ($(TARGET_CONFIGS),)
144 $(error No TARGET_CONFIGS specified)
147 TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
150 # Build Configurations
152 # TARGET_CONFIGS is unwieldy for use in Makefiles. Convert them to
153 # "build configurations" which are tuples joined by "^". For
154 # example, "RELEASE I386 DEFAULT DEVELOPMENT ARM DEFAULT" becomes
155 # "RELEASE^I386^NONE DEVELOPMENT^ARM^S5L8920X", which can be looped
156 # over trivially. PRIMARY_BUILD_CONFIGS is the first config
157 # for each architecture, used primarily for machine-dependent recursion.
159 BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
161 PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config)))))
162 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), )))))
163 NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS)))
164 FIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS))
166 # $(warning PRIMARY_ARCHS is $(PRIMARY_ARCHS))
167 # $(warning TARGET_CONFIGS is $(TARGET_CONFIGS))
168 # $(warning BUILD_CONFIGS is $(BUILD_CONFIGS))
169 # $(warning PRIMARY_BUILD_CONFIGS is $(PRIMARY_BUILD_CONFIGS))
170 # $(warning NON_PRIMARY_BUILD_CONFIGS is $(NON_PRIMARY_BUILD_CONFIGS))
172 MEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
174 # Assume LTO scaling by default, unless it is being explicitly passed on the command-line
175 LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1)
177 ifeq ($(LARGE_BUILD_FOOTPRINT),1)
178 RAM_PER_KERNEL_BUILD := 8589934592
180 RAM_PER_KERNEL_BUILD := 268435456
183 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 )
184 # $(warning Building $(KERNEL_BUILDS_IN_PARALLEL) kernels in parallel)
187 # TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
189 # $(1) is the name of the makefile target to invoke for the each build config
190 # after setting up the parallel hierarchy in the TARGET directory
191 # $(2) is an optional suffix on the TARGET directory, which might even be
193 # $(3) are any dependencies for the bootstrap target
194 # $(4) are any dependencies that are expanded per-build config to another bootstrap target
195 # $(5) is how many build configurations to build in parallel
196 # $(6) is which build configs to build in parallel
198 # Since building many configurations in parallel may overwhelm the system,
199 # we try to throttle behavior into more managable S "stripes" of N/S
200 # configurations by generating sequential dependencies between configs
201 # in each stripe. That ensures that only S kernel builds are occurring
202 # at once at any point in time
204 define TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
206 # Create a list of synthesized targets for each build config
207 $(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
209 .PHONY: $$($(1)_bootstrap_target_list)
211 $(1)_generated_stripe_dependencies = $$(call _function_generate_stripe_groupings,$(1),$(5),$(call reverse,$(6)))
212 ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
213 $$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies))
215 $$(eval $$($(1)_generated_stripe_dependencies))
218 $$($(1)_bootstrap_target_list): $(1)_bootstrap_% : $(1)_stripe_dep_for_% $$(addsuffix _bootstrap_%,$(4)) $(3)
219 $$(_v)$$(MKDIR) $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)
221 -C $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2) \
222 -f $${SRCROOT}/Makefile \
223 CURRENT_KERNEL_CONFIG=$$(call function_extract_kernel_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
224 CURRENT_ARCH_CONFIG=$$(call function_extract_arch_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
225 CURRENT_MACHINE_CONFIG=$$(call function_extract_machine_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
226 CURRENT_BUILD_CONFIG=$$(patsubst $(1)_bootstrap_%,%,$$@) \
227 PRIMARY_BUILD_CONFIGS="$(PRIMARY_BUILD_CONFIGS)" \
228 SOURCE=$${SRCROOT}/ \
229 RELATIVE_SOURCE_PATH=. \
230 TARGET=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)/ \
231 OBJPATH=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
234 .PHONY: $(1)_bootstrap
236 $(1)_bootstrap: $$($(1)_bootstrap_target_list)
240 # TOP_LEVEL_STRIPE_DEPENDENCY_template
242 # $(1) is the Makefile target we are building for
243 # $(2) is the build config that must build first
244 # $(3) is the build config that must build after $(2)
246 define TOP_LEVEL_STRIPE_DEPENDENCY_template
248 .PHONY: $(1)_stripe_dep_for_$(3)
250 $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
254 # $(1) is the Makefile target we are building for
255 # $(2) is the stripe size
256 # $(3) is the list of the build configs in the current group
257 # $(4) is the list of remaining build configs
258 _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))))
261 # $(1) is the Makefile target we are building for
262 # $(2) is the stripe size
263 # $(3) is the list of the build configs
264 _function_generate_stripe_groupings = $(call _function_generate_stripe_groupings_recursive,$(1),$(2),,$(3))
267 # Setup pass for build system tools
270 generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG))
271 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
272 $(warning Generate makefile fragment: $(generated_top_level_build_setup))
274 $(eval $(generated_top_level_build_setup))
278 # invalidate current kernel in $(SYMROOT). Timestamp must be +1 from a previous kernel build
279 setup: build_setup_bootstrap
280 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new
281 $(_v)while [ \! $(OBJROOT)/.mach_kernel.timestamp.new -nt $(OBJROOT)/.mach_kernel.timestamp ]; do \
283 $(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new; \
285 $(_v)$(MV) $(OBJROOT)/.mach_kernel.timestamp.new $(OBJROOT)/.mach_kernel.timestamp
286 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp.new
287 $(_v)while [ \! $(OBJROOT)/.symbolset.timestamp.new -nt $(OBJROOT)/.symbolset.timestamp ]; do \
289 $(TOUCH) $(OBJROOT)/.symbolset.timestamp.new; \
291 $(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
294 # Install kernel header files
296 .PHONY: exporthdrs exporthdrs_mi exporthdrs_md
298 exporthdrs: exporthdrs_mi exporthdrs_md
301 # Install machine independent kernel header files
304 generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
305 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
306 $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi))
308 $(eval $(generated_top_level_build_exporthdrs_mi))
310 exporthdrs_mi: build_exporthdrs_mi_bootstrap
313 # Install machine dependent kernel header files
316 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))
317 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
318 $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md))
320 $(eval $(generated_top_level_build_exporthdrs_md))
322 exporthdrs_md: build_exporthdrs_md_bootstrap
325 # Install kernel header files
328 .PHONY: installhdrs installhdrs_mi installhdrs_md
330 ifeq ($(RC_ProjectName),xnu_debug)
335 installhdrs: installhdrs_mi installhdrs_md
338 .PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop
340 installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs
342 installhdrs_development_embedded:
345 # Install machine independent header files
348 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))
349 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
350 $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi))
352 $(eval $(generated_top_level_build_installhdrs_mi))
354 installhdrs_mi: build_installhdrs_mi_bootstrap
357 # Install machine dependent kernel header files
360 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))
361 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
362 $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md))
364 $(eval $(generated_top_level_build_installhdrs_md))
366 installhdrs_md: build_installhdrs_md_bootstrap
369 # Install text files (man pages, dtrace scripts, etc.)
372 generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG))
373 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
374 $(warning Generate makefile fragment: $(generated_top_level_textfiles_install))
376 $(eval $(generated_top_level_textfiles_install))
378 .PHONY: install_textfiles
380 install_textfiles: textfiles_install_bootstrap
383 # Build all architectures for all Configuration/Architecture options
386 generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
387 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
388 $(warning Generate makefile fragment: $(generated_top_level_build_all))
390 $(eval $(generated_top_level_build_all))
394 build: build_all_bootstrap
397 # Post-process build results
400 generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
401 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
402 $(warning Generate makefile fragment: $(generated_top_level_config_all))
404 $(eval $(generated_top_level_config_all))
408 all config: config_all_bootstrap
410 .PHONY: all_embedded all_release_embedded all_development_embedded all_desktop
412 all_embedded all_release_embedded all_development_embedded all_desktop: all
415 # Install kernel files
418 generated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
419 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
420 $(warning Generate makefile fragment: $(generated_top_level_build_install_primary))
422 $(eval $(generated_top_level_build_install_primary))
424 .PHONY: install_primary
426 install_primary: build_install_primary_bootstrap
428 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))
429 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
430 $(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary))
432 $(eval $(generated_top_level_build_install_non_primary))
434 .PHONY: install_non_primary
436 install_non_primary: build_install_non_primary_bootstrap
438 generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
439 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
440 $(warning Generate makefile fragment: $(generated_top_level_config_install))
442 $(eval $(generated_top_level_config_install))
444 .PHONY: install_config final_touch_config_timestamps
446 install_config: config_install_bootstrap final_touch_config_timestamps
448 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
449 final_touch_config_timestamps: config_install_bootstrap
450 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp
453 # Aggregate install targets, which install everything appropriate for the current build alias/make target
458 ifeq ($(RC_ProjectName),xnu_debug)
459 install: install_kernels
460 else ifeq ($(RC_ProjectName),xnu_headers_Sim)
464 install: installhdrs install_textfiles install_config install_kernels
467 .PHONY: install_embedded install_release_embedded install_development_embedded install_desktop
469 # By default, all kernel files, headers, text files, and pseudo-kexts are installed
470 install_embedded install_release_embedded install_desktop: install
472 # These special configs only install the kernel files
473 install_development_embedded: install_kernels
475 .PHONY: install_kernels final_touch_kernel_timestamps
477 install_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
479 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
480 final_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
481 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
484 # Install source tree
489 @echo INSTALLSRC $(SRCROOT)
490 $(_v)$(MKDIR) $(SRCROOT)
491 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
492 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
496 # Clean up source tree
502 @rm -f cscope.* 2> /dev/null
503 @rm -f $(OBJROOT)/cscope.genhdrs/* 2> /dev/null || true
504 @rm -f TAGS 2> /dev/null
508 # Build source file list for cscope database and tags
513 @echo "Building file list for cscope and tags"
514 @find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
515 @find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
516 @find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
517 @find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
518 @find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
519 @find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
520 @cat $(OBJROOT)/cscope.genhdrs/* >> _cscope.files 2> /dev/null || true
521 @echo -k -q -c > cscope.files 2> /dev/null
522 @sort -u < _cscope.files >> cscope.files 2> /dev/null
523 @rm -f _cscope.files _cscope.files2 2> /dev/null
526 # Build cscope database
529 @echo "Building cscope database"
530 @cscope -bvU 2> /dev/null
536 @echo "Building ctags"
537 @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
538 echo "Phantom files detected!" 2>&1 > /dev/null
539 @-[ -f TAGS ] || ${MAKE} -f $(firstword $(MAKEFILE_LIST)) TAGS
542 @echo "Building etags"
543 @-cat cscope.files | etags -l auto -S - 2> /dev/null
544 @rm -f cscope.files 2> /dev/null
547 # Re-indent source code using xnu clang-format style
552 $(_v)$(SRCROOT)/tools/reindent.sh
559 .PHONY: print_exports
565 generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG))
566 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
567 $(warning Generate makefile fragment: $(generated_top_level_print_exports))
569 $(eval $(generated_top_level_print_exports))
571 .PHONY: print_exports_first_build_config
573 print_exports_first_build_config: print_exports_bootstrap