xref: /xnu-10063.101.15/Makefile (revision 94d3b452840153a99b38a3a9659680b2a006908e)
1*94d3b452SApple OSS Distributions#
2*94d3b452SApple OSS Distributions# Copyright (C) 1999-2020 Apple Inc. All rights reserved.
3*94d3b452SApple OSS Distributions#
4*94d3b452SApple OSS Distributionsifndef VERSDIR
5*94d3b452SApple OSS Distributionsexport VERSDIR := $(shell /bin/pwd)
6*94d3b452SApple OSS Distributionsendif
7*94d3b452SApple OSS Distributions
8*94d3b452SApple OSS Distributionsifndef SRCROOT
9*94d3b452SApple OSS Distributionsexport SRCROOT := $(shell /bin/pwd)
10*94d3b452SApple OSS Distributionsendif
11*94d3b452SApple OSS Distributionsifndef OBJROOT
12*94d3b452SApple OSS Distributionsexport OBJROOT = $(SRCROOT)/BUILD/obj
13*94d3b452SApple OSS Distributionsendif
14*94d3b452SApple OSS Distributionsifndef DSTROOT
15*94d3b452SApple OSS Distributionsexport DSTROOT = $(SRCROOT)/BUILD/dst
16*94d3b452SApple OSS Distributionsendif
17*94d3b452SApple OSS Distributionsifndef SYMROOT
18*94d3b452SApple OSS Distributionsexport SYMROOT = $(SRCROOT)/BUILD/sym
19*94d3b452SApple OSS Distributionsendif
20*94d3b452SApple OSS Distributionsifndef MallocNanoZone
21*94d3b452SApple OSS Distributionsexport MallocNanoZone := 1
22*94d3b452SApple OSS Distributionsendif
23*94d3b452SApple OSS Distributions
24*94d3b452SApple OSS Distributions# Avoid make default rules, make becomes faster
25*94d3b452SApple OSS DistributionsMAKEFLAGS+=r
26*94d3b452SApple OSS Distributions
27*94d3b452SApple OSS Distributionsexport MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
28*94d3b452SApple OSS Distributionsexport MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
29*94d3b452SApple OSS Distributionsexport MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
30*94d3b452SApple OSS Distributionsexport MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
31*94d3b452SApple OSS Distributionsexport MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
32*94d3b452SApple OSS Distributionsexport MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir
33*94d3b452SApple OSS Distributions
34*94d3b452SApple OSS Distributions.DEFAULT_GOAL := default
35*94d3b452SApple OSS Distributions
36*94d3b452SApple OSS Distributionsexport PATCH_PREFIX ?= change-under-test_
37*94d3b452SApple OSS Distributionsexport PATCH_GLOB ?= $(PATCH_PREFIX)*.diff
38*94d3b452SApple OSS Distributions
39*94d3b452SApple OSS Distributions
40*94d3b452SApple OSS Distributionsskip:
41*94d3b452SApple OSS Distributions	@echo "Skipping $(RC_ProjectName)"
42*94d3b452SApple OSS Distributions
43*94d3b452SApple OSS Distributions.PHONY: skip
44*94d3b452SApple OSS Distributions
45*94d3b452SApple OSS Distributions#
46*94d3b452SApple OSS Distributions# Dispatch non-xnu build aliases to their own build
47*94d3b452SApple OSS Distributions# systems. All xnu variants start with MakeInc_top.
48*94d3b452SApple OSS Distributions#
49*94d3b452SApple OSS Distributions
50*94d3b452SApple OSS Distributionsifneq ($(findstring Libsyscall,$(RC_ProjectName)),)
51*94d3b452SApple OSS Distributions
52*94d3b452SApple OSS Distributionsinclude $(MakeInc_cmd)
53*94d3b452SApple OSS Distributionsinclude $(MakeInc_def)
54*94d3b452SApple OSS Distributionsinclude $(MakeInc_rule)
55*94d3b452SApple OSS Distributions
56*94d3b452SApple OSS Distributionsifeq ($(RC_ProjectName),Libsyscall_headers_Sim)
57*94d3b452SApple OSS DistributionsTARGET=-target Libsyscall_headers_Sim
58*94d3b452SApple OSS Distributionsendif
59*94d3b452SApple OSS Distributions
60*94d3b452SApple OSS Distributionsifeq ($(RC_ProjectName),Libsyscall_driverkit)
61*94d3b452SApple OSS DistributionsTARGET=-target Libsyscall_driverkit
62*94d3b452SApple OSS Distributionsendif
63*94d3b452SApple OSS Distributions
64*94d3b452SApple OSS Distributions# default to OS X
65*94d3b452SApple OSS DistributionsSDKROOT ?= macosx.internal
66*94d3b452SApple OSS Distributions
67*94d3b452SApple OSS Distributionsdefault: install
68*94d3b452SApple OSS Distributions
69*94d3b452SApple OSS DistributionsLibsyscall_driverkit: install
70*94d3b452SApple OSS Distributions
71*94d3b452SApple OSS Distributions.PHONY: Libsyscall_driverkit
72*94d3b452SApple OSS Distributions
73*94d3b452SApple OSS Distributionsinstallhdrs install::
74*94d3b452SApple OSS Distributions	cd libsyscall ; \
75*94d3b452SApple OSS Distributions		xcodebuild $@ $(TARGET)	\
76*94d3b452SApple OSS Distributions			$(MAKEOVERRIDES)	\
77*94d3b452SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libsyscall"					\
78*94d3b452SApple OSS Distributions			"OBJROOT=$(OBJROOT)"						\
79*94d3b452SApple OSS Distributions			"SYMROOT=$(SYMROOT)"						\
80*94d3b452SApple OSS Distributions			"DSTROOT=$(DSTROOT)"						\
81*94d3b452SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
82*94d3b452SApple OSS Distributions
83*94d3b452SApple OSS Distributionsinstallhdrs install:: do_unifdef_headers
84*94d3b452SApple OSS Distributions
85*94d3b452SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(INCDIR),$(SINCFRAME_UNIFDEF)))
86*94d3b452SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(LCLDIR),$(SPINCFRAME_UNIFDEF)))
87*94d3b452SApple OSS Distributionsifeq ($(DRIVERKIT),1)
88*94d3b452SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(DRIVERKITINCDIR),$(DKINCFRAME_UNIFDEF)))
89*94d3b452SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(DRIVERKITLCLDIR),$(DKPINCFRAME_UNIFDEF)))
90*94d3b452SApple OSS Distributionsendif
91*94d3b452SApple OSS Distributions
92*94d3b452SApple OSS Distributionsclean:
93*94d3b452SApple OSS Distributions
94*94d3b452SApple OSS Distributionsinstallsrc:
95*94d3b452SApple OSS Distributions	pax -rw . $(SRCROOT)
96*94d3b452SApple OSS Distributions
97*94d3b452SApple OSS Distributionselse ifneq ($(findstring libkxld_host,$(RC_ProjectName)),)
98*94d3b452SApple OSS Distributions
99*94d3b452SApple OSS Distributionsinclude $(MakeInc_cmd)
100*94d3b452SApple OSS Distributions
101*94d3b452SApple OSS Distributionsdefault: install
102*94d3b452SApple OSS Distributions
103*94d3b452SApple OSS Distributionsinstallhdrs install clean:
104*94d3b452SApple OSS Distributions	 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
105*94d3b452SApple OSS Distributions
106*94d3b452SApple OSS Distributionsinstallsrc:
107*94d3b452SApple OSS Distributions	$(_v)$(MKDIR) $(SRCROOT)
108*94d3b452SApple 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)
109*94d3b452SApple OSS Distributions	$(_v)$(CHMOD) -R go+rX $(SRCROOT)
110*94d3b452SApple OSS Distributions
111*94d3b452SApple OSS Distributionselse ifneq ($(findstring libkxld,$(RC_ProjectName)),)
112*94d3b452SApple OSS Distributions
113*94d3b452SApple OSS Distributionsinclude $(MakeInc_cmd)
114*94d3b452SApple OSS Distributions
115*94d3b452SApple OSS Distributionsdefault: install
116*94d3b452SApple OSS Distributions
117*94d3b452SApple OSS Distributionsinstallhdrs install clean:
118*94d3b452SApple OSS Distributions	 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
119*94d3b452SApple OSS Distributions
120*94d3b452SApple OSS Distributionsinstallsrc:
121*94d3b452SApple OSS Distributions	$(_v)$(MKDIR) $(SRCROOT)
122*94d3b452SApple OSS Distributions	$(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -name compile_commands.json -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT)
123*94d3b452SApple OSS Distributions	$(_v)$(CHMOD) -R go+rX $(SRCROOT)
124*94d3b452SApple OSS Distributions
125*94d3b452SApple OSS Distributionselse ifneq ($(findstring libkmod,$(RC_ProjectName)),)
126*94d3b452SApple OSS Distributions
127*94d3b452SApple OSS Distributionsdefault: install
128*94d3b452SApple OSS Distributions
129*94d3b452SApple OSS Distributionsinstallhdrs install:
130*94d3b452SApple OSS Distributions	cd libkern/kmod ; \
131*94d3b452SApple OSS Distributions		xcodebuild $@	\
132*94d3b452SApple OSS Distributions			$(MAKEOVERRIDES)	\
133*94d3b452SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkern/kmod"				\
134*94d3b452SApple OSS Distributions			"OBJROOT=$(OBJROOT)"						\
135*94d3b452SApple OSS Distributions			"SYMROOT=$(SYMROOT)"						\
136*94d3b452SApple OSS Distributions			"DSTROOT=$(DSTROOT)"						\
137*94d3b452SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
138*94d3b452SApple OSS Distributions
139*94d3b452SApple OSS Distributionsclean:
140*94d3b452SApple OSS Distributions
141*94d3b452SApple OSS Distributionsinstallsrc:
142*94d3b452SApple OSS Distributions	pax -rw . $(SRCROOT)
143*94d3b452SApple OSS Distributions
144*94d3b452SApple OSS Distributionselse ifneq ($(findstring xnu_tests,$(RC_ProjectName)),)
145*94d3b452SApple OSS Distributions
146*94d3b452SApple OSS Distributionsexport SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
147*94d3b452SApple OSS Distributionsexport SYSCTL_HW_LOGICALCPU  := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
148*94d3b452SApple OSS DistributionsMAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
149*94d3b452SApple OSS Distributions
150*94d3b452SApple OSS Distributionsdefault: install
151*94d3b452SApple OSS Distributions
152*94d3b452SApple OSS Distributionsinstallhdrs:
153*94d3b452SApple OSS Distributions
154*94d3b452SApple OSS Distributionsinstall: xnu_tests
155*94d3b452SApple OSS Distributions
156*94d3b452SApple OSS Distributionsclean:
157*94d3b452SApple OSS Distributions
158*94d3b452SApple OSS Distributionsinstallsrc:
159*94d3b452SApple OSS Distributions	pax -rw . $(SRCROOT)
160*94d3b452SApple OSS Distributions
161*94d3b452SApple OSS Distributionselse ifeq ($(RC_ProjectName),xnu_tests_driverkit)
162*94d3b452SApple OSS Distributions
163*94d3b452SApple OSS Distributionsexport SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
164*94d3b452SApple OSS Distributionsexport SYSCTL_HW_LOGICALCPU  := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
165*94d3b452SApple OSS DistributionsMAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
166*94d3b452SApple OSS Distributions
167*94d3b452SApple OSS Distributionsdefault: install
168*94d3b452SApple OSS Distributions
169*94d3b452SApple OSS Distributionsinstallhdrs:
170*94d3b452SApple OSS Distributions
171*94d3b452SApple OSS Distributionsinstall: xnu_tests_driverkit
172*94d3b452SApple OSS Distributions
173*94d3b452SApple OSS Distributionsclean:
174*94d3b452SApple OSS Distributions
175*94d3b452SApple OSS Distributionsinstallsrc:
176*94d3b452SApple OSS Distributions	pax -rw . $(SRCROOT)
177*94d3b452SApple OSS Distributions
178*94d3b452SApple OSS Distributionselse # all other RC_ProjectName
179*94d3b452SApple OSS Distributions
180*94d3b452SApple OSS Distributionsifndef CURRENT_BUILD_CONFIG
181*94d3b452SApple OSS Distributions
182*94d3b452SApple OSS Distributions# avoid having to include MakeInc.cmd
183*94d3b452SApple OSS Distributionsifeq ($(RC_XBS),YES)
184*94d3b452SApple OSS Distributions_v =
185*94d3b452SApple OSS Distributionselse ifeq ($(VERBOSE),YES)
186*94d3b452SApple OSS Distributions_v =
187*94d3b452SApple OSS Distributionselse
188*94d3b452SApple OSS Distributions_v = @
189*94d3b452SApple OSS Distributionsendif
190*94d3b452SApple OSS Distributions
191*94d3b452SApple OSS Distributions#
192*94d3b452SApple OSS Distributions# Setup for parallel sub-makes, taking into account physical and logical
193*94d3b452SApple OSS Distributions# CPUs. If the system does not support SMT, use N+1.
194*94d3b452SApple OSS Distributions# If MAKEJOBS or -jN is passed on the make line, that takes precedence.
195*94d3b452SApple OSS Distributions#
196*94d3b452SApple OSS Distributionsexport SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
197*94d3b452SApple OSS Distributionsexport SYSCTL_HW_LOGICALCPU  := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
198*94d3b452SApple OSS DistributionsMAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
199*94d3b452SApple OSS Distributions
200*94d3b452SApple OSS DistributionsTOP_TARGETS = \
201*94d3b452SApple OSS Distributions	clean \
202*94d3b452SApple OSS Distributions	installsrc \
203*94d3b452SApple OSS Distributions	exporthdrs \
204*94d3b452SApple OSS Distributions	all all_desktop all_embedded \
205*94d3b452SApple OSS Distributions	all_release_embedded all_development_embedded \
206*94d3b452SApple OSS Distributions	installhdrs installhdrs_desktop installhdrs_embedded \
207*94d3b452SApple OSS Distributions	installhdrs_release_embedded installhdrs_development_embedded \
208*94d3b452SApple OSS Distributions	install install_desktop install_embedded \
209*94d3b452SApple OSS Distributions	install_release_embedded install_development_embedded \
210*94d3b452SApple OSS Distributions	install_kernels \
211*94d3b452SApple OSS Distributions	cscope tags TAGS \
212*94d3b452SApple OSS Distributions	help
213*94d3b452SApple OSS Distributions
214*94d3b452SApple OSS DistributionsDEFAULT_TARGET = all
215*94d3b452SApple OSS Distributions
216*94d3b452SApple OSS Distributions# Targets for internal build system debugging
217*94d3b452SApple OSS DistributionsTOP_TARGETS += \
218*94d3b452SApple OSS Distributions	print_exports print_exports_first_build_config \
219*94d3b452SApple OSS Distributions	setup \
220*94d3b452SApple OSS Distributions	build \
221*94d3b452SApple OSS Distributions	config \
222*94d3b452SApple OSS Distributions	install_textfiles \
223*94d3b452SApple OSS Distributions	install_config
224*94d3b452SApple OSS Distributions
225*94d3b452SApple OSS Distributions.PHONY: $(TOP_TARGETS)
226*94d3b452SApple OSS Distributions
227*94d3b452SApple OSS Distributionsdefault: $(DEFAULT_TARGET)
228*94d3b452SApple OSS Distributions
229*94d3b452SApple OSS Distributionsifneq ($(REMOTEBUILD),)
230*94d3b452SApple OSS Distributions$(TOP_TARGETS):
231*94d3b452SApple OSS Distributions	$(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
232*94d3b452SApple OSS Distributionselse
233*94d3b452SApple OSS Distributions$(TOP_TARGETS):
234*94d3b452SApple OSS Distributions	$(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
235*94d3b452SApple OSS Distributionsendif
236*94d3b452SApple OSS Distributions
237*94d3b452SApple OSS Distributionselse # CURRENT_BUILD_CONFIG
238*94d3b452SApple OSS Distributions
239*94d3b452SApple OSS Distributionsinclude $(MakeInc_cmd)
240*94d3b452SApple OSS Distributionsinclude $(MakeInc_def)
241*94d3b452SApple OSS Distributions
242*94d3b452SApple OSS DistributionsALL_SUBDIRS = \
243*94d3b452SApple OSS Distributions	security \
244*94d3b452SApple OSS Distributions	bsd  \
245*94d3b452SApple OSS Distributions	iokit \
246*94d3b452SApple OSS Distributions	osfmk \
247*94d3b452SApple OSS Distributions	pexpert \
248*94d3b452SApple OSS Distributions	libkern \
249*94d3b452SApple OSS Distributions	libsa \
250*94d3b452SApple OSS Distributions	config \
251*94d3b452SApple OSS Distributions	san
252*94d3b452SApple OSS Distributions
253*94d3b452SApple OSS DistributionsCONFIG_SUBDIRS = config tools san
254*94d3b452SApple OSS Distributions# Hack to handle san external dependency on config_all allsymbols target
255*94d3b452SApple OSS Distributionsconfig_all_recurse_into_san: config_all_recurse_into_config
256*94d3b452SApple OSS Distributions
257*94d3b452SApple OSS DistributionsINSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
258*94d3b452SApple OSS DistributionsINSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
259*94d3b452SApple OSS DistributionsINSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
260*94d3b452SApple OSS DistributionsINSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
261*94d3b452SApple OSS DistributionsINSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
262*94d3b452SApple OSS Distributions
263*94d3b452SApple OSS DistributionsEXPINC_SUBDIRS = $(ALL_SUBDIRS)
264*94d3b452SApple OSS DistributionsEXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
265*94d3b452SApple OSS DistributionsEXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
266*94d3b452SApple OSS DistributionsEXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
267*94d3b452SApple OSS DistributionsEXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
268*94d3b452SApple OSS Distributions
269*94d3b452SApple OSS DistributionsSETUP_SUBDIRS = SETUP san bsd
270*94d3b452SApple OSS Distributions
271*94d3b452SApple OSS DistributionsCOMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
272*94d3b452SApple OSS DistributionsCOMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
273*94d3b452SApple OSS DistributionsCOMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
274*94d3b452SApple OSS DistributionsCOMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
275*94d3b452SApple OSS Distributions
276*94d3b452SApple OSS DistributionsINSTTEXTFILES_SUBDIRS =	\
277*94d3b452SApple OSS Distributions	bsd
278*94d3b452SApple OSS DistributionsINSTTEXTFILES_SUBDIRS_X86_64 = $(INSTTEXTFILES_SUBDIRS)
279*94d3b452SApple OSS DistributionsINSTTEXTFILES_SUBDIRS_X86_64H = $(INSTTEXTFILES_SUBDIRS)
280*94d3b452SApple OSS DistributionsINSTTEXTFILES_SUBDIRS_ARM = $(INSTTEXTFILES_SUBDIRS)
281*94d3b452SApple OSS DistributionsINSTTEXTFILES_SUBDIRS_ARM64 = $(INSTTEXTFILES_SUBDIRS)
282*94d3b452SApple OSS Distributions
283*94d3b452SApple OSS Distributionsinclude $(MakeInc_kernel)
284*94d3b452SApple OSS Distributionsinclude $(MakeInc_rule)
285*94d3b452SApple OSS Distributionsinclude $(MakeInc_dir)
286*94d3b452SApple OSS Distributions
287*94d3b452SApple OSS Distributionsendif # CURRENT_BUILD_CONFIG
288*94d3b452SApple OSS Distributions
289*94d3b452SApple OSS Distributionsendif # all other RC_ProjectName
290*94d3b452SApple OSS Distributions
291*94d3b452SApple OSS Distributionsinstallapi_libkdd installhdrs_libkdd install_libkdd:
292*94d3b452SApple OSS Distributions	cd libkdd; \
293*94d3b452SApple OSS Distributions		xcodebuild -target Default $(subst _libkdd,,$@)	\
294*94d3b452SApple OSS Distributions			$(MAKEOVERRIDES)	\
295*94d3b452SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkdd"		\
296*94d3b452SApple OSS Distributions			"OBJROOT=$(OBJROOT)"			\
297*94d3b452SApple OSS Distributions			"SYMROOT=$(SYMROOT)"			\
298*94d3b452SApple OSS Distributions			"DSTROOT=$(DSTROOT)"			\
299*94d3b452SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
300*94d3b452SApple OSS Distributions
301*94d3b452SApple OSS Distributions
302*94d3b452SApple OSS Distributionsinstallapi_libkdd_tests installhdrs_libkdd_tests install_libkdd_tests:
303*94d3b452SApple OSS Distributions	cd libkdd; \
304*94d3b452SApple OSS Distributions		xcodebuild -target tests $(subst _libkdd_tests,,$@)	\
305*94d3b452SApple OSS Distributions			$(MAKEOVERRIDES)	\
306*94d3b452SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkdd"		\
307*94d3b452SApple OSS Distributions			"OBJROOT=$(OBJROOT)"			\
308*94d3b452SApple OSS Distributions			"SYMROOT=$(SYMROOT)"			\
309*94d3b452SApple OSS Distributions			"DSTROOT=$(DSTROOT)"			\
310*94d3b452SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
311*94d3b452SApple OSS Distributions
312*94d3b452SApple OSS Distributions
313*94d3b452SApple OSS Distributionsinstallapi_libkdd_host installhdrs_libkdd_host install_libkdd_host:
314*94d3b452SApple OSS Distributions	cd libkdd; \
315*94d3b452SApple OSS Distributions		xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@)	\
316*94d3b452SApple OSS Distributions			$(MAKEOVERRIDES)	\
317*94d3b452SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkdd"		\
318*94d3b452SApple OSS Distributions			"OBJROOT=$(OBJROOT)"			\
319*94d3b452SApple OSS Distributions			"SYMROOT=$(SYMROOT)"			\
320*94d3b452SApple OSS Distributions			"DSTROOT=$(DSTROOT)"			\
321*94d3b452SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
322*94d3b452SApple OSS Distributions
323*94d3b452SApple OSS Distributions
324*94d3b452SApple OSS Distributions# "xnu_tests" and "testbots" are targets that can be invoked via a standalone
325*94d3b452SApple OSS Distributions# "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
326*94d3b452SApple OSS Distributions# Define the target here in the outermost scope of the initial Makefile
327*94d3b452SApple OSS Distributions
328*94d3b452SApple OSS Distributionsxnu_tests:
329*94d3b452SApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tools/tests	$(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
330*94d3b452SApple OSS Distributions		SRCROOT=$(SRCROOT)/tools/tests
331*94d3b452SApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tests	$(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
332*94d3b452SApple OSS Distributions		SRCROOT=$(SRCROOT)/tests
333*94d3b452SApple OSS Distributions
334*94d3b452SApple OSS Distributionsxnu_tests_driverkit:
335*94d3b452SApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tests/driverkit $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
336*94d3b452SApple OSS Distributions		SRCROOT=$(SRCROOT)/tests/driverkit
337*94d3b452SApple OSS Distributions
338*94d3b452SApple OSS Distributions
339*94d3b452SApple OSS Distributionsinclude $(MakeInc_cmd)
340*94d3b452SApple OSS Distributions
341*94d3b452SApple OSS Distributions#
342*94d3b452SApple OSS Distributions# The "analyze" target defined below invokes Clang Static Analyzer
343*94d3b452SApple OSS Distributions# with a predefined set of checks and options for the project.
344*94d3b452SApple OSS Distributions#
345*94d3b452SApple OSS Distributions
346*94d3b452SApple OSS Distributions# By default, analysis results are available in BUILD/StaticAnalyzer.
347*94d3b452SApple OSS Distributions# Set this variable in your make invocation to use a different directory.
348*94d3b452SApple OSS Distributions# Note that these results are only deleted when the build directory
349*94d3b452SApple OSS Distributions# is cleaned. They aren't deleted every time the analyzer is re-run,
350*94d3b452SApple OSS Distributions# but they are deleted after "make clean".
351*94d3b452SApple OSS DistributionsSTATIC_ANALYZER_OUTPUT_DIR ?= $(SRCROOT)/BUILD/StaticAnalyzer
352*94d3b452SApple OSS Distributions
353*94d3b452SApple OSS Distributions# By default, the default make target is analyzed. You can analyze
354*94d3b452SApple OSS Distributions# other targets by setting this variable in your make invocation.
355*94d3b452SApple OSS DistributionsSTATIC_ANALYZER_TARGET ?=
356*94d3b452SApple OSS Distributions
357*94d3b452SApple OSS Distributions# You can pass additional flags to scan-build by setting this variable
358*94d3b452SApple OSS Distributions# in your make invocation. For example, you can enable additional checks.
359*94d3b452SApple OSS DistributionsSTATIC_ANALYZER_EXTRA_FLAGS ?=
360*94d3b452SApple OSS Distributions
361*94d3b452SApple OSS Distributionsanalyze:
362*94d3b452SApple OSS Distributions# This is where the reports are going to be available.
363*94d3b452SApple OSS Distributions# Old reports are deleted on make clean only.
364*94d3b452SApple OSS Distributions	$(_v)$(MKDIR) $(STATIC_ANALYZER_OUTPUT_DIR)
365*94d3b452SApple OSS Distributions
366*94d3b452SApple OSS Distributions# Recursively build the requested target under scan-build.
367*94d3b452SApple OSS Distributions# Exclude checks that weren't deemed to be security critical,
368*94d3b452SApple OSS Distributions# like null pointer dereferences.
369*94d3b452SApple OSS Distributions	$(_v)$(XCRUN) $(SCAN_BUILD) -o $(STATIC_ANALYZER_OUTPUT_DIR) \
370*94d3b452SApple OSS Distributions		-disable-checker deadcode.DeadStores \
371*94d3b452SApple OSS Distributions		-disable-checker core.NullDereference \
372*94d3b452SApple OSS Distributions		-disable-checker core.DivideZero \
373*94d3b452SApple OSS Distributions		--exclude BUILD \
374*94d3b452SApple OSS Distributions		$(STATIC_ANALYZER_EXTRA_FLAGS) \
375*94d3b452SApple OSS Distributions		$(MAKE) $(STATIC_ANALYZER_TARGET) QUIET=1 2>&1 | $(GREP) "^scan-build:"
376*94d3b452SApple OSS Distributions
377*94d3b452SApple OSS Distributions.PHONY: analyze
378