]> git.saurik.com Git - apple/xnu.git/blame - makedefs/MakeInc.top
xnu-3248.50.21.tar.gz
[apple/xnu.git] / makedefs / MakeInc.top
CommitLineData
39236c6e
A
1# -*- mode: makefile;-*-
2#
3e170ce0 3# Copyright (C) 2010-2014 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
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
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
46
47# Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS
48ifndef ARCH_CONFIGS
49ifdef RC_ARCHS
3e170ce0 50ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
39236c6e
A
51else
52ARCH_CONFIGS := DEFAULT
53endif
54endif
55
56#
57# Kernel Configuration options
58#
59
60ifeq ($(RC_ProjectName),xnu_debug)
61override DEFAULT_KERNEL_CONFIG := DEBUG
3e170ce0 62else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
fe8ab488
A
63override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
64else ifeq ($(PLATFORM),MacOSX)
39236c6e
A
65override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
66else
67override DEFAULT_KERNEL_CONFIG := RELEASE
68endif
69
70# If KERNEL_CONFIGS is specified it should override default
71ifndef KERNEL_CONFIGS
72KERNEL_CONFIGS := DEFAULT
73endif
74
75#
76# Machine Configuration options
77#
78
79override DEFAULT_I386_MACHINE_CONFIG := NONE
80override DEFAULT_X86_64_MACHINE_CONFIG := NONE
fe8ab488 81override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
39236c6e
A
82
83
84# This is typically never specified (TARGET_CONFIGS is used)
85ifndef MACHINE_CONFIGS
86MACHINE_CONFIGS := DEFAULT
87endif
88
89#
90# Target configuration options. NOTE - target configurations will
91# override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
92#
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.
98#
99# Example:
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).
102#
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:
105#
106# default kernel configuration = DEFAULT_KERNEL_CONFIG
107# default architecture configuration = system architecture where you are running make.
108
109
fe8ab488
A
110ifeq ($(PLATFORM),MacOSX)
111
112# Defaults for "make all_desktop"
113ifeq ($(KERNEL_CONFIGS),DEFAULT)
114KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
115else
116KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
117endif
118
119endif
120
39236c6e
A
121ifndef TARGET_CONFIGS
122ifneq ($(PRODUCT_CONFIGS),)
123# generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS
124TARGET_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)))))
fe8ab488
A
125else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),)
126# generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map
127TARGET_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))))))
128else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),)
129# generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map
130TARGET_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))))))
39236c6e
A
131else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
132# generate TARGET_CONFIGS for all kernel configs and products in the device map
133TARGET_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))))))
fe8ab488
A
134else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
135# generate TARGET_CONFIGS for all kernel configs for B&I
136TARGET_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))))
39236c6e
A
137else
138# generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
139TARGET_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))))
140endif
141endif
142
143ifeq ($(TARGET_CONFIGS),)
144$(error No TARGET_CONFIGS specified)
145endif
146
147TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
148
149#
150# Build Configurations
151#
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.
158
159BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
160
161PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config)))))
162PRIMARY_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), )))))
163NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS)))
164FIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS))
165
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))
171
172MEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
173
fe8ab488
A
174# Assume LTO scaling by default, unless it is being explicitly passed on the command-line
175LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1)
39236c6e
A
176
177ifeq ($(LARGE_BUILD_FOOTPRINT),1)
178RAM_PER_KERNEL_BUILD := 8589934592
39236c6e
A
179else
180RAM_PER_KERNEL_BUILD := 268435456
39236c6e
A
181endif
182
fe8ab488
A
183KERNEL_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)
39236c6e
A
185
186#
187# TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
188#
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
192# "/.."
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
197#
198# Since building many configurations in parallel may overwhelm the system,
fe8ab488
A
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
39236c6e
A
203
204define TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
205
206# Create a list of synthesized targets for each build config
207$(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
208
209.PHONY: $$($(1)_bootstrap_target_list)
210
fe8ab488
A
211$(1)_generated_stripe_dependencies = $$(call _function_generate_stripe_groupings,$(1),$(5),$(call reverse,$(6)))
212ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
213$$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies))
214endif
215$$(eval $$($(1)_generated_stripe_dependencies))
216
39236c6e 217
fe8ab488 218$$($(1)_bootstrap_target_list): $(1)_bootstrap_% : $(1)_stripe_dep_for_% $$(addsuffix _bootstrap_%,$(4)) $(3)
39236c6e
A
219 $$(_v)$$(MKDIR) $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)
220 $$(_v)$${MAKE} \
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_%,%,$$@)) \
232 $(1)
233
234.PHONY: $(1)_bootstrap
235
236$(1)_bootstrap: $$($(1)_bootstrap_target_list)
237endef
238
239#
fe8ab488 240# TOP_LEVEL_STRIPE_DEPENDENCY_template
39236c6e
A
241#
242# $(1) is the Makefile target we are building for
fe8ab488
A
243# $(2) is the build config that must build first
244# $(3) is the build config that must build after $(2)
39236c6e 245
fe8ab488 246define TOP_LEVEL_STRIPE_DEPENDENCY_template
39236c6e 247
fe8ab488 248.PHONY: $(1)_stripe_dep_for_$(3)
39236c6e 249
fe8ab488 250 $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
39236c6e
A
251
252endef
253
254# $(1) is the Makefile target we are building for
fe8ab488
A
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))))
259
260
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))
39236c6e
A
265
266#
267# Setup pass for build system tools
268#
269
fe8ab488
A
270generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG))
271ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
272$(warning Generate makefile fragment: $(generated_top_level_build_setup))
273endif
274$(eval $(generated_top_level_build_setup))
275
276.PHONY: setup
277
fe8ab488 278# invalidate current kernel in $(SYMROOT). Timestamp must be +1 from a previous kernel build
39236c6e 279setup: build_setup_bootstrap
fe8ab488
A
280 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new
281 $(_v)while [ \! $(OBJROOT)/.mach_kernel.timestamp.new -nt $(OBJROOT)/.mach_kernel.timestamp ]; do \
282 $(SLEEP) 1; \
283 $(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new; \
284 done
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 \
288 $(SLEEP) 1; \
289 $(TOUCH) $(OBJROOT)/.symbolset.timestamp.new; \
290 done
291 $(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
39236c6e
A
292
293#
294# Install kernel header files
295#
296.PHONY: exporthdrs exporthdrs_mi exporthdrs_md
297
298exporthdrs: exporthdrs_mi exporthdrs_md
299
300#
301# Install machine independent kernel header files
302#
303
304generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
fe8ab488 305ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
306$(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi))
307endif
308$(eval $(generated_top_level_build_exporthdrs_mi))
309
310exporthdrs_mi: build_exporthdrs_mi_bootstrap
311
312#
313# Install machine dependent kernel header files
314#
315
fe8ab488
A
316generated_top_level_build_exporthdrs_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_md,,setup,,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
317ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
318$(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md))
319endif
320$(eval $(generated_top_level_build_exporthdrs_md))
321
322exporthdrs_md: build_exporthdrs_md_bootstrap
323
324#
325# Install kernel header files
326#
327
328.PHONY: installhdrs installhdrs_mi installhdrs_md
329
330ifeq ($(RC_ProjectName),xnu_debug)
331installhdrs:
332 @:
333else
334
335installhdrs: installhdrs_mi installhdrs_md
336endif
337
fe8ab488
A
338.PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop
339
340installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs
39236c6e 341
fe8ab488 342installhdrs_development_embedded:
39236c6e
A
343
344#
345# Install machine independent header files
346#
347
fe8ab488
A
348generated_top_level_build_installhdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_installhdrs_mi,,setup,build_exporthdrs_mi,1,$(FIRST_BUILD_CONFIG))
349ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
350$(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi))
351endif
352$(eval $(generated_top_level_build_installhdrs_mi))
353
fe8ab488 354installhdrs_mi: build_installhdrs_mi_bootstrap
39236c6e
A
355
356#
357# Install machine dependent kernel header files
358#
359
fe8ab488
A
360generated_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))
361ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
362$(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md))
363endif
364$(eval $(generated_top_level_build_installhdrs_md))
365
fe8ab488
A
366installhdrs_md: build_installhdrs_md_bootstrap
367
368#
369# Install text files (man pages, dtrace scripts, etc.)
370#
371
372generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG))
373ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
374$(warning Generate makefile fragment: $(generated_top_level_textfiles_install))
375endif
376$(eval $(generated_top_level_textfiles_install))
377
378.PHONY: install_textfiles
379
380install_textfiles: textfiles_install_bootstrap
39236c6e
A
381
382#
383# Build all architectures for all Configuration/Architecture options
384#
385
fe8ab488
A
386generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
387ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
388$(warning Generate makefile fragment: $(generated_top_level_build_all))
389endif
390$(eval $(generated_top_level_build_all))
391
392.PHONY: build
393
394build: build_all_bootstrap
395
396#
397# Post-process build results
398#
399
fe8ab488
A
400generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
401ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
402$(warning Generate makefile fragment: $(generated_top_level_config_all))
403endif
404$(eval $(generated_top_level_config_all))
405
fe8ab488 406.PHONY: all config
39236c6e 407
fe8ab488 408all config: config_all_bootstrap
39236c6e 409
fe8ab488 410.PHONY: all_embedded all_release_embedded all_development_embedded all_desktop
39236c6e 411
fe8ab488 412all_embedded all_release_embedded all_development_embedded all_desktop: all
39236c6e
A
413
414#
fe8ab488 415# Install kernel files
39236c6e
A
416#
417
418generated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
fe8ab488 419ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
420$(warning Generate makefile fragment: $(generated_top_level_build_install_primary))
421endif
422$(eval $(generated_top_level_build_install_primary))
423
fe8ab488
A
424.PHONY: install_primary
425
426install_primary: build_install_primary_bootstrap
427
428generated_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))
429ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
430$(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary))
431endif
432$(eval $(generated_top_level_build_install_non_primary))
433
fe8ab488
A
434.PHONY: install_non_primary
435
436install_non_primary: build_install_non_primary_bootstrap
437
438generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
439ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
440$(warning Generate makefile fragment: $(generated_top_level_config_install))
441endif
442$(eval $(generated_top_level_config_install))
443
444.PHONY: install_config final_touch_config_timestamps
445
446install_config: config_install_bootstrap final_touch_config_timestamps
447
448# Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
449final_touch_config_timestamps: config_install_bootstrap
450 $(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp
451
452#
453# Aggregate install targets, which install everything appropriate for the current build alias/make target
454#
39236c6e
A
455
456.PHONY: install
457
458ifeq ($(RC_ProjectName),xnu_debug)
fe8ab488 459install: install_kernels
39236c6e
A
460else ifeq ($(RC_ProjectName),xnu_headers_Sim)
461install: installhdrs
462else
463
fe8ab488 464install: installhdrs install_textfiles install_config install_kernels
39236c6e
A
465endif
466
fe8ab488 467.PHONY: install_embedded install_release_embedded install_development_embedded install_desktop
39236c6e 468
fe8ab488
A
469# By default, all kernel files, headers, text files, and pseudo-kexts are installed
470install_embedded install_release_embedded install_desktop: install
39236c6e 471
fe8ab488
A
472# These special configs only install the kernel files
473install_development_embedded: install_kernels
39236c6e 474
fe8ab488 475.PHONY: install_kernels final_touch_kernel_timestamps
39236c6e 476
fe8ab488 477install_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
39236c6e 478
fe8ab488
A
479# Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
480final_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
481 $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
39236c6e
A
482
483#
484# Install source tree
485#
486.PHONY: installsrc
487
488installsrc:
489 @echo INSTALLSRC $(SRCROOT)
490 $(_v)$(MKDIR) $(SRCROOT)
fe8ab488
A
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)
39236c6e
A
493
494
495#
496# Clean up source tree
497#
498.PHONY: clean
499
500clean:
501 @:
fe8ab488
A
502 @rm -f cscope.* 2> /dev/null
503 @rm -f $(OBJROOT)/cscope.genhdrs/* 2> /dev/null || true
504 @rm -f TAGS 2> /dev/null
505
39236c6e
A
506
507#
508# Build source file list for cscope database and tags
509#
fe8ab488
A
510.PHONY: cscope.files
511
39236c6e
A
512cscope.files:
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
fe8ab488 520 @cat $(OBJROOT)/cscope.genhdrs/* >> _cscope.files 2> /dev/null || true
39236c6e
A
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
524
525#
526# Build cscope database
527#
528cscope: cscope.files
529 @echo "Building cscope database"
530 @cscope -bvU 2> /dev/null
531
532#
533# Build tags
534#
535tags: cscope.files
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
540
541TAGS: cscope.files
542 @echo "Building etags"
543 @-cat cscope.files | etags -l auto -S - 2> /dev/null
fe8ab488 544 @rm -f cscope.files 2> /dev/null
39236c6e 545
3e170ce0
A
546#
547# Re-indent source code using xnu clang-format style
548#
549.PHONY: reindent
550
551reindent:
552 $(_v)$(SRCROOT)/tools/reindent.sh
553
554.PHONY: help
555
39236c6e
A
556help:
557 @cat README
558
3e170ce0
A
559.PHONY: print_exports
560
39236c6e
A
561print_exports:
562 $(_v)printenv | sort
563
564
565generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG))
fe8ab488 566ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
39236c6e
A
567$(warning Generate makefile fragment: $(generated_top_level_print_exports))
568endif
569$(eval $(generated_top_level_print_exports))
570
3e170ce0
A
571.PHONY: print_exports_first_build_config
572
39236c6e 573print_exports_first_build_config: print_exports_bootstrap