1 # -*- mode: makefile;-*-
3 # Copyright (C) 2010-2012 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
37 ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
38 override DEFAULT_ARCH_CONFIG := ARM
39 else ifneq ($(filter iPhoneSimulator iPhoneNanoSimulator,$(PLATFORM)),)
40 override DEFAULT_ARCH_CONFIG := X86_64
42 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 | sed -E 's/ARMV[0-9][A-Z]?/ARM/g' | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
51 ARCH_CONFIGS := DEFAULT
56 # Kernel Configuration options
59 ifeq ($(RC_ProjectName),xnu_debug)
60 override DEFAULT_KERNEL_CONFIG := DEBUG
61 else ifneq ($(filter iPhoneOS iPhoneOSNano,$(PLATFORM)),)
62 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
63 else ifeq ($(PLATFORM),MacOSX)
64 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
66 override DEFAULT_KERNEL_CONFIG := RELEASE
69 # If KERNEL_CONFIGS is specified it should override default
71 KERNEL_CONFIGS := DEFAULT
75 # Machine Configuration options
78 override DEFAULT_I386_MACHINE_CONFIG := NONE
79 override DEFAULT_X86_64_MACHINE_CONFIG := NONE
80 override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
83 # This is typically never specified (TARGET_CONFIGS is used)
84 ifndef MACHINE_CONFIGS
85 MACHINE_CONFIGS := DEFAULT
89 # Target configuration options. NOTE - target configurations will
90 # override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
92 # Target configs come in groups of three parameters. The first is the
93 # kernel configuration, the second is the architecture configuration,
94 # and the third is the machine configuration. You may pass in as
95 # many groups of configurations as you wish. Each item passed in is
96 # seperated by whitespace.
99 # TARGET_CONFIGS="release ppc default debug i386 default release arm MX31ADS"
100 # Parameters may be in upper or lower case (they are converted to upper).
102 # "default" parameter is a special case. It means use the default value for
103 # that parameter. Here are the default values for each configuration:
105 # default kernel configuration = DEFAULT_KERNEL_CONFIG
106 # default architecture configuration = system architecture where you are running make.
109 ifeq ($(PLATFORM),MacOSX)
111 # Defaults for "make all_desktop"
112 ifeq ($(KERNEL_CONFIGS),DEFAULT)
113 KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
115 KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
120 ifndef TARGET_CONFIGS
121 ifneq ($(PRODUCT_CONFIGS),)
122 # generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS
123 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)))))
124 else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),)
125 # generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map
126 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))))))
127 else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),)
128 # generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map
129 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))))))
130 else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
131 # generate TARGET_CONFIGS for all kernel configs and products in the device map
132 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))))))
133 else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
134 # generate TARGET_CONFIGS for all kernel configs for B&I
135 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))))
137 # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
138 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))))
142 ifeq ($(TARGET_CONFIGS),)
143 $(error No TARGET_CONFIGS specified)
146 TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
149 # Build Configurations
151 # TARGET_CONFIGS is unwieldy for use in Makefiles. Convert them to
152 # "build configurations" which are tuples joined by "^". For
153 # example, "RELEASE I386 DEFAULT DEVELOPMENT ARM DEFAULT" becomes
154 # "RELEASE^I386^NONE DEVELOPMENT^ARM^S5L8920X", which can be looped
155 # over trivially. PRIMARY_BUILD_CONFIGS is the first config
156 # for each architecture, used primarily for machine-dependent recursion.
158 BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
160 PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config)))))
161 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), )))))
162 NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS)))
163 FIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS))
165 # $(warning PRIMARY_ARCHS is $(PRIMARY_ARCHS))
166 # $(warning TARGET_CONFIGS is $(TARGET_CONFIGS))
167 # $(warning BUILD_CONFIGS is $(BUILD_CONFIGS))
168 # $(warning PRIMARY_BUILD_CONFIGS is $(PRIMARY_BUILD_CONFIGS))
169 # $(warning NON_PRIMARY_BUILD_CONFIGS is $(NON_PRIMARY_BUILD_CONFIGS))
171 MEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
173 # Assume LTO scaling by default, unless it is being explicitly passed on the command-line
174 LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1)
176 ifeq ($(LARGE_BUILD_FOOTPRINT),1)
177 RAM_PER_KERNEL_BUILD := 8589934592
179 RAM_PER_KERNEL_BUILD := 268435456
182 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 )
183 # $(warning Building $(KERNEL_BUILDS_IN_PARALLEL) kernels in parallel)
186 # TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
188 # $(1) is the name of the makefile target to invoke for the each build config
189 # after setting up the parallel hierarchy in the TARGET directory
190 # $(2) is an optional suffix on the TARGET directory, which might even be
192 # $(3) are any dependencies for the bootstrap target
193 # $(4) are any dependencies that are expanded per-build config to another bootstrap target
194 # $(5) is how many build configurations to build in parallel
195 # $(6) is which build configs to build in parallel
197 # Since building many configurations in parallel may overwhelm the system,
198 # we try to throttle behavior into more managable S "stripes" of N/S
199 # configurations by generating sequential dependencies between configs
200 # in each stripe. That ensures that only S kernel builds are occurring
201 # at once at any point in time
203 define TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
205 # Create a list of synthesized targets for each build config
206 $(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
208 .PHONY: $$($(1)_bootstrap_target_list)
210 $(1)_generated_stripe_dependencies = $$(call _function_generate_stripe_groupings,$(1),$(5),$(call reverse,$(6)))
211 ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
212 $$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies))
214 $$(eval $$($(1)_generated_stripe_dependencies))
217 $$($(1)_bootstrap_target_list): $(1)_bootstrap_% : $(1)_stripe_dep_for_% $$(addsuffix _bootstrap_%,$(4)) $(3)
218 $$(_v)$$(MKDIR) $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)
220 -C $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2) \
221 -f $${SRCROOT}/Makefile \
222 CURRENT_KERNEL_CONFIG=$$(call function_extract_kernel_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
223 CURRENT_ARCH_CONFIG=$$(call function_extract_arch_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
224 CURRENT_MACHINE_CONFIG=$$(call function_extract_machine_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
225 CURRENT_BUILD_CONFIG=$$(patsubst $(1)_bootstrap_%,%,$$@) \
226 PRIMARY_BUILD_CONFIGS="$(PRIMARY_BUILD_CONFIGS)" \
227 SOURCE=$${SRCROOT}/ \
228 RELATIVE_SOURCE_PATH=. \
229 TARGET=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)/ \
230 OBJPATH=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
233 .PHONY: $(1)_bootstrap
235 $(1)_bootstrap: $$($(1)_bootstrap_target_list)
239 # TOP_LEVEL_STRIPE_DEPENDENCY_template
241 # $(1) is the Makefile target we are building for
242 # $(2) is the build config that must build first
243 # $(3) is the build config that must build after $(2)
245 define TOP_LEVEL_STRIPE_DEPENDENCY_template
247 .PHONY: $(1)_stripe_dep_for_$(3)
249 $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
253 # $(1) is the Makefile target we are building for
254 # $(2) is the stripe size
255 # $(3) is the list of the build configs in the current group
256 # $(4) is the list of remaining build configs
257 _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))))
260 # $(1) is the Makefile target we are building for
261 # $(2) is the stripe size
262 # $(3) is the list of the build configs
263 _function_generate_stripe_groupings = $(call _function_generate_stripe_groupings_recursive,$(1),$(2),,$(3))
266 # Setup pass for build system tools
269 generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG))
270 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
271 $(warning Generate makefile fragment: $(generated_top_level_build_setup))
273 $(eval $(generated_top_level_build_setup))
277 # invalidate current kernel in $(SYMROOT). Timestamp must be +1 from a previous kernel build
278 setup: build_setup_bootstrap
279 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new
280 $(_v)while [ \! $(OBJROOT)/.mach_kernel.timestamp.new -nt $(OBJROOT)/.mach_kernel.timestamp ]; do \
282 $(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new; \
284 $(_v)$(MV) $(OBJROOT)/.mach_kernel.timestamp.new $(OBJROOT)/.mach_kernel.timestamp
285 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp.new
286 $(_v)while [ \! $(OBJROOT)/.symbolset.timestamp.new -nt $(OBJROOT)/.symbolset.timestamp ]; do \
288 $(TOUCH) $(OBJROOT)/.symbolset.timestamp.new; \
290 $(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
293 # Install kernel header files
295 .PHONY: exporthdrs exporthdrs_mi exporthdrs_md
297 exporthdrs: exporthdrs_mi exporthdrs_md
300 # Install machine independent kernel header files
303 generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
304 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
305 $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi))
307 $(eval $(generated_top_level_build_exporthdrs_mi))
309 exporthdrs_mi: build_exporthdrs_mi_bootstrap
312 # Install machine dependent kernel header files
315 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))
316 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
317 $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md))
319 $(eval $(generated_top_level_build_exporthdrs_md))
321 exporthdrs_md: build_exporthdrs_md_bootstrap
324 # Install kernel header files
327 .PHONY: installhdrs installhdrs_mi installhdrs_md
329 ifeq ($(RC_ProjectName),xnu_debug)
334 installhdrs: installhdrs_mi installhdrs_md
337 .PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop
339 installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs
341 installhdrs_development_embedded:
344 # Install machine independent header files
347 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))
348 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
349 $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi))
351 $(eval $(generated_top_level_build_installhdrs_mi))
353 installhdrs_mi: build_installhdrs_mi_bootstrap
356 # Install machine dependent kernel header files
359 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))
360 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
361 $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md))
363 $(eval $(generated_top_level_build_installhdrs_md))
365 installhdrs_md: build_installhdrs_md_bootstrap
368 # Install text files (man pages, dtrace scripts, etc.)
371 generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG))
372 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
373 $(warning Generate makefile fragment: $(generated_top_level_textfiles_install))
375 $(eval $(generated_top_level_textfiles_install))
377 .PHONY: install_textfiles
379 install_textfiles: textfiles_install_bootstrap
382 # Build all architectures for all Configuration/Architecture options
385 generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
386 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
387 $(warning Generate makefile fragment: $(generated_top_level_build_all))
389 $(eval $(generated_top_level_build_all))
393 build: build_all_bootstrap
396 # Post-process build results
399 generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
400 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
401 $(warning Generate makefile fragment: $(generated_top_level_config_all))
403 $(eval $(generated_top_level_config_all))
407 all config: config_all_bootstrap
409 .PHONY: all_embedded all_release_embedded all_development_embedded all_desktop
411 all_embedded all_release_embedded all_development_embedded all_desktop: all
414 # Install kernel files
417 generated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
418 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
419 $(warning Generate makefile fragment: $(generated_top_level_build_install_primary))
421 $(eval $(generated_top_level_build_install_primary))
423 .PHONY: install_primary
425 install_primary: build_install_primary_bootstrap
427 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))
428 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
429 $(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary))
431 $(eval $(generated_top_level_build_install_non_primary))
433 .PHONY: install_non_primary
435 install_non_primary: build_install_non_primary_bootstrap
437 generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
438 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
439 $(warning Generate makefile fragment: $(generated_top_level_config_install))
441 $(eval $(generated_top_level_config_install))
443 .PHONY: install_config final_touch_config_timestamps
445 install_config: config_install_bootstrap final_touch_config_timestamps
447 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
448 final_touch_config_timestamps: config_install_bootstrap
449 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp
452 # Aggregate install targets, which install everything appropriate for the current build alias/make target
457 ifeq ($(RC_ProjectName),xnu_debug)
458 install: install_kernels
459 else ifeq ($(RC_ProjectName),xnu_headers_Sim)
463 install: installhdrs install_textfiles install_config install_kernels
466 .PHONY: install_embedded install_release_embedded install_development_embedded install_desktop
468 # By default, all kernel files, headers, text files, and pseudo-kexts are installed
469 install_embedded install_release_embedded install_desktop: install
471 # These special configs only install the kernel files
472 install_development_embedded: install_kernels
474 .PHONY: install_kernels final_touch_kernel_timestamps
476 install_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
478 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
479 final_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
480 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
483 # Install source tree
488 @echo INSTALLSRC $(SRCROOT)
489 $(_v)$(MKDIR) $(SRCROOT)
490 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
491 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
495 # Clean up source tree
501 @rm -f cscope.* 2> /dev/null
502 @rm -f $(OBJROOT)/cscope.genhdrs/* 2> /dev/null || true
503 @rm -f TAGS 2> /dev/null
507 # Build source file list for cscope database and tags
512 @echo "Building file list for cscope and tags"
513 @find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
514 @find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
515 @find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
516 @find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
517 @find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
518 @find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
519 @cat $(OBJROOT)/cscope.genhdrs/* >> _cscope.files 2> /dev/null || true
520 @echo -k -q -c > cscope.files 2> /dev/null
521 @sort -u < _cscope.files >> cscope.files 2> /dev/null
522 @rm -f _cscope.files _cscope.files2 2> /dev/null
525 # Build cscope database
528 @echo "Building cscope database"
529 @cscope -bvU 2> /dev/null
535 @echo "Building ctags"
536 @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
537 echo "Phantom files detected!" 2>&1 > /dev/null
538 @-[ -f TAGS ] || ${MAKE} -f $(firstword $(MAKEFILE_LIST)) TAGS
541 @echo "Building etags"
542 @-cat cscope.files | etags -l auto -S - 2> /dev/null
543 @rm -f cscope.files 2> /dev/null
552 generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG))
553 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
554 $(warning Generate makefile fragment: $(generated_top_level_print_exports))
556 $(eval $(generated_top_level_print_exports))
558 print_exports_first_build_config: print_exports_bootstrap