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