xref: /xnu-11417.101.15/makedefs/MakeInc.top (revision e3723e1f17661b24996789d8afc084c0c3303b26)
1*e3723e1fSApple OSS Distributions# -*- mode: makefile;-*-
2*e3723e1fSApple OSS Distributions#
3*e3723e1fSApple OSS Distributions# Copyright (C) 2010-2020 Apple Inc. All rights reserved.
4*e3723e1fSApple OSS Distributions#
5*e3723e1fSApple OSS Distributions# MakeInc.top is the top-level makefile for the xnu
6*e3723e1fSApple OSS Distributions# build system. All the main XBS targets
7*e3723e1fSApple OSS Distributions# (like "installhdrs") are defined here, as
8*e3723e1fSApple OSS Distributions# well as globals that can be overridden on
9*e3723e1fSApple OSS Distributions# the command-line by the user.
10*e3723e1fSApple OSS Distributions#
11*e3723e1fSApple OSS Distributions# This makefile's main purpose is to bootstrap
12*e3723e1fSApple OSS Distributions# the user's intent ("build these 3 kernels")
13*e3723e1fSApple OSS Distributions# into 3 single-architecture builds that each
14*e3723e1fSApple OSS Distributions# invoke the recursive make build system.
15*e3723e1fSApple OSS Distributions# As such, we have no knowledge of how to build
16*e3723e1fSApple OSS Distributions# a kernel or perform actions other than
17*e3723e1fSApple OSS Distributions# invoking a sub-make with a different
18*e3723e1fSApple OSS Distributions# current directory, makefile, and target. One
19*e3723e1fSApple OSS Distributions# side effect of this is that each
20*e3723e1fSApple OSS Distributions# single-architecture build is responsible for
21*e3723e1fSApple OSS Distributions# inserting its build products into the final
22*e3723e1fSApple OSS Distributions# multi-architecture output files. To avoid
23*e3723e1fSApple OSS Distributions# races, these aggregating stages for
24*e3723e1fSApple OSS Distributions# "primary" build configs are done in serial.
25*e3723e1fSApple OSS Distributions#
26*e3723e1fSApple OSS Distributions
27*e3723e1fSApple OSS Distributionsexport MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
28*e3723e1fSApple OSS Distributions
29*e3723e1fSApple OSS Distributionsinclude $(MakeInc_cmd)
30*e3723e1fSApple OSS Distributions
31*e3723e1fSApple OSS Distributions
32*e3723e1fSApple OSS Distributions#
33*e3723e1fSApple OSS Distributions# Architecture Configuration options
34*e3723e1fSApple OSS Distributions#
35*e3723e1fSApple OSS Distributions
36*e3723e1fSApple OSS Distributions# Default to current kernel architecture
37*e3723e1fSApple OSS Distributions
38*e3723e1fSApple OSS Distributionsifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
39*e3723e1fSApple OSS Distributions     override DEFAULT_ARCH_CONFIG := ARM64
40*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
41*e3723e1fSApple OSS Distributions     override DEFAULT_ARCH_CONFIG := X86_64
42*e3723e1fSApple OSS Distributionselse
43*e3723e1fSApple OSS Distributions     override DEFAULT_ARCH_CONFIG := X86_64
44*e3723e1fSApple OSS Distributionsendif
45*e3723e1fSApple OSS Distributions
46*e3723e1fSApple OSS Distributions# Accept either explicit ARCH_CONFIGS or XBS-style RC_ARCHS
47*e3723e1fSApple OSS Distributionsifndef ARCH_CONFIGS
48*e3723e1fSApple OSS Distributionsifdef RC_ARCHS
49*e3723e1fSApple OSS DistributionsARCH_CONFIGS	:= $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | $(TR) " " "\n" | sort -u | $(TR) "\n" " ")
50*e3723e1fSApple OSS Distributionselse
51*e3723e1fSApple OSS DistributionsARCH_CONFIGS	:= DEFAULT
52*e3723e1fSApple OSS Distributionsendif
53*e3723e1fSApple OSS Distributionsendif
54*e3723e1fSApple OSS Distributions
55*e3723e1fSApple OSS Distributions#
56*e3723e1fSApple OSS Distributions# Kernel Configuration options
57*e3723e1fSApple OSS Distributions#
58*e3723e1fSApple OSS Distributions
59*e3723e1fSApple OSS DistributionsDEFAULT_PRODUCT_CONFIGS :=
60*e3723e1fSApple OSS Distributions
61*e3723e1fSApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_debug),)
62*e3723e1fSApple OSS Distributionsoverride DEFAULT_KERNEL_CONFIG := DEBUG
63*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
64*e3723e1fSApple OSS Distributionsoverride KERNEL_CONFIGS := KASAN
65*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
66*e3723e1fSApple OSS Distributionsoverride DEFAULT_KERNEL_CONFIG := DEVELOPMENT
67*e3723e1fSApple OSS Distributionselse ifeq ($(PLATFORM),MacOSX)
68*e3723e1fSApple OSS Distributionsoverride DEFAULT_KERNEL_CONFIG := DEVELOPMENT
69*e3723e1fSApple OSS Distributionselse
70*e3723e1fSApple OSS Distributionsoverride DEFAULT_KERNEL_CONFIG := RELEASE
71*e3723e1fSApple OSS Distributionsendif
72*e3723e1fSApple OSS Distributions
73*e3723e1fSApple OSS Distributions# If KERNEL_CONFIGS is specified it should override default
74*e3723e1fSApple OSS Distributionsifndef KERNEL_CONFIGS
75*e3723e1fSApple OSS DistributionsKERNEL_CONFIGS := DEFAULT
76*e3723e1fSApple OSS Distributionsendif
77*e3723e1fSApple OSS Distributions
78*e3723e1fSApple OSS Distributions# If PRODUCT_CONFIGS is specified it should override default
79*e3723e1fSApple OSS Distributionsifndef PRODUCT_CONFIGS
80*e3723e1fSApple OSS DistributionsPRODUCT_CONFIGS := $(DEFAULT_PRODUCT_CONFIGS)
81*e3723e1fSApple OSS Distributionsendif
82*e3723e1fSApple OSS Distributions
83*e3723e1fSApple OSS Distributions#
84*e3723e1fSApple OSS Distributions# Machine Configuration options
85*e3723e1fSApple OSS Distributions#
86*e3723e1fSApple OSS Distributions
87*e3723e1fSApple OSS Distributionsoverride DEFAULT_I386_MACHINE_CONFIG := NONE
88*e3723e1fSApple OSS Distributionsoverride DEFAULT_X86_64_MACHINE_CONFIG := NONE
89*e3723e1fSApple OSS Distributionsoverride DEFAULT_X86_64H_MACHINE_CONFIG := NONE
90*e3723e1fSApple OSS Distributions
91*e3723e1fSApple OSS Distributionsifneq ($(findstring _Sim,$(RC_ProjectName)),)
92*e3723e1fSApple OSS Distributionsoverride DEFAULT_ARM64_MACHINE_CONFIG	:= NONE
93*e3723e1fSApple OSS Distributionselse ifneq ($(findstring _host,$(RC_ProjectName)),)
94*e3723e1fSApple OSS Distributionsoverride DEFAULT_ARM64_MACHINE_CONFIG	:= NONE
95*e3723e1fSApple OSS Distributionselse
96*e3723e1fSApple OSS Distributionsoverride DEFAULT_ARM64_MACHINE_CONFIG	:= VMAPPLE
97*e3723e1fSApple OSS Distributionsendif
98*e3723e1fSApple OSS Distributions
99*e3723e1fSApple OSS Distributions# This is typically never specified (TARGET_CONFIGS is used)
100*e3723e1fSApple OSS Distributionsifndef MACHINE_CONFIGS
101*e3723e1fSApple OSS DistributionsMACHINE_CONFIGS	:= DEFAULT
102*e3723e1fSApple OSS Distributionsendif
103*e3723e1fSApple OSS Distributions
104*e3723e1fSApple OSS Distributions#
105*e3723e1fSApple OSS Distributions# Target configuration options.  NOTE - target configurations will
106*e3723e1fSApple OSS Distributions# override ARCH_CONFIGS and KERNEL_CONFIGS and MACHINE_CONFIGS.
107*e3723e1fSApple OSS Distributions#
108*e3723e1fSApple OSS Distributions# Target configs come in groups of three parameters.  The first is the
109*e3723e1fSApple OSS Distributions# kernel configuration, the second is the architecture configuration,
110*e3723e1fSApple OSS Distributions# and the third is the machine configuration.  You may pass in as
111*e3723e1fSApple OSS Distributions# many groups of configurations as you wish.  Each item passed in is
112*e3723e1fSApple OSS Distributions# seperated by whitespace.
113*e3723e1fSApple OSS Distributions#
114*e3723e1fSApple OSS Distributions# Example:
115*e3723e1fSApple OSS Distributions#	TARGET_CONFIGS="release ppc default debug i386 default release arm MX31ADS"
116*e3723e1fSApple OSS Distributions# Parameters may be in upper or lower case (they are converted to upper).
117*e3723e1fSApple OSS Distributions#
118*e3723e1fSApple OSS Distributions# "default" parameter is a special case.  It means use the default value for
119*e3723e1fSApple OSS Distributions# that parameter.  Here are the default values for each configuration:
120*e3723e1fSApple OSS Distributions#
121*e3723e1fSApple OSS Distributions# default kernel configuration = DEFAULT_KERNEL_CONFIG
122*e3723e1fSApple OSS Distributions# default architecture configuration = system architecture where you are running make.
123*e3723e1fSApple OSS Distributions
124*e3723e1fSApple OSS Distributionsifneq ($(filter $(SUPPORTED_PLATFORMS),$(PLATFORM)),)
125*e3723e1fSApple OSS Distributions
126*e3723e1fSApple OSS Distributions# Defaults for "make all_embedded"
127*e3723e1fSApple OSS Distributionsifeq ($(KERNEL_CONFIGS),DEFAULT)
128*e3723e1fSApple OSS DistributionsKERNEL_CONFIGS_EMBEDDED := RELEASE DEVELOPMENT
129*e3723e1fSApple OSS Distributionselse
130*e3723e1fSApple OSS DistributionsKERNEL_CONFIGS_EMBEDDED := $(KERNEL_CONFIGS)
131*e3723e1fSApple OSS Distributionsendif
132*e3723e1fSApple OSS Distributions
133*e3723e1fSApple OSS Distributionsifeq ($(ARCH_CONFIGS),DEFAULT)
134*e3723e1fSApple OSS DistributionsARCH_CONFIGS_EMBEDDED := ARM64
135*e3723e1fSApple OSS DistributionsARCH_CONFIGS_DESKTOP := X86_64
136*e3723e1fSApple OSS Distributionselse
137*e3723e1fSApple OSS DistributionsARCH_CONFIGS_EMBEDDED := $(strip $(shell echo $(filter-out X86_64, $(ARCH_CONFIGS)) | $(TR) a-z A-Z))
138*e3723e1fSApple OSS DistributionsARCH_CONFIGS_DESKTOP := $(strip $(shell echo $(filter X86_64, $(ARCH_CONFIGS)) | $(TR) a-z A-Z))
139*e3723e1fSApple OSS Distributionsendif
140*e3723e1fSApple OSS Distributions
141*e3723e1fSApple OSS Distributions# Find supported products from the device map
142*e3723e1fSApple OSS Distributionsifneq ($(EMBEDDED_DEVICE_MAP),)
143*e3723e1fSApple OSS DistributionsDEVICEMAP_PRODUCTS_ARM64 := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)		\
144*e3723e1fSApple OSS Distributions				-list -query 'SELECT DISTINCT TargetType		\
145*e3723e1fSApple OSS Distributions					FROM Files					\
146*e3723e1fSApple OSS Distributions					  INNER JOIN Manifests USING (manifestID)	\
147*e3723e1fSApple OSS Distributions					  INNER JOIN Targets USING (Target)		\
148*e3723e1fSApple OSS Distributions					WHERE (KernelMachOArchitecture LIKE "arm64"	\
149*e3723e1fSApple OSS Distributions					   AND fileType in ("KernelCache", "RestoreKernelCache"))')
150*e3723e1fSApple OSS DistributionsDEVICEMAP_PRODUCTS_OSX_ARM64 := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)		\
151*e3723e1fSApple OSS Distributions					-list -query 'SELECT DISTINCT TargetType		\
152*e3723e1fSApple OSS Distributions					      	FROM Files					\
153*e3723e1fSApple OSS Distributions					  	  INNER JOIN Manifests USING (manifestID)	\
154*e3723e1fSApple OSS Distributions					  	  INNER JOIN Targets USING (Target)		\
155*e3723e1fSApple OSS Distributions					    	WHERE (KernelMachOArchitecture LIKE "arm64"	\
156*e3723e1fSApple OSS Distributions					   	  AND fileType in ("KernelCache", "RestoreKernelCache") \
157*e3723e1fSApple OSS Distributions						  AND SDKPlatform == "macosx")')
158*e3723e1fSApple OSS Distributions
159*e3723e1fSApple OSS Distributions
160*e3723e1fSApple OSS Distributions# Generate a list of mappings of the form "n75:arm;t8002" based on the device map
161*e3723e1fSApple OSS DistributionsDEVICEMAP_PRODUCT_SOC_MAPPINGS := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -list -query SELECT DISTINCT TargetType, KernelMachOArchitecture, KernelPlatform FROM Targets | awk -F\| '{ if ($$2 ~ /arm64[a-z]?/) { print $$1 ":arm64;" $$3 ";" $$4} else { print $$1 ":" $$2 ";" $$3 ";" $$4} }' )
162*e3723e1fSApple OSS Distributions
163*e3723e1fSApple OSS Distributions# use embedded_device_map
164*e3723e1fSApple OSS Distributionsendif
165*e3723e1fSApple OSS Distributions
166*e3723e1fSApple OSS Distributions# Map a product like "n75" to "arm;t8002"
167*e3723e1fSApple OSS Distributions# $(1) is a product name in lower case
168*e3723e1fSApple OSS Distributionsfunction_lookup_product = $(call function_substitute_word_with_replacement,	\
169*e3723e1fSApple OSS Distributions				 $(1),						\
170*e3723e1fSApple OSS Distributions				 $(DEVICEMAP_PRODUCT_SOC_MAPPINGS),		\
171*e3723e1fSApple OSS Distributions				 unknown_arch_for_$(1);unknown_platform_for_$(1) \
172*e3723e1fSApple OSS Distributions			   )
173*e3723e1fSApple OSS Distributions
174*e3723e1fSApple OSS Distributionsifneq ($(PLATFORM),MacOSX)
175*e3723e1fSApple OSS Distributionsifneq ($(EMBEDDED_DEVICE_MAP),)
176*e3723e1fSApple OSS Distributions# Generate a list of mappings for products that use a different platform for their kernel configuration than their true platform
177*e3723e1fSApple OSS Distributions# of the form "n71m:arm64;s8000;s8003". The 4th element is the true SoC platform, which will get an on-disk copy, while the
178*e3723e1fSApple OSS Distributions# kernel's recursive build system will build the 3rd element as the KernelPlatform
179*e3723e1fSApple OSS DistributionsDEVICEMAP_PRODUCT_SOC_ALIASES := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -list -query SELECT DISTINCT TargetType, KernelMachOArchitecture, KernelPlatform, Platform FROM Targets WHERE KernelPlatform "!=" Platform | awk -F\| '{ if ($$2 ~ /arm64[a-z]?/) { print $$1 ":arm64;" $$3 ";" $$4} else { print $$1 ":" $$2 ";" $$3 ";" $$4} }' )
180*e3723e1fSApple OSS Distributions
181*e3723e1fSApple OSS Distributionsendif
182*e3723e1fSApple OSS Distributionsendif
183*e3723e1fSApple OSS Distributions
184*e3723e1fSApple OSS Distributionsfunction_lookup_product_alias = $(call function_substitute_word_with_replacement,	\
185*e3723e1fSApple OSS Distributions					$(1),						\
186*e3723e1fSApple OSS Distributions					$(DEVICEMAP_PRODUCT_SOC_ALIASES),		\
187*e3723e1fSApple OSS Distributions				 )
188*e3723e1fSApple OSS Distributionsendif
189*e3723e1fSApple OSS Distributions
190*e3723e1fSApple OSS Distributionsifeq ($(PLATFORM),MacOSX)
191*e3723e1fSApple OSS Distributions
192*e3723e1fSApple OSS Distributions# Defaults for "make all_desktop"
193*e3723e1fSApple OSS Distributionsifeq ($(KERNEL_CONFIGS),DEFAULT)
194*e3723e1fSApple OSS DistributionsKERNEL_CONFIGS_DESKTOP := RELEASE DEVELOPMENT
195*e3723e1fSApple OSS Distributionselse
196*e3723e1fSApple OSS DistributionsKERNEL_CONFIGS_DESKTOP := $(KERNEL_CONFIGS)
197*e3723e1fSApple OSS Distributionsendif
198*e3723e1fSApple OSS Distributions
199*e3723e1fSApple OSS Distributionsendif
200*e3723e1fSApple OSS Distributions
201*e3723e1fSApple OSS Distributionsifndef TARGET_CONFIGS
202*e3723e1fSApple OSS Distributionsifneq ($(PRODUCT_CONFIGS),)
203*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS using KERNEL_CONFIGS and PRODUCT_CONFIGS
204*e3723e1fSApple OSS DistributionsTARGET_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))))
205*e3723e1fSApple OSS DistributionsTARGET_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))))
206*e3723e1fSApple OSS Distributionselse ifeq (xnu_headers_driverkit,$(RC_ProjectName))
207*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for all kernel configs for B&I
208*e3723e1fSApple OSS DistributionsTARGET_CONFIGS = DEVELOPMENT arm64 DEFAULT DEVELOPMENT X86_64 DEFAULT
209*e3723e1fSApple OSS Distributionselse ifneq ($(filter %_release_embedded,$(MAKECMDGOALS)),)
210*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for RELEASE kernel configs and products in the device map
211*e3723e1fSApple OSS DistributionsTARGET_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))))
212*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(EXTRA_TARGET_CONFIGS_RELEASE)
213*e3723e1fSApple OSS DistributionsTARGET_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))))
214*e3723e1fSApple OSS Distributionselse ifneq ($(filter %_development_embedded,$(MAKECMDGOALS)),)
215*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for DEVELOPMENT kernel configs and products in the device map
216*e3723e1fSApple OSS DistributionsTARGET_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))))
217*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(EXTRA_TARGET_CONFIGS_DEVELOPMENT)
218*e3723e1fSApple OSS DistributionsTARGET_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))))
219*e3723e1fSApple OSS Distributionselse ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
220*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for all kernel configs and products in the device map
221*e3723e1fSApple OSS DistributionsTARGET_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))))
222*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(EXTRA_TARGET_CONFIGS_$(my_kernel_config)))
223*e3723e1fSApple OSS DistributionsTARGET_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))))
224*e3723e1fSApple OSS Distributionselse ifneq ($(filter %_release_desktop,$(MAKECMDGOALS)),)
225*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for B&I release builds
226*e3723e1fSApple OSS DistributionsTARGET_CONFIGS := $(foreach my_kern_config, RELEASE, $(foreach my_arch_config, $(ARCH_CONFIGS_DESKTOP), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
227*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,RELEASE,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
228*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(EXTRA_TARGET_CONFIGS_RELEASE)
229*e3723e1fSApple OSS DistributionsTARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,RELEASE,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
230*e3723e1fSApple OSS Distributionselse ifneq ($(filter %_development_desktop,$(MAKECMDGOALS)),)
231*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for B&I development builds
232*e3723e1fSApple OSS DistributionsTARGET_CONFIGS := $(foreach my_kern_config, DEVELOPMENT, $(foreach my_arch_config, $(ARCH_CONFIGS_DESKTOP), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
233*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,DEVELOPMENT,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
234*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(EXTRA_TARGET_CONFIGS_DEVELOPMENT)
235*e3723e1fSApple OSS DistributionsTARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,DEVELOPMENT,$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
236*e3723e1fSApple OSS Distributionselse ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
237*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS for all kernel configs for B&I
238*e3723e1fSApple OSS DistributionsTARGET_CONFIGS := $(foreach my_kern_config, $(KERNEL_CONFIGS_DESKTOP), $(foreach my_arch_config, $(ARCH_CONFIGS_DESKTOP), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
239*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
240*e3723e1fSApple OSS DistributionsTARGET_CONFIGS += $(foreach my_kernel_config,$(KERNEL_CONFIGS_DESKTOP),$(EXTRA_TARGET_CONFIGS_$(my_kernel_config)))
241*e3723e1fSApple OSS DistributionsTARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(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))))
242*e3723e1fSApple OSS Distributionselse
243*e3723e1fSApple OSS Distributions# generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
244*e3723e1fSApple OSS DistributionsTARGET_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))))
245*e3723e1fSApple OSS DistributionsTARGET_CONFIGS_ALIASES :=
246*e3723e1fSApple OSS Distributionsendif
247*e3723e1fSApple OSS Distributionsendif
248*e3723e1fSApple OSS Distributions
249*e3723e1fSApple OSS Distributionsifeq ($(TARGET_CONFIGS),)
250*e3723e1fSApple OSS Distributions$(error No TARGET_CONFIGS specified)
251*e3723e1fSApple OSS Distributionsendif
252*e3723e1fSApple OSS Distributions
253*e3723e1fSApple OSS DistributionsTARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
254*e3723e1fSApple OSS DistributionsTARGET_CONFIGS_ALIASES_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS_ALIASES)" | $(TR) a-z A-Z))
255*e3723e1fSApple OSS Distributions
256*e3723e1fSApple OSS Distributions#
257*e3723e1fSApple OSS Distributions# Build Configurations
258*e3723e1fSApple OSS Distributions#
259*e3723e1fSApple OSS Distributions# TARGET_CONFIGS is unwieldy for use in Makefiles. Convert them to
260*e3723e1fSApple OSS Distributions# "build configurations" which are tuples joined by "^". For
261*e3723e1fSApple OSS Distributions# example, "RELEASE I386 DEFAULT DEVELOPMENT ARM DEFAULT" becomes
262*e3723e1fSApple OSS Distributions# "RELEASE^I386^NONE DEVELOPMENT^ARM^T8002", which can be looped
263*e3723e1fSApple OSS Distributions# over trivially. PRIMARY_BUILD_CONFIGS is the first config
264*e3723e1fSApple OSS Distributions# for each architecture, used primarily for machine-dependent recursion.
265*e3723e1fSApple OSS Distributions# VARIANT_CONFIGS contains one build configuration for each combination
266*e3723e1fSApple OSS Distributions# of kernel architecture and configuration. It is used for variant
267*e3723e1fSApple OSS Distributions# installation recursion.
268*e3723e1fSApple OSS Distributions
269*e3723e1fSApple OSS DistributionsBUILD_CONFIGS = $(call function_create_build_configs, $(TARGET_CONFIGS_UC))
270*e3723e1fSApple OSS Distributions
271*e3723e1fSApple OSS DistributionsPRIMARY_ARCHS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_arch_config_from_build_config, $(build_config)))))
272*e3723e1fSApple OSS DistributionsPRIMARY_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), )))))
273*e3723e1fSApple OSS DistributionsNON_PRIMARY_BUILD_CONFIGS = $(strip $(filter-out $(PRIMARY_BUILD_CONFIGS), $(BUILD_CONFIGS)))
274*e3723e1fSApple OSS DistributionsFIRST_BUILD_CONFIG = $(firstword $(BUILD_CONFIGS))
275*e3723e1fSApple OSS Distributions
276*e3723e1fSApple OSS Distributions# Build list of all kernel configurations present in all build configs.
277*e3723e1fSApple OSS DistributionsPRIMARY_KERNEL_CONFIGS = $(strip $(sort $(foreach build_config, $(BUILD_CONFIGS), $(call function_extract_kernel_config_from_build_config, $(build_config)))))
278*e3723e1fSApple OSS Distributions
279*e3723e1fSApple OSS Distributions# Pick one build configuration for each kernel configuration.
280*e3723e1fSApple OSS Distributions# This will be used to populate System.kext variants in SYMROOT / DSTROOT.
281*e3723e1fSApple OSS DistributionsVARIANT_CONFIGS = $(strip \
282*e3723e1fSApple OSS Distributions                    $(foreach kernel_config, $(PRIMARY_KERNEL_CONFIGS), \
283*e3723e1fSApple OSS Distributions                      $(firstword $(call function_match_build_config_for_kernel_config, $(BUILD_CONFIGS), $(kernel_config)))))
284*e3723e1fSApple OSS Distributions
285*e3723e1fSApple OSS Distributionsifneq ($(TARGET_CONFIGS_ALIASES_UC),)
286*e3723e1fSApple OSS DistributionsALIAS_CONFIGS = $(call function_create_alias_configs, $(TARGET_CONFIGS_ALIASES_UC))
287*e3723e1fSApple OSS Distributionselse
288*e3723e1fSApple OSS DistributionsALIAS_CONFIGS =
289*e3723e1fSApple OSS Distributionsendif
290*e3723e1fSApple OSS Distributions
291*e3723e1fSApple OSS Distributions# $(warning PRIMARY_ARCHS is $(PRIMARY_ARCHS))
292*e3723e1fSApple OSS Distributions# $(warning TARGET_CONFIGS is $(TARGET_CONFIGS))
293*e3723e1fSApple OSS Distributions# $(warning BUILD_CONFIGS is $(BUILD_CONFIGS))
294*e3723e1fSApple OSS Distributions# $(warning PRIMARY_BUILD_CONFIGS is $(PRIMARY_BUILD_CONFIGS))
295*e3723e1fSApple OSS Distributions# $(warning NON_PRIMARY_BUILD_CONFIGS is $(NON_PRIMARY_BUILD_CONFIGS))
296*e3723e1fSApple OSS Distributions# $(warning TARGET_CONFIGS_ALIASES is $(TARGET_CONFIGS_ALIASES))
297*e3723e1fSApple OSS Distributions# $(warning ALIAS_CONFIGS is $(ALIAS_CONFIGS))
298*e3723e1fSApple OSS Distributions# $(warning PRIMARY_KERNEL_CONFIGS is $(PRIMARY_KERNEL_CONFIGS))
299*e3723e1fSApple OSS Distributions# $(warning VARIANT_CONFIGS is $(VARIANT_CONFIGS))
300*e3723e1fSApple OSS Distributions
301*e3723e1fSApple OSS DistributionsMEMORY_SIZE := $(shell /usr/sbin/sysctl -n hw.memsize)
302*e3723e1fSApple OSS Distributions
303*e3723e1fSApple OSS Distributions# Assume LTO scaling by default, unless it is being explicitly passed on the command-line
304*e3723e1fSApple OSS DistributionsLARGE_BUILD_FOOTPRINT := $(if $(BUILD_LTO),$(BUILD_LTO),1)
305*e3723e1fSApple OSS Distributions
306*e3723e1fSApple OSS Distributionsifeq ($(LARGE_BUILD_FOOTPRINT),1)
307*e3723e1fSApple OSS DistributionsRAM_PER_KERNEL_BUILD := 4294967296
308*e3723e1fSApple OSS Distributionselse
309*e3723e1fSApple OSS DistributionsRAM_PER_KERNEL_BUILD := 268435456
310*e3723e1fSApple OSS Distributionsendif
311*e3723e1fSApple OSS Distributions
312*e3723e1fSApple OSS DistributionsKERNEL_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 )
313*e3723e1fSApple OSS Distributions# $(warning Building $(KERNEL_BUILDS_IN_PARALLEL) kernels in parallel)
314*e3723e1fSApple OSS Distributions
315*e3723e1fSApple OSS Distributions#
316*e3723e1fSApple OSS Distributions# TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
317*e3723e1fSApple OSS Distributions#
318*e3723e1fSApple OSS Distributions# $(1) is the name of the makefile target to invoke for the each build config
319*e3723e1fSApple OSS Distributions#      after setting up the parallel hierarchy in the TARGET directory
320*e3723e1fSApple OSS Distributions# $(2) is an optional suffix on the TARGET directory, which might even be
321*e3723e1fSApple OSS Distributions#      "/.."
322*e3723e1fSApple OSS Distributions# $(3) are any dependencies for the bootstrap target
323*e3723e1fSApple OSS Distributions# $(4) are any dependencies that are expanded per-build config to another bootstrap target
324*e3723e1fSApple OSS Distributions# $(5) is how many build configurations to build in parallel
325*e3723e1fSApple OSS Distributions# $(6) is which build configs to build in parallel
326*e3723e1fSApple OSS Distributions#
327*e3723e1fSApple OSS Distributions# Since building many configurations in parallel may overwhelm the system,
328*e3723e1fSApple OSS Distributions# we try to throttle behavior into more managable S "stripes" of N/S
329*e3723e1fSApple OSS Distributions# configurations by generating sequential dependencies between configs
330*e3723e1fSApple OSS Distributions# in each stripe. That ensures that only S kernel builds are occurring
331*e3723e1fSApple OSS Distributions# at once at any point in time
332*e3723e1fSApple OSS Distributions
333*e3723e1fSApple OSS Distributionsdefine TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template
334*e3723e1fSApple OSS Distributions
335*e3723e1fSApple OSS Distributions# Create a list of synthesized targets for each build config
336*e3723e1fSApple OSS Distributions$(1)_bootstrap_target_list = $$(addprefix $(1)_bootstrap_,$(6))
337*e3723e1fSApple OSS Distributions
338*e3723e1fSApple OSS Distributions.PHONY: $$($(1)_bootstrap_target_list)
339*e3723e1fSApple OSS Distributions
340*e3723e1fSApple OSS Distributions$(1)_generated_stripe_dependencies = $$(call _function_generate_stripe_groupings,$(1),$(5),$(call reverse,$(6)))
341*e3723e1fSApple OSS Distributionsifeq ($$(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
342*e3723e1fSApple OSS Distributions$$(warning Generate makefile fragment: $$($(1)_generated_stripe_dependencies))
343*e3723e1fSApple OSS Distributionsendif
344*e3723e1fSApple OSS Distributions$$(eval $$($(1)_generated_stripe_dependencies))
345*e3723e1fSApple OSS Distributions
346*e3723e1fSApple OSS Distributions$$($(1)_bootstrap_target_list): $(1)_bootstrap_% : $(1)_stripe_dep_for_% $$(addsuffix _bootstrap_%,$(4)) $(3)
347*e3723e1fSApple OSS Distributions	$$(_v)$$(MKDIR) $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)
348*e3723e1fSApple OSS Distributions	$$(_v)$${MAKE}													        \
349*e3723e1fSApple OSS Distributions		-C $${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)		\
350*e3723e1fSApple OSS Distributions		-f $${SRCROOT}/Makefile												\
351*e3723e1fSApple OSS Distributions		CURRENT_KERNEL_CONFIG=$$(call function_extract_kernel_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@)) \
352*e3723e1fSApple OSS Distributions		CURRENT_ARCH_CONFIG=$$(call function_extract_arch_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@))	  \
353*e3723e1fSApple OSS Distributions		CURRENT_MACHINE_CONFIG=$$(call function_extract_machine_config_from_build_config,$$(patsubst $(1)_bootstrap_%,%,$$@))	\
354*e3723e1fSApple OSS Distributions		CURRENT_BUILD_CONFIG=$$(patsubst $(1)_bootstrap_%,%,$$@)							\
355*e3723e1fSApple OSS Distributions		PRIMARY_BUILD_CONFIGS="$(PRIMARY_BUILD_CONFIGS)" BUILD_CONFIGS="$(BUILD_CONFIGS)"				\
356*e3723e1fSApple OSS Distributions		SOURCE=$${SRCROOT}/												\
357*e3723e1fSApple OSS Distributions		RELATIVE_SOURCE_PATH=.											\
358*e3723e1fSApple OSS Distributions		TARGET=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))$(2)/	\
359*e3723e1fSApple OSS Distributions		OBJPATH=$${OBJROOT}/$$(call function_convert_build_config_to_objdir,$$(patsubst $(1)_bootstrap_%,%,$$@))	\
360*e3723e1fSApple OSS Distributions		$(1)
361*e3723e1fSApple OSS Distributions
362*e3723e1fSApple OSS Distributions.PHONY: $(1)_bootstrap
363*e3723e1fSApple OSS Distributions
364*e3723e1fSApple OSS Distributions$(1)_bootstrap: $$($(1)_bootstrap_target_list)
365*e3723e1fSApple OSS Distributionsendef
366*e3723e1fSApple OSS Distributions
367*e3723e1fSApple OSS Distributions#
368*e3723e1fSApple OSS Distributions# TOP_LEVEL_STRIPE_DEPENDENCY_template
369*e3723e1fSApple OSS Distributions#
370*e3723e1fSApple OSS Distributions# $(1) is the Makefile target we are building for
371*e3723e1fSApple OSS Distributions# $(2) is the build config that must build first
372*e3723e1fSApple OSS Distributions# $(3) is the build config that must build after $(2)
373*e3723e1fSApple OSS Distributions
374*e3723e1fSApple OSS Distributionsdefine TOP_LEVEL_STRIPE_DEPENDENCY_template
375*e3723e1fSApple OSS Distributions
376*e3723e1fSApple OSS Distributions.PHONY: $(1)_stripe_dep_for_$(3)
377*e3723e1fSApple OSS Distributions
378*e3723e1fSApple OSS Distributions $(1)_stripe_dep_for_$(3): $(if $(2),$(1)_bootstrap_$(2))
379*e3723e1fSApple OSS Distributions
380*e3723e1fSApple OSS Distributionsendef
381*e3723e1fSApple OSS Distributions
382*e3723e1fSApple OSS Distributions# $(1) is the Makefile target we are building for
383*e3723e1fSApple OSS Distributions# $(2) is the stripe size
384*e3723e1fSApple OSS Distributions# $(3) is the list of the build configs in the current group
385*e3723e1fSApple OSS Distributions# $(4) is the list of remaining build configs
386*e3723e1fSApple OSS Distributions_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))))
387*e3723e1fSApple OSS Distributions
388*e3723e1fSApple OSS Distributions# $(1) is the Makefile target we are building for
389*e3723e1fSApple OSS Distributions# $(2) is the stripe size
390*e3723e1fSApple OSS Distributions# $(3) is the list of the build configs
391*e3723e1fSApple OSS Distributions_function_generate_stripe_groupings = $(call _function_generate_stripe_groupings_recursive,$(1),$(2),,$(3))
392*e3723e1fSApple OSS Distributions
393*e3723e1fSApple OSS Distributions#
394*e3723e1fSApple OSS Distributions# Setup pass for build system tools
395*e3723e1fSApple OSS Distributions#
396*e3723e1fSApple OSS Distributions
397*e3723e1fSApple OSS Distributionsgenerated_top_level_build_setup = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_setup,/..,,,1,$(FIRST_BUILD_CONFIG))
398*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
399*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_setup))
400*e3723e1fSApple OSS Distributionsendif
401*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_setup))
402*e3723e1fSApple OSS Distributions
403*e3723e1fSApple OSS Distributions.PHONY: setup
404*e3723e1fSApple OSS Distributions
405*e3723e1fSApple OSS Distributions# invalidate current kernel in $(SYMROOT). Timestamp must be +1 from a previous kernel build
406*e3723e1fSApple OSS Distributionssetup: build_setup_bootstrap
407*e3723e1fSApple OSS Distributions	$(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new
408*e3723e1fSApple OSS Distributions    # -nt and -ot are evaluated differently by bash, dash, and zsh (and are not part of the POSIX specification).
409*e3723e1fSApple OSS Distributions    # Explicitly specify what should happen when the right hand file doesn't exist.
410*e3723e1fSApple OSS Distributions	$(_v)while [ \! $(OBJROOT)/.mach_kernel.timestamp.new -nt $(OBJROOT)/.mach_kernel.timestamp -a \( \! -e $(OBJROOT)/.mach_kernel.timestamp.new -o -e $(OBJROOT)/.mach_kernel.timestamp \) ]; do \
411*e3723e1fSApple OSS Distributions		$(SLEEP) 1;					\
412*e3723e1fSApple OSS Distributions		$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp.new;	\
413*e3723e1fSApple OSS Distributions	done
414*e3723e1fSApple OSS Distributions	$(_v)$(MV) $(OBJROOT)/.mach_kernel.timestamp.new $(OBJROOT)/.mach_kernel.timestamp
415*e3723e1fSApple OSS Distributions	$(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp.new
416*e3723e1fSApple OSS Distributions	$(_v)while [ $(OBJROOT)/.symbolset.timestamp.new -ot $(OBJROOT)/.symbolset.timestamp ]; do \
417*e3723e1fSApple OSS Distributions		$(SLEEP) 1;					\
418*e3723e1fSApple OSS Distributions		$(TOUCH) $(OBJROOT)/.symbolset.timestamp.new;	\
419*e3723e1fSApple OSS Distributions	done
420*e3723e1fSApple OSS Distributions	$(_v)$(MV) $(OBJROOT)/.symbolset.timestamp.new $(OBJROOT)/.symbolset.timestamp
421*e3723e1fSApple OSS Distributions
422*e3723e1fSApple OSS Distributions#
423*e3723e1fSApple OSS Distributions# Install kernel header files
424*e3723e1fSApple OSS Distributions#
425*e3723e1fSApple OSS Distributions.PHONY: exporthdrs exporthdrs_mi exporthdrs_md
426*e3723e1fSApple OSS Distributions
427*e3723e1fSApple OSS Distributionsexporthdrs: exporthdrs_mi exporthdrs_md
428*e3723e1fSApple OSS Distributions
429*e3723e1fSApple OSS Distributions#
430*e3723e1fSApple OSS Distributions# Install machine independent kernel header files
431*e3723e1fSApple OSS Distributions#
432*e3723e1fSApple OSS Distributions
433*e3723e1fSApple OSS Distributionsgenerated_top_level_build_exporthdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
434*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
435*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_mi))
436*e3723e1fSApple OSS Distributionsendif
437*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_exporthdrs_mi))
438*e3723e1fSApple OSS Distributions
439*e3723e1fSApple OSS Distributionsexporthdrs_mi: build_exporthdrs_mi_bootstrap
440*e3723e1fSApple OSS Distributions
441*e3723e1fSApple OSS Distributions#
442*e3723e1fSApple OSS Distributions# Install machine dependent kernel header files
443*e3723e1fSApple OSS Distributions#
444*e3723e1fSApple OSS Distributions
445*e3723e1fSApple OSS Distributionsgenerated_top_level_build_exporthdrs_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_exporthdrs_md,,setup,,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
446*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
447*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_exporthdrs_md))
448*e3723e1fSApple OSS Distributionsendif
449*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_exporthdrs_md))
450*e3723e1fSApple OSS Distributions
451*e3723e1fSApple OSS Distributionsexporthdrs_md: build_exporthdrs_md_bootstrap
452*e3723e1fSApple OSS Distributions
453*e3723e1fSApple OSS Distributions#
454*e3723e1fSApple OSS Distributions# Install kernel header files
455*e3723e1fSApple OSS Distributions#
456*e3723e1fSApple OSS Distributions
457*e3723e1fSApple OSS Distributions.PHONY: installhdrs installhdrs_mi installhdrs_md
458*e3723e1fSApple OSS Distributions
459*e3723e1fSApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_debug),)
460*e3723e1fSApple OSS Distributionsinstallhdrs:
461*e3723e1fSApple OSS Distributions	@:
462*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
463*e3723e1fSApple OSS Distributionsinstallhdrs:
464*e3723e1fSApple OSS Distributions	@:
465*e3723e1fSApple OSS Distributionselse
466*e3723e1fSApple OSS Distributions
467*e3723e1fSApple OSS Distributionsinstallhdrs: installhdrs_mi installhdrs_md
468*e3723e1fSApple OSS Distributionsendif
469*e3723e1fSApple OSS Distributions
470*e3723e1fSApple OSS Distributions.PHONY: installhdrs_embedded installhdrs_release_embedded installhdrs_development_embedded
471*e3723e1fSApple OSS Distributions.PHONY: installhdrs_desktop installhdrs_release_desktop installhdrs_development_desktop
472*e3723e1fSApple OSS Distributions
473*e3723e1fSApple OSS Distributionsinstallhdrs_embedded installhdrs_release_embedded: installhdrs
474*e3723e1fSApple OSS Distributionsinstallhdrs_desktop installhdrs_release_desktop: installhdrs
475*e3723e1fSApple OSS Distributions
476*e3723e1fSApple OSS Distributionsinstallhdrs_development_embedded:
477*e3723e1fSApple OSS Distributionsinstallhdrs_development_desktop:
478*e3723e1fSApple OSS Distributions
479*e3723e1fSApple OSS Distributions#
480*e3723e1fSApple OSS Distributions# Install machine independent header files
481*e3723e1fSApple OSS Distributions#
482*e3723e1fSApple OSS Distributions
483*e3723e1fSApple OSS Distributionsgenerated_top_level_build_installhdrs_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_installhdrs_mi,,setup,build_exporthdrs_mi,1,$(FIRST_BUILD_CONFIG))
484*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
485*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_mi))
486*e3723e1fSApple OSS Distributionsendif
487*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_installhdrs_mi))
488*e3723e1fSApple OSS Distributions
489*e3723e1fSApple OSS Distributionsinstallhdrs_mi: build_installhdrs_mi_bootstrap
490*e3723e1fSApple OSS Distributions
491*e3723e1fSApple OSS Distributions#
492*e3723e1fSApple OSS Distributions# Install machine dependent kernel header files
493*e3723e1fSApple OSS Distributions#
494*e3723e1fSApple OSS Distributions
495*e3723e1fSApple OSS Distributionsgenerated_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))
496*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
497*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_installhdrs_md))
498*e3723e1fSApple OSS Distributionsendif
499*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_installhdrs_md))
500*e3723e1fSApple OSS Distributions
501*e3723e1fSApple OSS Distributionsinstallhdrs_md: build_installhdrs_md_bootstrap
502*e3723e1fSApple OSS Distributions
503*e3723e1fSApple OSS Distributions.PHONY: install_textfiles install_textfiles_mi install_textfiles_md
504*e3723e1fSApple OSS Distributions
505*e3723e1fSApple OSS Distributionsinstall_textfiles: install_textfiles_mi install_textfiles_md
506*e3723e1fSApple OSS Distributions
507*e3723e1fSApple OSS Distributions#
508*e3723e1fSApple OSS Distributions#  Install machine independent text files (man pages, dtrace scripts, etc.)
509*e3723e1fSApple OSS Distributions#
510*e3723e1fSApple OSS Distributions
511*e3723e1fSApple OSS Distributionsgenerated_top_level_textfiles_install_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
512*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
513*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_textfiles_install_mi))
514*e3723e1fSApple OSS Distributionsendif
515*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_textfiles_install_mi))
516*e3723e1fSApple OSS Distributions
517*e3723e1fSApple OSS Distributionsinstall_textfiles_mi: textfiles_install_mi_bootstrap
518*e3723e1fSApple OSS Distributions
519*e3723e1fSApple OSS Distributions#
520*e3723e1fSApple OSS Distributions#  Install machine dependent text files (man pages, dtrace scripts, etc.)
521*e3723e1fSApple OSS Distributions#
522*e3723e1fSApple OSS Distributions
523*e3723e1fSApple OSS Distributionsgenerated_top_level_textfiles_install_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install_md,,setup,,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
524*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
525*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_textfiles_install_md))
526*e3723e1fSApple OSS Distributionsendif
527*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_textfiles_install_md))
528*e3723e1fSApple OSS Distributions
529*e3723e1fSApple OSS Distributionsinstall_textfiles_md: textfiles_install_md_bootstrap
530*e3723e1fSApple OSS Distributions
531*e3723e1fSApple OSS Distributions#
532*e3723e1fSApple OSS Distributions# Build all architectures for all Configuration/Architecture options
533*e3723e1fSApple OSS Distributions#
534*e3723e1fSApple OSS Distributions
535*e3723e1fSApple OSS Distributionsgenerated_top_level_build_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_all,,setup exporthdrs,,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
536*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
537*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_all))
538*e3723e1fSApple OSS Distributionsendif
539*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_all))
540*e3723e1fSApple OSS Distributions
541*e3723e1fSApple OSS Distributions.PHONY: build
542*e3723e1fSApple OSS Distributions
543*e3723e1fSApple OSS Distributionsbuild: build_all_bootstrap
544*e3723e1fSApple OSS Distributions
545*e3723e1fSApple OSS Distributions#
546*e3723e1fSApple OSS Distributions# Post-process build results
547*e3723e1fSApple OSS Distributions#
548*e3723e1fSApple OSS Distributions
549*e3723e1fSApple OSS Distributionsgenerated_top_level_config_all = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_all,,setup,build_all,$(KERNEL_BUILDS_IN_PARALLEL),$(BUILD_CONFIGS))
550*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
551*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_config_all))
552*e3723e1fSApple OSS Distributionsendif
553*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_config_all))
554*e3723e1fSApple OSS Distributions
555*e3723e1fSApple OSS Distributions.PHONY: all config
556*e3723e1fSApple OSS Distributions
557*e3723e1fSApple OSS Distributionsall config: config_all_bootstrap
558*e3723e1fSApple OSS Distributions
559*e3723e1fSApple OSS Distributions.PHONY: all_embedded all_release_embedded all_development_embedded
560*e3723e1fSApple OSS Distributions.PHONY: all_desktop all_release_desktop all_development_desktop
561*e3723e1fSApple OSS Distributions
562*e3723e1fSApple OSS Distributionsall_embedded all_release_embedded all_development_embedded: all
563*e3723e1fSApple OSS Distributionsall_desktop all_release_desktop all_development_desktop: all
564*e3723e1fSApple OSS Distributions
565*e3723e1fSApple OSS Distributions#
566*e3723e1fSApple OSS Distributions# Install kernel files
567*e3723e1fSApple OSS Distributions#
568*e3723e1fSApple OSS Distributions
569*e3723e1fSApple OSS Distributionsgenerated_top_level_build_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,build_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
570*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
571*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_install_primary))
572*e3723e1fSApple OSS Distributionsendif
573*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_install_primary))
574*e3723e1fSApple OSS Distributions
575*e3723e1fSApple OSS Distributions.PHONY: install_primary
576*e3723e1fSApple OSS Distributions
577*e3723e1fSApple OSS Distributionsinstall_primary: build_install_primary_bootstrap
578*e3723e1fSApple OSS Distributions
579*e3723e1fSApple OSS Distributionsgenerated_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))
580*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
581*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_build_install_non_primary))
582*e3723e1fSApple OSS Distributionsendif
583*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_build_install_non_primary))
584*e3723e1fSApple OSS Distributions
585*e3723e1fSApple OSS Distributions.PHONY: install_non_primary
586*e3723e1fSApple OSS Distributions
587*e3723e1fSApple OSS Distributionsinstall_non_primary: build_install_non_primary_bootstrap
588*e3723e1fSApple OSS Distributions
589*e3723e1fSApple OSS Distributionsgenerated_top_level_config_install_primary = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install_primary,,setup,config_all,1,$(PRIMARY_BUILD_CONFIGS))
590*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
591*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_config_install_primary))
592*e3723e1fSApple OSS Distributionsendif
593*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_config_install_primary))
594*e3723e1fSApple OSS Distributions
595*e3723e1fSApple OSS Distributions.PHONY: install_config_primary
596*e3723e1fSApple OSS Distributions
597*e3723e1fSApple OSS Distributionsinstall_config_primary: config_install_primary_bootstrap
598*e3723e1fSApple OSS Distributions
599*e3723e1fSApple OSS Distributions# config_install_variant iterates through products from all BUILD_CONFIGS so depends on config_all having completed overall
600*e3723e1fSApple OSS Distributionsgenerated_top_level_config_install_variant = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install_variant,,config_all_bootstrap,,1,$(VARIANT_CONFIGS))
601*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
602*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_config_install_variant))
603*e3723e1fSApple OSS Distributionsendif
604*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_config_install_variant))
605*e3723e1fSApple OSS Distributions
606*e3723e1fSApple OSS Distributions.PHONY: install_config_variant
607*e3723e1fSApple OSS Distributions
608*e3723e1fSApple OSS Distributionsinstall_config_variant: config_install_variant_bootstrap
609*e3723e1fSApple OSS Distributions
610*e3723e1fSApple OSS Distributions# config_install iterates through products from all BUILD_CONFIGS so depends on config_all having completed overall
611*e3723e1fSApple OSS Distributionsgenerated_top_level_config_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,config_install,,config_all_bootstrap,,1,$(FIRST_BUILD_CONFIG))
612*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
613*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_config_install))
614*e3723e1fSApple OSS Distributionsendif
615*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_config_install))
616*e3723e1fSApple OSS Distributions
617*e3723e1fSApple OSS Distributions.PHONY: install_config final_touch_config_timestamps
618*e3723e1fSApple OSS Distributions
619*e3723e1fSApple OSS Distributionsinstall_config: config_install_bootstrap install_config_primary install_config_variant final_touch_config_timestamps
620*e3723e1fSApple OSS Distributions
621*e3723e1fSApple OSS Distributions
622*e3723e1fSApple OSS Distributions# Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
623*e3723e1fSApple OSS Distributionsfinal_touch_config_timestamps: config_install_bootstrap install_config_primary install_config_variant
624*e3723e1fSApple OSS Distributions	$(_v)$(TOUCH) $(OBJROOT)/.symbolset.timestamp
625*e3723e1fSApple OSS Distributions
626*e3723e1fSApple OSS Distributions#
627*e3723e1fSApple OSS Distributions# Aggregate install targets, which install everything appropriate for the current build alias/make target
628*e3723e1fSApple OSS Distributions#
629*e3723e1fSApple OSS Distributions
630*e3723e1fSApple OSS Distributions.PHONY: install
631*e3723e1fSApple OSS Distributions
632*e3723e1fSApple OSS Distributionsifneq ($(filter $(RC_ProjectName),xnu_debug),)
633*e3723e1fSApple OSS Distributionsinstall: install_kernels
634*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
635*e3723e1fSApple OSS Distributionsinstall: install_config install_kernels
636*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_headers_Sim),)
637*e3723e1fSApple OSS Distributionsinstall: installhdrs
638*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_headers_host),)
639*e3723e1fSApple OSS Distributionsinstall: installhdrs
640*e3723e1fSApple OSS Distributionsexport INSTALLHDRS_SKIP_HOST=YES
641*e3723e1fSApple OSS Distributionsexport INSTALLHDRS_MODULEMAPS_SKIP_HOST=YES
642*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_headers_driverkit),)
643*e3723e1fSApple OSS Distributionsinstall: installhdrs_desktop
644*e3723e1fSApple OSS Distributionselse ifneq ($(filter $(RC_ProjectName),xnu_headers_exclavekit xnu_headers_exclavecore),)
645*e3723e1fSApple OSS Distributionsinstall: installhdrs_desktop
646*e3723e1fSApple OSS Distributionsexport INSTALLHDRS_MODULEMAPS_SKIP_HOST=YES
647*e3723e1fSApple OSS Distributionsexport INSTALLHDRS_SKIP_HOST=YES
648*e3723e1fSApple OSS Distributionsexport EXPORTHDRS_SKIP_EXCLAVES=YES
649*e3723e1fSApple OSS Distributionselse
650*e3723e1fSApple OSS Distributions
651*e3723e1fSApple OSS Distributionsinstall: installhdrs install_textfiles install_config install_kernels install_aliases
652*e3723e1fSApple OSS Distributionsendif
653*e3723e1fSApple OSS Distributions
654*e3723e1fSApple OSS Distributions.PHONY: install_embedded install_release_embedded install_development_embedded
655*e3723e1fSApple OSS Distributions.PHONY: install_desktop install_release_desktop install_development_desktop
656*e3723e1fSApple OSS Distributions
657*e3723e1fSApple OSS Distributions# By default, all kernel files, headers, text files, and pseudo-kexts are installed
658*e3723e1fSApple OSS Distributionsinstall_embedded install_release_embedded install_desktop install_release_desktop: install
659*e3723e1fSApple OSS Distributions
660*e3723e1fSApple OSS Distributions# These special configs only install the kernel files
661*e3723e1fSApple OSS Distributionsinstall_development_embedded install_development_desktop: install_kernels install_aliases
662*e3723e1fSApple OSS Distributions
663*e3723e1fSApple OSS Distributions.PHONY: install_kernels final_touch_kernel_timestamps install_aliases
664*e3723e1fSApple OSS Distributions
665*e3723e1fSApple OSS Distributionsinstall_kernels: build_install_primary_bootstrap build_install_non_primary_bootstrap final_touch_kernel_timestamps
666*e3723e1fSApple OSS Distributions
667*e3723e1fSApple OSS Distributions# Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
668*e3723e1fSApple OSS Distributionsfinal_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
669*e3723e1fSApple OSS Distributions	$(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
670*e3723e1fSApple OSS Distributions	@echo "done building xnu"
671*e3723e1fSApple OSS Distributions
672*e3723e1fSApple OSS Distributions# Copy kernels that are aliases of another configuration
673*e3723e1fSApple OSS Distributionsgenerated_top_level_install_alias = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,install_alias,,install_kernels,,$(KERNEL_BUILDS_IN_PARALLEL),$(ALIAS_CONFIGS))
674*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
675*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_install_alias))
676*e3723e1fSApple OSS Distributionsendif
677*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_install_alias))
678*e3723e1fSApple OSS Distributions
679*e3723e1fSApple OSS Distributionsinstall_aliases: install_alias_bootstrap
680*e3723e1fSApple OSS Distributions
681*e3723e1fSApple OSS Distributions#
682*e3723e1fSApple OSS Distributions# Install source tree
683*e3723e1fSApple OSS Distributions#
684*e3723e1fSApple OSS Distributions.PHONY: installsrc
685*e3723e1fSApple OSS Distributions
686*e3723e1fSApple OSS Distributions
687*e3723e1fSApple OSS Distributionsifeq ($(CREATE_BRANCH_PATCH),)
688*e3723e1fSApple OSS Distributionsinstallsrc:
689*e3723e1fSApple OSS Distributions	@echo INSTALLSRC $(SRCROOT)
690*e3723e1fSApple OSS Distributions	$(_v)$(MKDIR) $(SRCROOT)
691*e3723e1fSApple OSS Distributions	$(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name compile_commands.json -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
692*e3723e1fSApple OSS Distributions	$(_v)$(CHMOD) -R go+rX $(SRCROOT)
693*e3723e1fSApple OSS Distributionsendif
694*e3723e1fSApple OSS Distributions
695*e3723e1fSApple OSS Distributions###############
696*e3723e1fSApple OSS Distributions# Open source #
697*e3723e1fSApple OSS Distributions###############
698*e3723e1fSApple OSS Distributions
699*e3723e1fSApple OSS Distributions
700*e3723e1fSApple OSS Distributions########
701*e3723e1fSApple OSS Distributions# Misc #
702*e3723e1fSApple OSS Distributions########
703*e3723e1fSApple OSS Distributions
704*e3723e1fSApple OSS Distributions#
705*e3723e1fSApple OSS Distributions# Clean up source tree
706*e3723e1fSApple OSS Distributions#
707*e3723e1fSApple OSS Distributions.PHONY: clean
708*e3723e1fSApple OSS Distributions
709*e3723e1fSApple OSS DistributionsCLEAN_RM_DIRS= $(OBJROOT) $(SYMROOT) $(DSTROOT) \
710*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/test/BUILD \
711*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/darwintests/build \
712*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/testkext/build \
713*e3723e1fSApple OSS Distributions		$(SRCROOT)/libkdd/build \
714*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/unit_tests/BUILD \
715*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/execperf/BUILD \
716*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/packetdrill/BUILD \
717*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/perf_index/BUILD
718*e3723e1fSApple OSS Distributions
719*e3723e1fSApple OSS DistributionsCLEAN_ACTION_DIRS= $(SRCROOT)/tools/tests/MPMMTest \
720*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/TLBcoherency \
721*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/kqueue_tests \
722*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/mktimer \
723*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/zero-to-n \
724*e3723e1fSApple OSS Distributions		$(SRCROOT)/tools/tests/personas
725*e3723e1fSApple OSS Distributions
726*e3723e1fSApple OSS Distributionsclean:
727*e3723e1fSApple OSS Distributions	@:
728*e3723e1fSApple OSS Distributions	$(_v)rm -f cscope.* 2> /dev/null
729*e3723e1fSApple OSS Distributions	$(_v)rm -f TAGS 2> /dev/null
730*e3723e1fSApple OSS Distributions	$(_v)for cdir in $(CLEAN_RM_DIRS); do \
731*e3723e1fSApple OSS Distributions		if [ -d $${cdir} ] ; then \
732*e3723e1fSApple OSS Distributions			echo "Removing $${cdir}"; \
733*e3723e1fSApple OSS Distributions			rm -fr $${cdir} 2> /dev/null  || true ; \
734*e3723e1fSApple OSS Distributions		fi ; \
735*e3723e1fSApple OSS Distributions	done
736*e3723e1fSApple OSS Distributions
737*e3723e1fSApple OSS Distributions	$(_v)for mcdir in $(CLEAN_ACTION_DIRS); do \
738*e3723e1fSApple OSS Distributions		make -C $${mcdir} clean; \
739*e3723e1fSApple OSS Distributions	done
740*e3723e1fSApple OSS Distributions
741*e3723e1fSApple OSS Distributions
742*e3723e1fSApple OSS Distributions#
743*e3723e1fSApple OSS Distributions# Build source file list for cscope database and tags
744*e3723e1fSApple OSS Distributions#
745*e3723e1fSApple OSS Distributions.PHONY: cscope.files
746*e3723e1fSApple OSS Distributions
747*e3723e1fSApple OSS Distributionscscope.files:
748*e3723e1fSApple OSS Distributions	@echo "Building file list for cscope and tags"
749*e3723e1fSApple OSS Distributions	@find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
750*e3723e1fSApple OSS Distributions	@find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
751*e3723e1fSApple OSS Distributions	@find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
752*e3723e1fSApple OSS Distributions	@find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
753*e3723e1fSApple OSS Distributions	@find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
754*e3723e1fSApple OSS Distributions	@find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
755*e3723e1fSApple OSS Distributions	@cat $(OBJROOT)/cscope.genhdrs/* >> _cscope.files 2> /dev/null || true
756*e3723e1fSApple OSS Distributions	@echo -k -q -c > cscope.files 2> /dev/null
757*e3723e1fSApple OSS Distributions	@sort -u < _cscope.files >> cscope.files 2> /dev/null
758*e3723e1fSApple OSS Distributions	@rm -f _cscope.files _cscope.files2 2> /dev/null
759*e3723e1fSApple OSS Distributions
760*e3723e1fSApple OSS Distributions#
761*e3723e1fSApple OSS Distributions# Build cscope database
762*e3723e1fSApple OSS Distributions#
763*e3723e1fSApple OSS Distributionscscope: cscope.files
764*e3723e1fSApple OSS Distributions	@echo "Building cscope database"
765*e3723e1fSApple OSS Distributions	@cscope -bvU 2> /dev/null
766*e3723e1fSApple OSS Distributions
767*e3723e1fSApple OSS Distributions#
768*e3723e1fSApple OSS Distributions# Build tags
769*e3723e1fSApple OSS Distributions#
770*e3723e1fSApple OSS Distributionstags: cscope.files
771*e3723e1fSApple OSS Distributions	@echo "Building ctags"
772*e3723e1fSApple OSS Distributions	@-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
773*e3723e1fSApple OSS Distributions		echo "Phantom files detected!" 2>&1 > /dev/null
774*e3723e1fSApple OSS Distributions	@-[ -f TAGS ] || ${MAKE} -f $(firstword $(MAKEFILE_LIST)) TAGS
775*e3723e1fSApple OSS Distributions
776*e3723e1fSApple OSS DistributionsTAGS: cscope.files
777*e3723e1fSApple OSS Distributions	@echo "Building etags"
778*e3723e1fSApple OSS Distributions	@-cat cscope.files | etags -l auto -S - 2> /dev/null
779*e3723e1fSApple OSS Distributions	@rm -f cscope.files 2> /dev/null
780*e3723e1fSApple OSS Distributions
781*e3723e1fSApple OSS Distributions
782*e3723e1fSApple OSS Distributions.PHONY: help
783*e3723e1fSApple OSS Distributions
784*e3723e1fSApple OSS Distributionshelp:
785*e3723e1fSApple OSS Distributions	@cat README.md
786*e3723e1fSApple OSS Distributions
787*e3723e1fSApple OSS Distributions.PHONY: print_exports
788*e3723e1fSApple OSS Distributions
789*e3723e1fSApple OSS Distributionsprint_exports:
790*e3723e1fSApple OSS Distributions	$(_v)printenv | sort
791*e3723e1fSApple OSS Distributions
792*e3723e1fSApple OSS Distributionsgenerated_top_level_print_exports = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,print_exports,,,,1,$(FIRST_BUILD_CONFIG))
793*e3723e1fSApple OSS Distributionsifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
794*e3723e1fSApple OSS Distributions$(warning Generate makefile fragment: $(generated_top_level_print_exports))
795*e3723e1fSApple OSS Distributionsendif
796*e3723e1fSApple OSS Distributions$(eval $(generated_top_level_print_exports))
797*e3723e1fSApple OSS Distributions
798*e3723e1fSApple OSS Distributions.PHONY: print_exports_first_build_config
799*e3723e1fSApple OSS Distributions
800*e3723e1fSApple OSS Distributionsprint_exports_first_build_config: print_exports_bootstrap
801*e3723e1fSApple OSS Distributions
802*e3723e1fSApple OSS Distributions
803*e3723e1fSApple OSS Distributions# vim: set ft=make:
804