]> git.saurik.com Git - apple/xnu.git/blame - makedefs/MakeInc.top
xnu-3789.41.3.tar.gz
[apple/xnu.git] / makedefs / MakeInc.top
CommitLineData
39236c6e
A
1# -*- mode: makefile;-*-
2#
39037602 3# Copyright (C) 2010-2016 Apple Inc. All rights reserved.
39236c6e
A
4#
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
39037602 8# well as globals that can be overridden on
39236c6e
A
9# the command-line by the user.
10#
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
39037602 23# races, these aggregating stages for
39236c6e 24# "primary" build configs are done in serial.
39037602 25#
39236c6e
A
26
27export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
28
29include $(MakeInc_cmd)
30
31
32#
33# Architecture Configuration options
34#
35
36# Default to current kernel architecture
3e170ce0
A
37
38ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
39236c6e 39 override DEFAULT_ARCH_CONFIG := ARM
3e170ce0 40else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
39236c6e
A
41 override DEFAULT_ARCH_CONFIG := X86_64
42else
43 override DEFAULT_ARCH_CONFIG := X86_64
44endif
45
39236c6e
A
46# Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS
47ifndef ARCH_CONFIGS
48ifdef RC_ARCHS
39037602 49ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
39236c6e
A
50else
51ARCH_CONFIGS := DEFAULT
52endif
53endif
54
55#
39037602 56# Kernel Configuration options
39236c6e
A
57#
58
59ifeq ($(RC_ProjectName),xnu_debug)
60override DEFAULT_KERNEL_CONFIG := DEBUG
3e170ce0 61else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
fe8ab488
A
62override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
63else ifeq ($(PLATFORM),MacOSX)
39236c6e
A
64override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
65else
66override DEFAULT_KERNEL_CONFIG := RELEASE
67endif
68
69# If KERNEL_CONFIGS is specified it should override default
70ifndef KERNEL_CONFIGS
71KERNEL_CONFIGS := DEFAULT
72endif
73
74#
39037602 75# Machine Configuration options
39236c6e
A
76#
77
78override DEFAULT_I386_MACHINE_CONFIG := NONE
79override DEFAULT_X86_64_MACHINE_CONFIG := NONE
fe8ab488 80override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
39236c6e
A
81
82
83# This is typically never specified (TARGET_CONFIGS is used)
84ifndef MACHINE_CONFIGS
39037602 85MACHINE_CONFIGS := DEFAULT
39236c6e
A
86endif
87
88#
39037602 89# Target configuration options. NOTE - target configurations will
39236c6e
A
90# override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
91#
39037602 92# Target configs come in groups of three parameters. The first is the
39236c6e
A
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.
97#
98# Example:
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).
101#
39037602 102# "default" parameter is a special case. It means use the default value for
39236c6e
A
103# that parameter. Here are the default values for each configuration:
104#
105# default kernel configuration = DEFAULT_KERNEL_CONFIG
106# default architecture configuration = system architecture where you are running make.
107
108
fe8ab488
A
109ifeq ($(PLATFORM),MacOSX)
110
111# Defaults for "make all_desktop"
112ifeq ($(KERNEL_CONFIGS),DEFAULT)
113KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
114else
115KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
116endif
117
118endif
119
39236c6e
A
120ifndef TARGET_CONFIGS
121ifneq ($(PRODUCT_CONFIGS),)
122# generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS
39037602
A
123TARGET_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))))
124TARGET_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))))
fe8ab488
A
125else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),)
126# generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map
39037602
A
127TARGET_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))))
128TARGET_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))))
fe8ab488
A
129else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),)
130# generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map
39037602
A
131TARGET_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))))
132TARGET_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))))
39236c6e
A
133else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
134# generate TARGET_CONFIGS for all kernel configs and products in the device map
39037602
A
135TARGET_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))))
136TARGET_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))))
fe8ab488
A
137else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
138# generate TARGET_CONFIGS for all kernel configs for B&I
139TARGET_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))))
39037602 140TARGET_CONFIGS_ALIASES :=
39236c6e
A
141else
142# generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
143TARGET_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))))
39037602 144TARGET_CONFIGS_ALIASES :=
39236c6e
A
145endif
146endif
147
148ifeq ($(TARGET_CONFIGS),)
149$(error No TARGET_CONFIGS specified)
150endif
151
152TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
39037602 153TARGET_CONFIGS_ALIASES_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS_ALIASES)" | $(TR) a-z A-Z))
39236c6e
A
154
155#
156# Build Configurations
157#
158# TARGET_CONFIGS is unwieldy for use in Makefiles. Convert them to
159# "build configurations" which are tuples joined by "^". For
160# example, "RELEASE I386 DEFAULT DEVELOPMENT ARM DEFAULT" becomes
161# "RELEASE^I386^NONE DEVELOPMENT^ARM^S5L8920X", which can be looped
162# over trivially. PRIMARY_BUILD_CONFIGS is the first config
163# for each architecture, used primarily for machine-dependent recursion.
164
165BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
166
167PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config)))))
168PRIMARY_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), )))))
169NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS)))
170FIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS))
171
39037602
A
172ifneq ($(TARGET_CONFIGS_ALIASES_UC),)
173ALIAS_CONFIGS = $(call function_create_alias_configs, $(TARGET_CONFIGS_ALIASES_UC))
174else
175ALIAS_CONFIGS =
176endif
177
39236c6e
A
178# $(warning PRIMARY_ARCHS is $(PRIMARY_ARCHS))
179# $(warning TARGET_CONFIGS is $(TARGET_CONFIGS))
180# $(warning BUILD_CONFIGS is $(BUILD_CONFIGS))
181# $(warning PRIMARY_BUILD_CONFIGS is $(PRIMARY_BUILD_CONFIGS))
182# $(warning NON_PRIMARY_BUILD_CONFIGS is $(NON_PRIMARY_BUILD_CONFIGS))
39037602
A
183# $(warning TARGET_CONFIGS_ALIASES is $(TARGET_CONFIGS_ALIASES))
184# $(warning ALIAS_CONFIGS is $(ALIAS_CONFIGS))
39236c6e
A
185
186MEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
187
fe8ab488
A
188# Assume LTO scaling by default, unless it is being explicitly passed on the command-line
189LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1)
39236c6e
A
190
191ifeq ($(LARGE_BUILD_FOOTPRINT),1)
39037602 192RAM_PER_KERNEL_BUILD := 4294967296
39236c6e
A
193else
194RAM_PER_KERNEL_BUILD := 268435456
39236c6e
A
195endif
196
fe8ab488
A
197KERNEL_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 )
198# $(warning Building $(KERNEL_BUILDS_IN_PARALLEL) kernels in parallel)
39236c6e
A
199
200#
201# TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
202#
203# $(1) is the name of the makefile target to invoke for the each build config
204# after setting up the parallel hierarchy in the TARGET directory
205# $(2) is an optional suffix on the TARGET directory, which might even be
206# "/.."
207# $(3) are any dependencies for the bootstrap target
208# $(4) are any dependencies that are expanded per-build config to another bootstrap target
209# $(5) is how many build configurations to build in parallel
210# $(6) is which build configs to build in parallel
211#
212# Since building many configurations in parallel may overwhelm the system,
fe8ab488
A
213# we try to throttle behavior into more managable S "stripes" of N/S
214# configurations by generating sequential dependencies between configs
215# in each stripe. That ensures that only S kernel builds are occurring
216# at once at any point in time
39236c6e
A
217
218define TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
219
220# Create a list of synthesized targets for each build config
221$(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
222
223.PHONY: $$($(1)_bootstrap_target_list)
224
fe8ab488
A
225$(1)_generated_stripe_dependencies = $$(call _function_generate_stripe_groupings,$(1),$(5),$(call reverse,$(6)))
226ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
227$$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies))
228endif
229$$(eval $$($(1)_generated_stripe_dependencies))
230
fe8ab488 231$$($(1)_bootstrap_target_list): $(1)_bootstrap_% : $(1)_stripe_dep_for_% $$(addsuffix _bootstrap_%,$(4)) $(3)
39236c6e 232 $$(_v)$$(MKDIR) $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)
39037602 233 $$(_v)$${MAKE} \
39236c6e
A
234 -C $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2) \
235 -f $${SRCROOT}/Makefile \
236 CURRENT_KERNEL_CONFIG=$$(call function_extract_kernel_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
237 CURRENT_ARCH_CONFIG=$$(call function_extract_arch_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
238 CURRENT_MACHINE_CONFIG=$$(call function_extract_machine_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
239 CURRENT_BUILD_CONFIG=$$(patsubst $(1)_bootstrap_%,%,$$@) \
240 PRIMARY_BUILD_CONFIGS="$(PRIMARY_BUILD_CONFIGS)" \
241 SOURCE=$${SRCROOT}/ \
242 RELATIVE_SOURCE_PATH=. \
243 TARGET=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)/ \
244 OBJPATH=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
245 $(1)
246
247.PHONY: $(1)_bootstrap
248
249$(1)_bootstrap: $$($(1)_bootstrap_target_list)
250endef
251
252#
fe8ab488 253# TOP_LEVEL_STRIPE_DEPENDENCY_template
39236c6e
A
254#
255# $(1) is the Makefile target we are building for
fe8ab488
A
256# $(2) is the build config that must build first
257# $(3) is the build config that must build after $(2)
39236c6e 258
fe8ab488 259define TOP_LEVEL_STRIPE_DEPENDENCY_template
39236c6e 260
fe8ab488 261.PHONY: $(1)_stripe_dep_for_$(3)
39236c6e 262
fe8ab488 263 $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
39236c6e
A
264
265endef
266
267# $(1) is the Makefile target we are building for
fe8ab488
A
268# $(2) is the stripe size
269# $(3) is the list of the build configs in the current group
270# $(4) is the list of remaining build configs
271_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))))
272
fe8ab488
A
273# $(1) is the Makefile target we are building for
274# $(2) is the stripe size
275# $(3) is the list of the build configs
276_function_generate_stripe_groupings = $(call _function_generate_stripe_groupings_recursive,$(1),$(2),,$(3))
39236c6e
A
277
278#
279# Setup pass for build system tools
280#
281
fe8ab488
A
282generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG))
283ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
284$(warning Generate makefile fragment: $(generated_top_level_build_setup))
285endif
286$(eval $(generated_top_level_build_setup))
287
288.PHONY: setup
289
fe8ab488 290# invalidate current kernel in $(SYMROOT). Timestamp must be +1 from a previous kernel build
39236c6e 291setup: build_setup_bootstrap
fe8ab488
A
292 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new
293 $(_v)while [ \! $(OBJROOT)/.mach_kernel.timestamp.new -nt $(OBJROOT)/.mach_kernel.timestamp ]; do \
294 $(SLEEP) 1; \
295 $(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new; \
296 done
297 $(_v)$(MV) $(OBJROOT)/.mach_kernel.timestamp.new $(OBJROOT)/.mach_kernel.timestamp
298 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp.new
299 $(_v)while [ \! $(OBJROOT)/.symbolset.timestamp.new -nt $(OBJROOT)/.symbolset.timestamp ]; do \
300 $(SLEEP) 1; \
301 $(TOUCH) $(OBJROOT)/.symbolset.timestamp.new; \
302 done
303 $(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
39236c6e
A
304
305#
306# Install kernel header files
307#
308.PHONY: exporthdrs exporthdrs_mi exporthdrs_md
309
39037602 310exporthdrs: exporthdrs_mi exporthdrs_md
39236c6e
A
311
312#
313# Install machine independent kernel header files
314#
315
316generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
fe8ab488 317ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
318$(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi))
319endif
320$(eval $(generated_top_level_build_exporthdrs_mi))
321
322exporthdrs_mi: build_exporthdrs_mi_bootstrap
323
324#
39037602 325# Install machine dependent kernel header files
39236c6e
A
326#
327
fe8ab488
A
328generated_top_level_build_exporthdrs_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_md,,setup,,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
329ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
330$(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md))
331endif
332$(eval $(generated_top_level_build_exporthdrs_md))
333
334exporthdrs_md: build_exporthdrs_md_bootstrap
335
336#
337# Install kernel header files
338#
339
340.PHONY: installhdrs installhdrs_mi installhdrs_md
341
342ifeq ($(RC_ProjectName),xnu_debug)
343installhdrs:
344 @:
345else
346
347installhdrs: installhdrs_mi installhdrs_md
348endif
349
fe8ab488
A
350.PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop
351
352installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs
39236c6e 353
fe8ab488 354installhdrs_development_embedded:
39236c6e
A
355
356#
357# Install machine independent header files
358#
359
fe8ab488
A
360generated_top_level_build_installhdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_installhdrs_mi,,setup,build_exporthdrs_mi,1,$(FIRST_BUILD_CONFIG))
361ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
362$(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi))
363endif
364$(eval $(generated_top_level_build_installhdrs_mi))
365
fe8ab488 366installhdrs_mi: build_installhdrs_mi_bootstrap
39236c6e
A
367
368#
39037602 369# Install machine dependent kernel header files
39236c6e
A
370#
371
fe8ab488
A
372generated_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))
373ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
374$(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md))
375endif
376$(eval $(generated_top_level_build_installhdrs_md))
377
fe8ab488
A
378installhdrs_md: build_installhdrs_md_bootstrap
379
380#
381# Install text files (man pages, dtrace scripts, etc.)
382#
383
384generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG))
385ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
386$(warning Generate makefile fragment: $(generated_top_level_textfiles_install))
387endif
388$(eval $(generated_top_level_textfiles_install))
389
390.PHONY: install_textfiles
391
392install_textfiles: textfiles_install_bootstrap
39236c6e
A
393
394#
395# Build all architectures for all Configuration/Architecture options
396#
397
fe8ab488
A
398generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
399ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
400$(warning Generate makefile fragment: $(generated_top_level_build_all))
401endif
402$(eval $(generated_top_level_build_all))
403
404.PHONY: build
405
406build: build_all_bootstrap
407
408#
409# Post-process build results
410#
411
fe8ab488
A
412generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
413ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
414$(warning Generate makefile fragment: $(generated_top_level_config_all))
415endif
416$(eval $(generated_top_level_config_all))
417
fe8ab488 418.PHONY: all config
39236c6e 419
fe8ab488 420all config: config_all_bootstrap
39236c6e 421
fe8ab488 422.PHONY: all_embedded all_release_embedded all_development_embedded all_desktop
39236c6e 423
fe8ab488 424all_embedded all_release_embedded all_development_embedded all_desktop: all
39236c6e
A
425
426#
fe8ab488 427# Install kernel files
39236c6e
A
428#
429
430generated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
fe8ab488 431ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
432$(warning Generate makefile fragment: $(generated_top_level_build_install_primary))
433endif
434$(eval $(generated_top_level_build_install_primary))
435
fe8ab488
A
436.PHONY: install_primary
437
438install_primary: build_install_primary_bootstrap
439
440generated_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))
441ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
442$(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary))
443endif
444$(eval $(generated_top_level_build_install_non_primary))
445
fe8ab488
A
446.PHONY: install_non_primary
447
448install_non_primary: build_install_non_primary_bootstrap
449
450generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
451ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
452$(warning Generate makefile fragment: $(generated_top_level_config_install))
453endif
454$(eval $(generated_top_level_config_install))
455
456.PHONY: install_config final_touch_config_timestamps
457
458install_config: config_install_bootstrap final_touch_config_timestamps
459
460# Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
461final_touch_config_timestamps: config_install_bootstrap
462 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp
463
464#
465# Aggregate install targets, which install everything appropriate for the current build alias/make target
466#
39236c6e
A
467
468.PHONY: install
469
470ifeq ($(RC_ProjectName),xnu_debug)
fe8ab488 471install: install_kernels
39236c6e
A
472else ifeq ($(RC_ProjectName),xnu_headers_Sim)
473install: installhdrs
474else
475
39037602 476install: installhdrs install_textfiles install_config install_kernels install_aliases
39236c6e
A
477endif
478
fe8ab488 479.PHONY: install_embedded install_release_embedded install_development_embedded install_desktop
39236c6e 480
fe8ab488
A
481# By default, all kernel files, headers, text files, and pseudo-kexts are installed
482install_embedded install_release_embedded install_desktop: install
39236c6e 483
fe8ab488 484# These special configs only install the kernel files
39037602 485install_development_embedded: install_kernels install_aliases
39236c6e 486
39037602 487.PHONY: install_kernels final_touch_kernel_timestamps install_aliases
39236c6e 488
fe8ab488 489install_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
39236c6e 490
fe8ab488
A
491# Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
492final_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
493 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
39236c6e 494
39037602
A
495# Copy kernels that are aliases of another configuration
496generated_top_level_install_alias = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,install_alias,,install_kernels,,$(KERNEL_BUILDS_IN_PARALLEL),$(ALIAS_CONFIGS))
497ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
498$(warning Generate makefile fragment: $(generated_top_level_install_alias))
499endif
500$(eval $(generated_top_level_install_alias))
501
502install_aliases: install_alias_bootstrap
503
39236c6e
A
504#
505# Install source tree
506#
507.PHONY: installsrc
508
509installsrc:
510 @echo INSTALLSRC $(SRCROOT)
511 $(_v)$(MKDIR) $(SRCROOT)
fe8ab488
A
512 $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
513 $(_v)$(CHMOD) -R go+rX $(SRCROOT)
39236c6e
A
514
515
516#
517# Clean up source tree
518#
519.PHONY: clean
520
521clean:
522 @:
fe8ab488 523 @rm -f cscope.* 2> /dev/null
39037602 524 @rm -f $(OBJROOT)/cscope.genhdrs/* 2> /dev/null || true
fe8ab488
A
525 @rm -f TAGS 2> /dev/null
526
39236c6e
A
527#
528# Build source file list for cscope database and tags
529#
fe8ab488
A
530.PHONY: cscope.files
531
39236c6e
A
532cscope.files:
533 @echo "Building file list for cscope and tags"
534 @find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
535 @find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
536 @find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
537 @find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
538 @find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
539 @find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
fe8ab488 540 @cat $(OBJROOT)/cscope.genhdrs/* >> _cscope.files 2> /dev/null || true
39236c6e
A
541 @echo -k -q -c > cscope.files 2> /dev/null
542 @sort -u < _cscope.files >> cscope.files 2> /dev/null
543 @rm -f _cscope.files _cscope.files2 2> /dev/null
544
545#
546# Build cscope database
547#
548cscope: cscope.files
549 @echo "Building cscope database"
550 @cscope -bvU 2> /dev/null
551
552#
553# Build tags
554#
555tags: cscope.files
556 @echo "Building ctags"
557 @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
558 echo "Phantom files detected!" 2>&1 > /dev/null
559 @-[ -f TAGS ] || ${MAKE} -f $(firstword $(MAKEFILE_LIST)) TAGS
560
561TAGS: cscope.files
562 @echo "Building etags"
563 @-cat cscope.files | etags -l auto -S - 2> /dev/null
fe8ab488 564 @rm -f cscope.files 2> /dev/null
39236c6e 565
3e170ce0
A
566#
567# Re-indent source code using xnu clang-format style
568#
569.PHONY: reindent
570
571reindent:
572 $(_v)$(SRCROOT)/tools/reindent.sh
573
574.PHONY: help
575
39236c6e 576help:
39037602 577 @cat README.md
39236c6e 578
3e170ce0
A
579.PHONY: print_exports
580
39236c6e
A
581print_exports:
582 $(_v)printenv | sort
583
39236c6e 584generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG))
fe8ab488 585ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
586$(warning Generate makefile fragment: $(generated_top_level_print_exports))
587endif
588$(eval $(generated_top_level_print_exports))
589
3e170ce0
A
590.PHONY: print_exports_first_build_config
591
39236c6e 592print_exports_first_build_config: print_exports_bootstrap