]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | ||
46 | ||
47 | # Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS | |
48 | ifndef ARCH_CONFIGS | |
49 | ifdef RC_ARCHS | |
3e170ce0 | 50 | ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ") |
39236c6e A |
51 | else |
52 | ARCH_CONFIGS := DEFAULT | |
53 | endif | |
54 | endif | |
55 | ||
56 | # | |
57 | # Kernel Configuration options | |
58 | # | |
59 | ||
60 | ifeq ($(RC_ProjectName),xnu_debug) | |
61 | override DEFAULT_KERNEL_CONFIG := DEBUG | |
3e170ce0 | 62 | else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) |
fe8ab488 A |
63 | override DEFAULT_KERNEL_CONFIG := DEVELOPMENT |
64 | else ifeq ($(PLATFORM),MacOSX) | |
39236c6e A |
65 | override DEFAULT_KERNEL_CONFIG := DEVELOPMENT |
66 | else | |
67 | override DEFAULT_KERNEL_CONFIG := RELEASE | |
68 | endif | |
69 | ||
70 | # If KERNEL_CONFIGS is specified it should override default | |
71 | ifndef KERNEL_CONFIGS | |
72 | KERNEL_CONFIGS := DEFAULT | |
73 | endif | |
74 | ||
75 | # | |
76 | # Machine Configuration options | |
77 | # | |
78 | ||
79 | override DEFAULT_I386_MACHINE_CONFIG := NONE | |
80 | override DEFAULT_X86_64_MACHINE_CONFIG := NONE | |
fe8ab488 | 81 | override DEFAULT_X86_64H_MACHINE_CONFIG := NONE |
39236c6e A |
82 | |
83 | ||
84 | # This is typically never specified (TARGET_CONFIGS is used) | |
85 | ifndef MACHINE_CONFIGS | |
86 | MACHINE_CONFIGS := DEFAULT | |
87 | endif | |
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 |
110 | ifeq ($(PLATFORM),MacOSX) |
111 | ||
112 | # Defaults for "make all_desktop" | |
113 | ifeq ($(KERNEL_CONFIGS),DEFAULT) | |
114 | KERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT | |
115 | else | |
116 | KERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS) | |
117 | endif | |
118 | ||
119 | endif | |
120 | ||
39236c6e A |
121 | ifndef TARGET_CONFIGS |
122 | ifneq ($(PRODUCT_CONFIGS),) | |
123 | # generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS | |
124 | TARGET_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 |
125 | else ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),) |
126 | # generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map | |
127 | TARGET_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)))))) | |
128 | else ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),) | |
129 | # generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map | |
130 | TARGET_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 |
131 | else ifneq ($(filter %_embedded,$(MAKECMDGOALS)),) |
132 | # generate TARGET_CONFIGS for all kernel configs and products in the device map | |
133 | TARGET_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 |
134 | else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),) |
135 | # generate TARGET_CONFIGS for all kernel configs for B&I | |
136 | 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)))) | |
39236c6e A |
137 | else |
138 | # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT") | |
139 | 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)))) | |
140 | endif | |
141 | endif | |
142 | ||
143 | ifeq ($(TARGET_CONFIGS),) | |
144 | $(error No TARGET_CONFIGS specified) | |
145 | endif | |
146 | ||
147 | TARGET_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 | ||
159 | BUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC)) | |
160 | ||
161 | PRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config))))) | |
162 | 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), ))))) | |
163 | NON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS))) | |
164 | FIRST_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 | ||
172 | MEMORY_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 |
175 | LARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1) | |
39236c6e A |
176 | |
177 | ifeq ($(LARGE_BUILD_FOOTPRINT),1) | |
178 | RAM_PER_KERNEL_BUILD := 8589934592 | |
39236c6e A |
179 | else |
180 | RAM_PER_KERNEL_BUILD := 268435456 | |
39236c6e A |
181 | endif |
182 | ||
fe8ab488 A |
183 | 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 ) |
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 | |
204 | define 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))) |
212 | ifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
213 | $$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies)) | |
214 | endif | |
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) | |
237 | endef | |
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 | 246 | define 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 | |
252 | endef | |
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 |
270 | generated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG)) |
271 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
272 | $(warning Generate makefile fragment: $(generated_top_level_build_setup)) |
273 | endif | |
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 | 279 | setup: 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 | ||
298 | exporthdrs: exporthdrs_mi exporthdrs_md | |
299 | ||
300 | # | |
301 | # Install machine independent kernel header files | |
302 | # | |
303 | ||
304 | generated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG)) | |
fe8ab488 | 305 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) |
39236c6e A |
306 | $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi)) |
307 | endif | |
308 | $(eval $(generated_top_level_build_exporthdrs_mi)) | |
309 | ||
310 | exporthdrs_mi: build_exporthdrs_mi_bootstrap | |
311 | ||
312 | # | |
313 | # Install machine dependent kernel header files | |
314 | # | |
315 | ||
fe8ab488 A |
316 | 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)) |
317 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
318 | $(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md)) |
319 | endif | |
320 | $(eval $(generated_top_level_build_exporthdrs_md)) | |
321 | ||
322 | exporthdrs_md: build_exporthdrs_md_bootstrap | |
323 | ||
324 | # | |
325 | # Install kernel header files | |
326 | # | |
327 | ||
328 | .PHONY: installhdrs installhdrs_mi installhdrs_md | |
329 | ||
330 | ifeq ($(RC_ProjectName),xnu_debug) | |
331 | installhdrs: | |
332 | @: | |
333 | else | |
334 | ||
335 | installhdrs: installhdrs_mi installhdrs_md | |
336 | endif | |
337 | ||
fe8ab488 A |
338 | .PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded installhdrs_desktop |
339 | ||
340 | installhdrs_embedded installhdrs_release_embedded installhdrs_desktop: installhdrs | |
39236c6e | 341 | |
fe8ab488 | 342 | installhdrs_development_embedded: |
39236c6e A |
343 | |
344 | # | |
345 | # Install machine independent header files | |
346 | # | |
347 | ||
fe8ab488 A |
348 | 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)) |
349 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
350 | $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi)) |
351 | endif | |
352 | $(eval $(generated_top_level_build_installhdrs_mi)) | |
353 | ||
fe8ab488 | 354 | installhdrs_mi: build_installhdrs_mi_bootstrap |
39236c6e A |
355 | |
356 | # | |
357 | # Install machine dependent kernel header files | |
358 | # | |
359 | ||
fe8ab488 A |
360 | 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)) |
361 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
362 | $(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md)) |
363 | endif | |
364 | $(eval $(generated_top_level_build_installhdrs_md)) | |
365 | ||
fe8ab488 A |
366 | installhdrs_md: build_installhdrs_md_bootstrap |
367 | ||
368 | # | |
369 | # Install text files (man pages, dtrace scripts, etc.) | |
370 | # | |
371 | ||
372 | generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG)) | |
373 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
374 | $(warning Generate makefile fragment: $(generated_top_level_textfiles_install)) | |
375 | endif | |
376 | $(eval $(generated_top_level_textfiles_install)) | |
377 | ||
378 | .PHONY: install_textfiles | |
379 | ||
380 | install_textfiles: textfiles_install_bootstrap | |
39236c6e A |
381 | |
382 | # | |
383 | # Build all architectures for all Configuration/Architecture options | |
384 | # | |
385 | ||
fe8ab488 A |
386 | generated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS)) |
387 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
388 | $(warning Generate makefile fragment: $(generated_top_level_build_all)) |
389 | endif | |
390 | $(eval $(generated_top_level_build_all)) | |
391 | ||
392 | .PHONY: build | |
393 | ||
394 | build: build_all_bootstrap | |
395 | ||
396 | # | |
397 | # Post-process build results | |
398 | # | |
399 | ||
fe8ab488 A |
400 | generated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS)) |
401 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
402 | $(warning Generate makefile fragment: $(generated_top_level_config_all)) |
403 | endif | |
404 | $(eval $(generated_top_level_config_all)) | |
405 | ||
fe8ab488 | 406 | .PHONY: all config |
39236c6e | 407 | |
fe8ab488 | 408 | all config: config_all_bootstrap |
39236c6e | 409 | |
fe8ab488 | 410 | .PHONY: all_embedded all_release_embedded all_development_embedded all_desktop |
39236c6e | 411 | |
fe8ab488 | 412 | all_embedded all_release_embedded all_development_embedded all_desktop: all |
39236c6e A |
413 | |
414 | # | |
fe8ab488 | 415 | # Install kernel files |
39236c6e A |
416 | # |
417 | ||
418 | 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 | 419 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) |
39236c6e A |
420 | $(warning Generate makefile fragment: $(generated_top_level_build_install_primary)) |
421 | endif | |
422 | $(eval $(generated_top_level_build_install_primary)) | |
423 | ||
fe8ab488 A |
424 | .PHONY: install_primary |
425 | ||
426 | install_primary: build_install_primary_bootstrap | |
427 | ||
428 | 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)) | |
429 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
39236c6e A |
430 | $(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary)) |
431 | endif | |
432 | $(eval $(generated_top_level_build_install_non_primary)) | |
433 | ||
fe8ab488 A |
434 | .PHONY: install_non_primary |
435 | ||
436 | install_non_primary: build_install_non_primary_bootstrap | |
437 | ||
438 | generated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS)) | |
439 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) | |
440 | $(warning Generate makefile fragment: $(generated_top_level_config_install)) | |
441 | endif | |
442 | $(eval $(generated_top_level_config_install)) | |
443 | ||
444 | .PHONY: install_config final_touch_config_timestamps | |
445 | ||
446 | install_config: config_install_bootstrap final_touch_config_timestamps | |
447 | ||
448 | # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT | |
449 | final_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 | ||
458 | ifeq ($(RC_ProjectName),xnu_debug) | |
fe8ab488 | 459 | install: install_kernels |
39236c6e A |
460 | else ifeq ($(RC_ProjectName),xnu_headers_Sim) |
461 | install: installhdrs | |
462 | else | |
463 | ||
fe8ab488 | 464 | install: installhdrs install_textfiles install_config install_kernels |
39236c6e A |
465 | endif |
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 |
470 | install_embedded install_release_embedded install_desktop: install | |
39236c6e | 471 | |
fe8ab488 A |
472 | # These special configs only install the kernel files |
473 | install_development_embedded: install_kernels | |
39236c6e | 474 | |
fe8ab488 | 475 | .PHONY: install_kernels final_touch_kernel_timestamps |
39236c6e | 476 | |
fe8ab488 | 477 | install_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 |
480 | final_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 | ||
488 | installsrc: | |
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 | ||
500 | clean: | |
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 |
512 | cscope.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 | # | |
528 | cscope: cscope.files | |
529 | @echo "Building cscope database" | |
530 | @cscope -bvU 2> /dev/null | |
531 | ||
532 | # | |
533 | # Build tags | |
534 | # | |
535 | tags: 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 | ||
541 | TAGS: 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 | ||
551 | reindent: | |
552 | $(_v)$(SRCROOT)/tools/reindent.sh | |
553 | ||
554 | .PHONY: help | |
555 | ||
39236c6e A |
556 | help: |
557 | @cat README | |
558 | ||
3e170ce0 A |
559 | .PHONY: print_exports |
560 | ||
39236c6e A |
561 | print_exports: |
562 | $(_v)printenv | sort | |
563 | ||
564 | ||
565 | generated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG)) | |
fe8ab488 | 566 | ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES) |
39236c6e A |
567 | $(warning Generate makefile fragment: $(generated_top_level_print_exports)) |
568 | endif | |
569 | $(eval $(generated_top_level_print_exports)) | |
570 | ||
3e170ce0 A |
571 | .PHONY: print_exports_first_build_config |
572 | ||
39236c6e | 573 | print_exports_first_build_config: print_exports_bootstrap |