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