]>
Commit | Line | Data |
---|---|---|
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 | |
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 | |
3e170ce0 A |
37 | |
38 | ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) | |
39236c6e | 39 | override DEFAULT_ARCH_CONFIG := ARM |
3e170ce0 | 40 | else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) |
39236c6e A |
41 | override DEFAULT_ARCH_CONFIG := X86_64 |
42 | else | |
43 | override DEFAULT_ARCH_CONFIG := X86_64 | |
44 | endif | |
45 | ||
39236c6e A |
46 | # Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS |
47 | ifndef ARCH_CONFIGS | |
48 | ifdef RC_ARCHS | |
39037602 | 49 | ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ") |
39236c6e A |
50 | else |
51 | ARCH_CONFIGS := DEFAULT | |
52 | endif | |
53 | endif | |
54 | ||
55 | # | |
39037602 | 56 | # Kernel Configuration options |
39236c6e A |
57 | # |
58 | ||
59 | ifeq ($(RC_ProjectName),xnu_debug) | |
60 | override DEFAULT_KERNEL_CONFIG := DEBUG | |
3e170ce0 | 61 | else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) |
fe8ab488 A |
62 | override DEFAULT_KERNEL_CONFIG := DEVELOPMENT |
63 | else ifeq ($(PLATFORM),MacOSX) | |
39236c6e A |
64 | override DEFAULT_KERNEL_CONFIG := DEVELOPMENT |
65 | else | |
66 | override DEFAULT_KERNEL_CONFIG := RELEASE | |
67 | endif | |
68 | ||
69 | # If KERNEL_CONFIGS is specified it should override default | |
70 | ifndef KERNEL_CONFIGS | |
71 | KERNEL_CONFIGS := DEFAULT | |
72 | endif | |
73 | ||
74 | # | |
39037602 | 75 | # Machine Configuration options |
39236c6e A |
76 | # |
77 | ||
78 | override DEFAULT_I386_MACHINE_CONFIG := NONE | |
79 | override DEFAULT_X86_64_MACHINE_CONFIG := NONE | |
fe8ab488 | 80 | override DEFAULT_X86_64H_MACHINE_CONFIG := NONE |
39236c6e A |
81 | |
82 | ||
83 | # This is typically never specified (TARGET_CONFIGS is used) | |
84 | ifndef MACHINE_CONFIGS | |
39037602 | 85 | MACHINE_CONFIGS := DEFAULT |
39236c6e A |
86 | endif |
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 |
109 | ifeq ($(PLATFORM),MacOSX) |
110 | ||
111 | # Defaults for "make all_desktop" | |
112 | ifeq ($(KERNEL_CONFIGS),DEFAULT) | |
113 | KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT | |
114 | else | |
115 | KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS) | |
116 | endif | |
117 | ||
118 | endif | |
119 | ||
39236c6e A |
120 | ifndef TARGET_CONFIGS |
121 | ifneq ($(PRODUCT_CONFIGS),) | |
122 | # generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS | |
39037602 A |
123 | 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)))) |
124 | 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)))) | |
fe8ab488 A |
125 | else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),) |
126 | # generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map | |
39037602 A |
127 | 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)))) |
128 | 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)))) | |
fe8ab488 A |
129 | else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),) |
130 | # generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map | |
39037602 A |
131 | 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)))) |
132 | 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)))) | |
39236c6e A |
133 | else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),) |
134 | # generate TARGET_CONFIGS for all kernel configs and products in the device map | |
39037602 A |
135 | 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)))) |
136 | 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)))) | |
fe8ab488 A |
137 | else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),) |
138 | # generate TARGET_CONFIGS for all kernel configs for B&I | |
139 | 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)))) | |
39037602 | 140 | TARGET_CONFIGS_ALIASES := |
39236c6e A |
141 | else |
142 | # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT") | |
143 | 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)))) | |
39037602 | 144 | TARGET_CONFIGS_ALIASES := |
39236c6e A |
145 | endif |
146 | endif | |
147 | ||
148 | ifeq ($(TARGET_CONFIGS),) | |
149 | $(error No TARGET_CONFIGS specified) | |
150 | endif | |
151 | ||
152 | TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z)) | |
39037602 | 153 | TARGET_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 | ||
165 | BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC)) | |
166 | ||
167 | PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config))))) | |
168 | 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), ))))) | |
169 | NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS))) | |
170 | FIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS)) | |
171 | ||
39037602 A |
172 | ifneq ($(TARGET_CONFIGS_ALIASES_UC),) |
173 | ALIAS_CONFIGS = $(call function_create_alias_configs, $(TARGET_CONFIGS_ALIASES_UC)) | |
174 | else | |
175 | ALIAS_CONFIGS = | |
176 | endif | |
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 | |
186 | MEMORY_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 |
189 | LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1) | |
39236c6e A |
190 | |
191 | ifeq ($(LARGE_BUILD_FOOTPRINT),1) | |
39037602 | 192 | RAM_PER_KERNEL_BUILD := 4294967296 |
39236c6e A |
193 | else |
194 | RAM_PER_KERNEL_BUILD := 268435456 | |
39236c6e A |
195 | endif |
196 | ||
fe8ab488 A |
197 | 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 ) |
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 | |
218 | define 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))) |
226 | ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
227 | $$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies)) | |
228 | endif | |
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) | |
250 | endef | |
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 | 259 | define 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 | |
265 | endef | |
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 |
282 | generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG)) |
283 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
284 | $(warning Generate makefile fragment: $(generated_top_level_build_setup)) |
285 | endif | |
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 | 291 | setup: 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 | 310 | exporthdrs: exporthdrs_mi exporthdrs_md |
39236c6e A |
311 | |
312 | # | |
313 | # Install machine independent kernel header files | |
314 | # | |
315 | ||
316 | generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG)) | |
fe8ab488 | 317 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) |
39236c6e A |
318 | $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi)) |
319 | endif | |
320 | $(eval $(generated_top_level_build_exporthdrs_mi)) | |
321 | ||
322 | exporthdrs_mi: build_exporthdrs_mi_bootstrap | |
323 | ||
324 | # | |
39037602 | 325 | # Install machine dependent kernel header files |
39236c6e A |
326 | # |
327 | ||
fe8ab488 A |
328 | 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)) |
329 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
330 | $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md)) |
331 | endif | |
332 | $(eval $(generated_top_level_build_exporthdrs_md)) | |
333 | ||
334 | exporthdrs_md: build_exporthdrs_md_bootstrap | |
335 | ||
336 | # | |
337 | # Install kernel header files | |
338 | # | |
339 | ||
340 | .PHONY: installhdrs installhdrs_mi installhdrs_md | |
341 | ||
342 | ifeq ($(RC_ProjectName),xnu_debug) | |
343 | installhdrs: | |
344 | @: | |
345 | else | |
346 | ||
347 | installhdrs: installhdrs_mi installhdrs_md | |
348 | endif | |
349 | ||
fe8ab488 A |
350 | .PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop |
351 | ||
352 | installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs | |
39236c6e | 353 | |
fe8ab488 | 354 | installhdrs_development_embedded: |
39236c6e A |
355 | |
356 | # | |
357 | # Install machine independent header files | |
358 | # | |
359 | ||
fe8ab488 A |
360 | 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)) |
361 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
362 | $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi)) |
363 | endif | |
364 | $(eval $(generated_top_level_build_installhdrs_mi)) | |
365 | ||
fe8ab488 | 366 | installhdrs_mi: build_installhdrs_mi_bootstrap |
39236c6e A |
367 | |
368 | # | |
39037602 | 369 | # Install machine dependent kernel header files |
39236c6e A |
370 | # |
371 | ||
fe8ab488 A |
372 | 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)) |
373 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
374 | $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md)) |
375 | endif | |
376 | $(eval $(generated_top_level_build_installhdrs_md)) | |
377 | ||
fe8ab488 A |
378 | installhdrs_md: build_installhdrs_md_bootstrap |
379 | ||
380 | # | |
381 | # Install text files (man pages, dtrace scripts, etc.) | |
382 | # | |
383 | ||
384 | generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG)) | |
385 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
386 | $(warning Generate makefile fragment: $(generated_top_level_textfiles_install)) | |
387 | endif | |
388 | $(eval $(generated_top_level_textfiles_install)) | |
389 | ||
390 | .PHONY: install_textfiles | |
391 | ||
392 | install_textfiles: textfiles_install_bootstrap | |
39236c6e A |
393 | |
394 | # | |
395 | # Build all architectures for all Configuration/Architecture options | |
396 | # | |
397 | ||
fe8ab488 A |
398 | generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS)) |
399 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
400 | $(warning Generate makefile fragment: $(generated_top_level_build_all)) |
401 | endif | |
402 | $(eval $(generated_top_level_build_all)) | |
403 | ||
404 | .PHONY: build | |
405 | ||
406 | build: build_all_bootstrap | |
407 | ||
408 | # | |
409 | # Post-process build results | |
410 | # | |
411 | ||
fe8ab488 A |
412 | generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS)) |
413 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
414 | $(warning Generate makefile fragment: $(generated_top_level_config_all)) |
415 | endif | |
416 | $(eval $(generated_top_level_config_all)) | |
417 | ||
fe8ab488 | 418 | .PHONY: all config |
39236c6e | 419 | |
fe8ab488 | 420 | all config: config_all_bootstrap |
39236c6e | 421 | |
fe8ab488 | 422 | .PHONY: all_embedded all_release_embedded all_development_embedded all_desktop |
39236c6e | 423 | |
fe8ab488 | 424 | all_embedded all_release_embedded all_development_embedded all_desktop: all |
39236c6e A |
425 | |
426 | # | |
fe8ab488 | 427 | # Install kernel files |
39236c6e A |
428 | # |
429 | ||
430 | generated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS)) | |
fe8ab488 | 431 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) |
39236c6e A |
432 | $(warning Generate makefile fragment: $(generated_top_level_build_install_primary)) |
433 | endif | |
434 | $(eval $(generated_top_level_build_install_primary)) | |
435 | ||
fe8ab488 A |
436 | .PHONY: install_primary |
437 | ||
438 | install_primary: build_install_primary_bootstrap | |
439 | ||
440 | 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)) | |
441 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
442 | $(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary)) |
443 | endif | |
444 | $(eval $(generated_top_level_build_install_non_primary)) | |
445 | ||
fe8ab488 A |
446 | .PHONY: install_non_primary |
447 | ||
448 | install_non_primary: build_install_non_primary_bootstrap | |
449 | ||
450 | generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS)) | |
451 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
452 | $(warning Generate makefile fragment: $(generated_top_level_config_install)) | |
453 | endif | |
454 | $(eval $(generated_top_level_config_install)) | |
455 | ||
456 | .PHONY: install_config final_touch_config_timestamps | |
457 | ||
458 | install_config: config_install_bootstrap final_touch_config_timestamps | |
459 | ||
460 | # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT | |
461 | final_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 | ||
470 | ifeq ($(RC_ProjectName),xnu_debug) | |
fe8ab488 | 471 | install: install_kernels |
39236c6e A |
472 | else ifeq ($(RC_ProjectName),xnu_headers_Sim) |
473 | install: installhdrs | |
474 | else | |
475 | ||
39037602 | 476 | install: installhdrs install_textfiles install_config install_kernels install_aliases |
39236c6e A |
477 | endif |
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 |
482 | install_embedded install_release_embedded install_desktop: install | |
39236c6e | 483 | |
fe8ab488 | 484 | # These special configs only install the kernel files |
39037602 | 485 | install_development_embedded: install_kernels install_aliases |
39236c6e | 486 | |
39037602 | 487 | .PHONY: install_kernels final_touch_kernel_timestamps install_aliases |
39236c6e | 488 | |
fe8ab488 | 489 | install_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 |
492 | final_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 |
496 | generated_top_level_install_alias = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,install_alias,,install_kernels,,$(KERNEL_BUILDS_IN_PARALLEL),$(ALIAS_CONFIGS)) | |
497 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
498 | $(warning Generate makefile fragment: $(generated_top_level_install_alias)) | |
499 | endif | |
500 | $(eval $(generated_top_level_install_alias)) | |
501 | ||
502 | install_aliases: install_alias_bootstrap | |
503 | ||
39236c6e A |
504 | # |
505 | # Install source tree | |
506 | # | |
507 | .PHONY: installsrc | |
508 | ||
509 | installsrc: | |
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 | ||
521 | clean: | |
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 |
532 | cscope.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 | # | |
548 | cscope: cscope.files | |
549 | @echo "Building cscope database" | |
550 | @cscope -bvU 2> /dev/null | |
551 | ||
552 | # | |
553 | # Build tags | |
554 | # | |
555 | tags: 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 | ||
561 | TAGS: 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 | ||
571 | reindent: | |
572 | $(_v)$(SRCROOT)/tools/reindent.sh | |
573 | ||
574 | .PHONY: help | |
575 | ||
39236c6e | 576 | help: |
39037602 | 577 | @cat README.md |
39236c6e | 578 | |
3e170ce0 A |
579 | .PHONY: print_exports |
580 | ||
39236c6e A |
581 | print_exports: |
582 | $(_v)printenv | sort | |
583 | ||
39236c6e | 584 | generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG)) |
fe8ab488 | 585 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) |
39236c6e A |
586 | $(warning Generate makefile fragment: $(generated_top_level_print_exports)) |
587 | endif | |
588 | $(eval $(generated_top_level_print_exports)) | |
589 | ||
3e170ce0 A |
590 | .PHONY: print_exports_first_build_config |
591 | ||
39236c6e | 592 | print_exports_first_build_config: print_exports_bootstrap |