]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.top
xnu-4570.41.2.tar.gz
[apple/xnu.git] / makedefs / MakeInc.top
1 # -*- mode: makefile;-*-
2 #
3 # Copyright (C) 2010-2016 Apple Inc. All rights reserved.
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
8 # well as globals that can be overridden on
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
23 # races, these aggregating stages for
24 # "primary" build configs are done in serial.
25 #
26
27 export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
28
29 include $(MakeInc_cmd)
30
31
32 #
33 # Architecture Configuration options
34 #
35
36 # Default to current kernel architecture
37
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
42 else
43 override DEFAULT_ARCH_CONFIG := X86_64
44 endif
45
46 # Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS
47 ifndef ARCH_CONFIGS
48 ifdef RC_ARCHS
49 ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
50 else
51 ARCH_CONFIGS := DEFAULT
52 endif
53 endif
54
55 #
56 # Kernel Configuration options
57 #
58
59 DEFAULT_PRODUCT_CONFIGS :=
60
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
69 else
70 override DEFAULT_KERNEL_CONFIG := RELEASE
71 endif
72
73 # If KERNEL_CONFIGS is specified it should override default
74 ifndef KERNEL_CONFIGS
75 KERNEL_CONFIGS := DEFAULT
76 endif
77
78 # If PRODUCT_CONFIGS is specified it should override default
79 ifndef PRODUCT_CONFIGS
80 PRODUCT_CONFIGS := $(DEFAULT_PRODUCT_CONFIGS)
81 endif
82
83 #
84 # Machine Configuration options
85 #
86
87 override DEFAULT_I386_MACHINE_CONFIG := NONE
88 override DEFAULT_X86_64_MACHINE_CONFIG := NONE
89 override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
90
91
92 # This is typically never specified (TARGET_CONFIGS is used)
93 ifndef MACHINE_CONFIGS
94 MACHINE_CONFIGS := DEFAULT
95 endif
96
97 #
98 # Target configuration options. NOTE - target configurations will
99 # override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
100 #
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.
106 #
107 # Example:
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).
110 #
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:
113 #
114 # default kernel configuration = DEFAULT_KERNEL_CONFIG
115 # default architecture configuration = system architecture where you are running make.
116
117
118 ifeq ($(PLATFORM),MacOSX)
119
120 # Defaults for "make all_desktop"
121 ifeq ($(KERNEL_CONFIGS),DEFAULT)
122 KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
123 else
124 KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
125 endif
126
127 endif
128
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 :=
150 else
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 :=
154 endif
155 endif
156
157 ifeq ($(TARGET_CONFIGS),)
158 $(error No TARGET_CONFIGS specified)
159 endif
160
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))
163
164 #
165 # Build Configurations
166 #
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.
173
174 BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
175
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))
180
181 ifneq ($(TARGET_CONFIGS_ALIASES_UC),)
182 ALIAS_CONFIGS = $(call function_create_alias_configs, $(TARGET_CONFIGS_ALIASES_UC))
183 else
184 ALIAS_CONFIGS =
185 endif
186
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))
194
195 MEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
196
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)
199
200 ifeq ($(LARGE_BUILD_FOOTPRINT),1)
201 RAM_PER_KERNEL_BUILD := 4294967296
202 else
203 RAM_PER_KERNEL_BUILD := 268435456
204 endif
205
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)
208
209 #
210 # TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
211 #
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
215 # "/.."
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
220 #
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
226
227 define TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
228
229 # Create a list of synthesized targets for each build config
230 $(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
231
232 .PHONY: $$($(1)_bootstrap_target_list)
233
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))
237 endif
238 $$(eval $$($(1)_generated_stripe_dependencies))
239
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)
242 $$(_v)$${MAKE} \
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_%,%,$$@)) \
254 $(1)
255
256 .PHONY: $(1)_bootstrap
257
258 $(1)_bootstrap: $$($(1)_bootstrap_target_list)
259 endef
260
261 #
262 # TOP_LEVEL_STRIPE_DEPENDENCY_template
263 #
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)
267
268 define TOP_LEVEL_STRIPE_DEPENDENCY_template
269
270 .PHONY: $(1)_stripe_dep_for_$(3)
271
272 $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
273
274 endef
275
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))))
281
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))
286
287 #
288 # Setup pass for build system tools
289 #
290
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))
294 endif
295 $(eval $(generated_top_level_build_setup))
296
297 .PHONY: setup
298
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 \
303 $(SLEEP) 1; \
304 $(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new; \
305 done
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 \
309 $(SLEEP) 1; \
310 $(TOUCH) $(OBJROOT)/.symbolset.timestamp.new; \
311 done
312 $(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
313
314 #
315 # Install kernel header files
316 #
317 .PHONY: exporthdrs exporthdrs_mi exporthdrs_md
318
319 exporthdrs: exporthdrs_mi exporthdrs_md
320
321 #
322 # Install machine independent kernel header files
323 #
324
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))
328 endif
329 $(eval $(generated_top_level_build_exporthdrs_mi))
330
331 exporthdrs_mi: build_exporthdrs_mi_bootstrap
332
333 #
334 # Install machine dependent kernel header files
335 #
336
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))
340 endif
341 $(eval $(generated_top_level_build_exporthdrs_md))
342
343 exporthdrs_md: build_exporthdrs_md_bootstrap
344
345 #
346 # Install kernel header files
347 #
348
349 .PHONY: installhdrs installhdrs_mi installhdrs_md
350
351 ifeq ($(RC_ProjectName),xnu_debug)
352 installhdrs:
353 @:
354 else ifeq ($(RC_ProjectName),xnu_kasan)
355 installhdrs:
356 @:
357 else
358
359 installhdrs: installhdrs_mi installhdrs_md
360 endif
361
362 .PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop
363
364 installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs
365
366 installhdrs_development_embedded:
367
368 #
369 # Install machine independent header files
370 #
371
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))
375 endif
376 $(eval $(generated_top_level_build_installhdrs_mi))
377
378 installhdrs_mi: build_installhdrs_mi_bootstrap
379
380 #
381 # Install machine dependent kernel header files
382 #
383
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))
387 endif
388 $(eval $(generated_top_level_build_installhdrs_md))
389
390 installhdrs_md: build_installhdrs_md_bootstrap
391
392 #
393 # Install text files (man pages, dtrace scripts, etc.)
394 #
395
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))
399 endif
400 $(eval $(generated_top_level_textfiles_install))
401
402 .PHONY: install_textfiles
403
404 install_textfiles: textfiles_install_bootstrap
405
406 #
407 # Build all architectures for all Configuration/Architecture options
408 #
409
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))
413 endif
414 $(eval $(generated_top_level_build_all))
415
416 .PHONY: build
417
418 build: build_all_bootstrap
419
420 #
421 # Post-process build results
422 #
423
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))
427 endif
428 $(eval $(generated_top_level_config_all))
429
430 .PHONY: all config
431
432 all config: config_all_bootstrap
433
434 .PHONY: all_embedded all_release_embedded all_development_embedded all_desktop
435
436 all_embedded all_release_embedded all_development_embedded all_desktop: all
437
438 #
439 # Install kernel files
440 #
441
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))
445 endif
446 $(eval $(generated_top_level_build_install_primary))
447
448 .PHONY: install_primary
449
450 install_primary: build_install_primary_bootstrap
451
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))
455 endif
456 $(eval $(generated_top_level_build_install_non_primary))
457
458 .PHONY: install_non_primary
459
460 install_non_primary: build_install_non_primary_bootstrap
461
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))
465 endif
466 $(eval $(generated_top_level_config_install))
467
468 .PHONY: install_config final_touch_config_timestamps
469
470 install_config: config_install_bootstrap final_touch_config_timestamps
471
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
475
476 #
477 # Aggregate install targets, which install everything appropriate for the current build alias/make target
478 #
479
480 .PHONY: install
481
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)
487 install: installhdrs
488 else
489
490 install: installhdrs install_textfiles install_config install_kernels install_aliases
491 endif
492
493 .PHONY: install_embedded install_release_embedded install_development_embedded install_desktop
494
495 # By default, all kernel files, headers, text files, and pseudo-kexts are installed
496 install_embedded install_release_embedded install_desktop: install
497
498 # These special configs only install the kernel files
499 install_development_embedded: install_kernels install_aliases
500
501 .PHONY: install_kernels final_touch_kernel_timestamps install_aliases
502
503 install_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
504
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
508
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))
513 endif
514 $(eval $(generated_top_level_install_alias))
515
516 install_aliases: install_alias_bootstrap
517
518 #
519 # Install source tree
520 #
521 .PHONY: installsrc
522
523 installsrc:
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)
528
529
530 #
531 # Clean up source tree
532 #
533 .PHONY: clean
534
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
544
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
552
553 clean:
554 @:
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 ; \
561 fi ; \
562 done
563
564 $(_v)for mcdir in $(CLEAN_ACTION_DIRS); do \
565 make -C $${mcdir} clean; \
566 done
567
568
569 #
570 # Build source file list for cscope database and tags
571 #
572 .PHONY: cscope.files
573
574 cscope.files:
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
586
587 #
588 # Build cscope database
589 #
590 cscope: cscope.files
591 @echo "Building cscope database"
592 @cscope -bvU 2> /dev/null
593
594 #
595 # Build tags
596 #
597 tags: cscope.files
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
602
603 TAGS: cscope.files
604 @echo "Building etags"
605 @-cat cscope.files | etags -l auto -S - 2> /dev/null
606 @rm -f cscope.files 2> /dev/null
607
608 #
609 # Re-indent source code using xnu clang-format style
610 #
611 .PHONY: reindent
612
613 reindent:
614 $(_v)$(SRCROOT)/tools/reindent.sh
615
616 .PHONY: help
617
618 help:
619 @cat README.md
620
621 .PHONY: print_exports
622
623 print_exports:
624 $(_v)printenv | sort
625
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))
629 endif
630 $(eval $(generated_top_level_print_exports))
631
632 .PHONY: print_exports_first_build_config
633
634 print_exports_first_build_config: print_exports_bootstrap