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