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