xref: /xnu-11215/Makefile (revision 8d741a5d)
1186b8fceSApple OSS Distributions#
2e6231be0SApple OSS Distributions# Copyright (C) 1999-2020 Apple Inc. All rights reserved.
3186b8fceSApple OSS Distributions#
4c1dac77fSApple OSS Distributionsifndef VERSDIR
5186b8fceSApple OSS Distributionsexport VERSDIR := $(shell /bin/pwd)
6fad439e7SApple OSS Distributionsendif
7c1dac77fSApple OSS Distributions
8186b8fceSApple OSS Distributionsifndef SRCROOT
9186b8fceSApple OSS Distributionsexport SRCROOT := $(shell /bin/pwd)
10186b8fceSApple OSS Distributionsendif
11186b8fceSApple OSS Distributionsifndef OBJROOT
12186b8fceSApple OSS Distributionsexport OBJROOT = $(SRCROOT)/BUILD/obj
13186b8fceSApple OSS Distributionsendif
14186b8fceSApple OSS Distributionsifndef DSTROOT
15186b8fceSApple OSS Distributionsexport DSTROOT = $(SRCROOT)/BUILD/dst
16186b8fceSApple OSS Distributionsendif
17186b8fceSApple OSS Distributionsifndef SYMROOT
18186b8fceSApple OSS Distributionsexport SYMROOT = $(SRCROOT)/BUILD/sym
19186b8fceSApple OSS Distributionsendif
20a5e72196SApple OSS Distributionsifndef MallocNanoZone
21a5e72196SApple OSS Distributionsexport MallocNanoZone := 1
22a5e72196SApple OSS Distributionsendif
23a5e72196SApple OSS Distributions
24a5e72196SApple OSS Distributions# Avoid make default rules, make becomes faster
25a5e72196SApple OSS DistributionsMAKEFLAGS+=r
26186b8fceSApple OSS Distributions
27186b8fceSApple OSS Distributionsexport MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
28186b8fceSApple OSS Distributionsexport MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
29c1dac77fSApple OSS Distributionsexport MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
30c1dac77fSApple OSS Distributionsexport MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
31c1dac77fSApple OSS Distributionsexport MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
32c1dac77fSApple OSS Distributionsexport MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir
33c1dac77fSApple OSS Distributions
34e6231be0SApple OSS Distributions.DEFAULT_GOAL := default
35e6231be0SApple OSS Distributions
36e6231be0SApple OSS Distributionsexport PATCH_PREFIX ?= change-under-test_
37e6231be0SApple OSS Distributionsexport PATCH_GLOB ?= $(PATCH_PREFIX)*.diff
38e6231be0SApple OSS Distributions
39e6231be0SApple OSS Distributions
40e6231be0SApple OSS Distributionsskip:
41e6231be0SApple OSS Distributions	@echo "Skipping $(RC_ProjectName)"
42e6231be0SApple OSS Distributions
43e6231be0SApple OSS Distributions.PHONY: skip
44e6231be0SApple OSS Distributions
45186b8fceSApple OSS Distributions#
46186b8fceSApple OSS Distributions# Dispatch non-xnu build aliases to their own build
47186b8fceSApple OSS Distributions# systems. All xnu variants start with MakeInc_top.
48186b8fceSApple OSS Distributions#
49186b8fceSApple OSS Distributions
50bb611c8fSApple OSS Distributionsifneq ($(findstring Libsyscall,$(RC_ProjectName)),)
51186b8fceSApple OSS Distributions
52a5e72196SApple OSS Distributionsinclude $(MakeInc_cmd)
53e6231be0SApple OSS Distributionsinclude $(MakeInc_def)
54e6231be0SApple OSS Distributionsinclude $(MakeInc_rule)
55a5e72196SApple OSS Distributions
56bb611c8fSApple OSS Distributionsifeq ($(RC_ProjectName),Libsyscall_headers_Sim)
57bb611c8fSApple OSS DistributionsTARGET=-target Libsyscall_headers_Sim
58bb611c8fSApple OSS Distributionsendif
59bb611c8fSApple OSS Distributions
60bb611c8fSApple OSS Distributionsifeq ($(RC_ProjectName),Libsyscall_driverkit)
61bb611c8fSApple OSS DistributionsTARGET=-target Libsyscall_driverkit
62186b8fceSApple OSS Distributionsendif
63186b8fceSApple OSS Distributions
6488cc0b97SApple OSS Distributions# default to OS X
6588cc0b97SApple OSS DistributionsSDKROOT ?= macosx.internal
6688cc0b97SApple OSS Distributions
67e6231be0SApple OSS Distributionsdefault: install
68e6231be0SApple OSS Distributions
69e6231be0SApple OSS DistributionsLibsyscall_driverkit: install
70e6231be0SApple OSS Distributions
71e6231be0SApple OSS Distributions.PHONY: Libsyscall_driverkit
72e6231be0SApple OSS Distributions
73e6231be0SApple OSS Distributionsinstallhdrs install::
74186b8fceSApple OSS Distributions	cd libsyscall ; \
75186b8fceSApple OSS Distributions		xcodebuild $@ $(TARGET)	\
76a5e72196SApple OSS Distributions			$(MAKEOVERRIDES)	\
77186b8fceSApple OSS Distributions			"SRCROOT=$(SRCROOT)/libsyscall"					\
78186b8fceSApple OSS Distributions			"OBJROOT=$(OBJROOT)"						\
79186b8fceSApple OSS Distributions			"SYMROOT=$(SYMROOT)"						\
80186b8fceSApple OSS Distributions			"DSTROOT=$(DSTROOT)"						\
81186b8fceSApple OSS Distributions			"SDKROOT=$(SDKROOT)"
82186b8fceSApple OSS Distributions
83e6231be0SApple OSS Distributionsinstallhdrs install:: do_unifdef_headers
84a5e72196SApple OSS Distributions
85e6231be0SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(INCDIR),$(SINCFRAME_UNIFDEF)))
86e6231be0SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(LCLDIR),$(SPINCFRAME_UNIFDEF)))
87e6231be0SApple OSS Distributionsifeq ($(DRIVERKIT),1)
88e6231be0SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(DRIVERKITINCDIR),$(DKINCFRAME_UNIFDEF)))
89e6231be0SApple OSS Distributions$(eval $(call LIBSYSCALL_DO_UNIFDEF_HEADERS_RULE_template,$(DSTROOT)/$(DRIVERKITLCLDIR),$(DKPINCFRAME_UNIFDEF)))
90e6231be0SApple OSS Distributionsendif
91a5e72196SApple OSS Distributions
92186b8fceSApple OSS Distributionsclean:
93186b8fceSApple OSS Distributions
94186b8fceSApple OSS Distributionsinstallsrc:
95186b8fceSApple OSS Distributions	pax -rw . $(SRCROOT)
96186b8fceSApple OSS Distributions
97bb611c8fSApple OSS Distributionselse ifneq ($(findstring libkxld_host,$(RC_ProjectName)),)
98186b8fceSApple OSS Distributions
99a3bb9fccSApple OSS Distributionsinclude $(MakeInc_cmd)
100a3bb9fccSApple OSS Distributions
101186b8fceSApple OSS Distributionsdefault: install
102186b8fceSApple OSS Distributions
103186b8fceSApple OSS Distributionsinstallhdrs install clean:
104186b8fceSApple OSS Distributions	 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
105186b8fceSApple OSS Distributions
106186b8fceSApple OSS Distributionsinstallsrc:
107a3bb9fccSApple OSS Distributions	$(_v)$(MKDIR) $(SRCROOT)
10894d3b452SApple 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)
109a3bb9fccSApple OSS Distributions	$(_v)$(CHMOD) -R go+rX $(SRCROOT)
110186b8fceSApple OSS Distributions
111bb611c8fSApple OSS Distributionselse ifneq ($(findstring libkxld,$(RC_ProjectName)),)
112bb611c8fSApple OSS Distributions
113bb611c8fSApple OSS Distributionsinclude $(MakeInc_cmd)
114bb611c8fSApple OSS Distributions
115bb611c8fSApple OSS Distributionsdefault: install
116bb611c8fSApple OSS Distributions
117bb611c8fSApple OSS Distributionsinstallhdrs install clean:
118bb611c8fSApple OSS Distributions	 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
119bb611c8fSApple OSS Distributions
120bb611c8fSApple OSS Distributionsinstallsrc:
121bb611c8fSApple OSS Distributions	$(_v)$(MKDIR) $(SRCROOT)
12294d3b452SApple 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)
123bb611c8fSApple OSS Distributions	$(_v)$(CHMOD) -R go+rX $(SRCROOT)
124bb611c8fSApple OSS Distributions
125bb611c8fSApple OSS Distributionselse ifneq ($(findstring libkmod,$(RC_ProjectName)),)
126186b8fceSApple OSS Distributions
127186b8fceSApple OSS Distributionsdefault: install
128186b8fceSApple OSS Distributions
129186b8fceSApple OSS Distributionsinstallhdrs install:
130186b8fceSApple OSS Distributions	cd libkern/kmod ; \
131186b8fceSApple OSS Distributions		xcodebuild $@	\
132a5e72196SApple OSS Distributions			$(MAKEOVERRIDES)	\
133186b8fceSApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkern/kmod"				\
134186b8fceSApple OSS Distributions			"OBJROOT=$(OBJROOT)"						\
135186b8fceSApple OSS Distributions			"SYMROOT=$(SYMROOT)"						\
136186b8fceSApple OSS Distributions			"DSTROOT=$(DSTROOT)"						\
137186b8fceSApple OSS Distributions			"SDKROOT=$(SDKROOT)"
138186b8fceSApple OSS Distributions
139186b8fceSApple OSS Distributionsclean:
140186b8fceSApple OSS Distributions
141186b8fceSApple OSS Distributionsinstallsrc:
142186b8fceSApple OSS Distributions	pax -rw . $(SRCROOT)
143186b8fceSApple OSS Distributions
144bb611c8fSApple OSS Distributionselse ifneq ($(findstring xnu_tests,$(RC_ProjectName)),)
145186b8fceSApple OSS Distributions
14688cc0b97SApple OSS Distributionsexport SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
14788cc0b97SApple OSS Distributionsexport SYSCTL_HW_LOGICALCPU  := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
148a5e72196SApple OSS DistributionsMAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
14988cc0b97SApple OSS Distributions
150186b8fceSApple OSS Distributionsdefault: install
151186b8fceSApple OSS Distributions
152186b8fceSApple OSS Distributionsinstallhdrs:
153186b8fceSApple OSS Distributions
1548dd02465SApple OSS Distributionsinstall: xnu_tests
155186b8fceSApple OSS Distributions
156186b8fceSApple OSS Distributionsclean:
157186b8fceSApple OSS Distributions
158186b8fceSApple OSS Distributionsinstallsrc:
159186b8fceSApple OSS Distributions	pax -rw . $(SRCROOT)
160186b8fceSApple OSS Distributions
161bb611c8fSApple OSS Distributionselse ifeq ($(RC_ProjectName),xnu_tests_driverkit)
162bb611c8fSApple OSS Distributions
163bb611c8fSApple OSS Distributionsexport SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
164bb611c8fSApple OSS Distributionsexport SYSCTL_HW_LOGICALCPU  := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
165bb611c8fSApple OSS DistributionsMAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
166bb611c8fSApple OSS Distributions
167bb611c8fSApple OSS Distributionsdefault: install
168bb611c8fSApple OSS Distributions
169bb611c8fSApple OSS Distributionsinstallhdrs:
170bb611c8fSApple OSS Distributions
171bb611c8fSApple OSS Distributionsinstall: xnu_tests_driverkit
172bb611c8fSApple OSS Distributions
173bb611c8fSApple OSS Distributionsclean:
174bb611c8fSApple OSS Distributions
175bb611c8fSApple OSS Distributionsinstallsrc:
176bb611c8fSApple OSS Distributions	pax -rw . $(SRCROOT)
177bb611c8fSApple OSS Distributions
178186b8fceSApple OSS Distributionselse # all other RC_ProjectName
179186b8fceSApple OSS Distributions
180186b8fceSApple OSS Distributionsifndef CURRENT_BUILD_CONFIG
181186b8fceSApple OSS Distributions
182186b8fceSApple OSS Distributions# avoid having to include MakeInc.cmd
183186b8fceSApple OSS Distributionsifeq ($(RC_XBS),YES)
184186b8fceSApple OSS Distributions_v =
185186b8fceSApple OSS Distributionselse ifeq ($(VERBOSE),YES)
186186b8fceSApple OSS Distributions_v =
187186b8fceSApple OSS Distributionselse
188186b8fceSApple OSS Distributions_v = @
189186b8fceSApple OSS Distributionsendif
190186b8fceSApple OSS Distributions
191186b8fceSApple OSS Distributions#
192a3bb9fccSApple OSS Distributions# Setup for parallel sub-makes, taking into account physical and logical
193a3bb9fccSApple OSS Distributions# CPUs. If the system does not support SMT, use N+1.
194186b8fceSApple OSS Distributions# If MAKEJOBS or -jN is passed on the make line, that takes precedence.
195186b8fceSApple OSS Distributions#
196a3bb9fccSApple OSS Distributionsexport SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
197a3bb9fccSApple OSS Distributionsexport SYSCTL_HW_LOGICALCPU  := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
198a5e72196SApple OSS DistributionsMAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
199186b8fceSApple OSS Distributions
200a3bb9fccSApple OSS DistributionsTOP_TARGETS = \
201a3bb9fccSApple OSS Distributions	clean \
202a3bb9fccSApple OSS Distributions	installsrc \
203a3bb9fccSApple OSS Distributions	exporthdrs \
204a3bb9fccSApple OSS Distributions	all all_desktop all_embedded \
205a3bb9fccSApple OSS Distributions	all_release_embedded all_development_embedded \
206*8d741a5dSApple OSS Distributions	all_release_desktop all_development_desktop \
207a3bb9fccSApple OSS Distributions	installhdrs installhdrs_desktop installhdrs_embedded \
208a3bb9fccSApple OSS Distributions	installhdrs_release_embedded installhdrs_development_embedded \
209*8d741a5dSApple OSS Distributions	installhdrs_release_desktop installhdrs_development_desktop \
210a3bb9fccSApple OSS Distributions	install install_desktop install_embedded \
211a3bb9fccSApple OSS Distributions	install_release_embedded install_development_embedded \
212*8d741a5dSApple OSS Distributions	install_release_desktop install_development_desktop \
213bb611c8fSApple OSS Distributions	install_kernels \
214e6231be0SApple OSS Distributions	cscope tags TAGS \
215a3bb9fccSApple OSS Distributions	help
216a3bb9fccSApple OSS Distributions
2170f3703acSApple OSS DistributionsDEFAULT_TARGET = all
2180f3703acSApple OSS Distributions
219a3bb9fccSApple OSS Distributions# Targets for internal build system debugging
220a3bb9fccSApple OSS DistributionsTOP_TARGETS += \
221a3bb9fccSApple OSS Distributions	print_exports print_exports_first_build_config \
222a3bb9fccSApple OSS Distributions	setup \
223a3bb9fccSApple OSS Distributions	build \
224a3bb9fccSApple OSS Distributions	config \
225a3bb9fccSApple OSS Distributions	install_textfiles \
226a3bb9fccSApple OSS Distributions	install_config
227186b8fceSApple OSS Distributions
228186b8fceSApple OSS Distributions.PHONY: $(TOP_TARGETS)
229186b8fceSApple OSS Distributions
2300f3703acSApple OSS Distributionsdefault: $(DEFAULT_TARGET)
231186b8fceSApple OSS Distributions
232186b8fceSApple OSS Distributionsifneq ($(REMOTEBUILD),)
233186b8fceSApple OSS Distributions$(TOP_TARGETS):
234a3bb9fccSApple OSS Distributions	$(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
235186b8fceSApple OSS Distributionselse
236186b8fceSApple OSS Distributions$(TOP_TARGETS):
2370f3703acSApple OSS Distributions	$(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
238186b8fceSApple OSS Distributionsendif
239186b8fceSApple OSS Distributions
240186b8fceSApple OSS Distributionselse # CURRENT_BUILD_CONFIG
241c1dac77fSApple OSS Distributions
242c1dac77fSApple OSS Distributionsinclude $(MakeInc_cmd)
243c1dac77fSApple OSS Distributionsinclude $(MakeInc_def)
244c1dac77fSApple OSS Distributions
245c1dac77fSApple OSS DistributionsALL_SUBDIRS = \
24676e12aa3SApple OSS Distributions	security \
247186b8fceSApple OSS Distributions	bsd  \
248c1dac77fSApple OSS Distributions	iokit \
249c1dac77fSApple OSS Distributions	osfmk \
250c1dac77fSApple OSS Distributions	pexpert \
251c1dac77fSApple OSS Distributions	libkern \
252e13b1fa5SApple OSS Distributions	libsa \
25376e12aa3SApple OSS Distributions	config \
25476e12aa3SApple OSS Distributions	san
255c1dac77fSApple OSS Distributions
25676e12aa3SApple OSS DistributionsCONFIG_SUBDIRS = config tools san
257e6231be0SApple OSS Distributions# Hack to handle san external dependency on config_all allsymbols target
258e6231be0SApple OSS Distributionsconfig_all_recurse_into_san: config_all_recurse_into_config
259368ad365SApple OSS Distributions
26014e3d835SApple OSS DistributionsINSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
261855239e5SApple OSS DistributionsINSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
262a3bb9fccSApple OSS DistributionsINSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
2630f3703acSApple OSS DistributionsINSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
264e13b1fa5SApple OSS Distributions
265c1dac77fSApple OSS DistributionsEXPINC_SUBDIRS = $(ALL_SUBDIRS)
2663ca3bd55SApple OSS DistributionsEXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
267a3bb9fccSApple OSS DistributionsEXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
2680f3703acSApple OSS DistributionsEXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
269e13b1fa5SApple OSS Distributions
270a5e72196SApple OSS DistributionsSETUP_SUBDIRS = SETUP san bsd
271c1dac77fSApple OSS Distributions
2723ca3bd55SApple OSS DistributionsCOMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
273a3bb9fccSApple OSS DistributionsCOMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
2740f3703acSApple OSS DistributionsCOMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
275368ad365SApple OSS Distributions
276a3bb9fccSApple OSS DistributionsINSTTEXTFILES_SUBDIRS =	\
277fad439e7SApple OSS Distributions	bsd
278bb611c8fSApple OSS DistributionsINSTTEXTFILES_SUBDIRS_X86_64 = $(INSTTEXTFILES_SUBDIRS)
279bb611c8fSApple OSS DistributionsINSTTEXTFILES_SUBDIRS_X86_64H = $(INSTTEXTFILES_SUBDIRS)
280bb611c8fSApple OSS DistributionsINSTTEXTFILES_SUBDIRS_ARM64 = $(INSTTEXTFILES_SUBDIRS)
281fad439e7SApple OSS Distributions
282186b8fceSApple OSS Distributionsinclude $(MakeInc_kernel)
283c1dac77fSApple OSS Distributionsinclude $(MakeInc_rule)
284c1dac77fSApple OSS Distributionsinclude $(MakeInc_dir)
285855239e5SApple OSS Distributions
286186b8fceSApple OSS Distributionsendif # CURRENT_BUILD_CONFIG
287186b8fceSApple OSS Distributions
288186b8fceSApple OSS Distributionsendif # all other RC_ProjectName
289186b8fceSApple OSS Distributions
290cc9a6355SApple OSS Distributionsinstallapi_libkdd installhdrs_libkdd install_libkdd:
2910f3703acSApple OSS Distributions	cd libkdd; \
292cc9a6355SApple OSS Distributions		xcodebuild -target Default $(subst _libkdd,,$@)	\
293a5e72196SApple OSS Distributions			$(MAKEOVERRIDES)	\
294cc9a6355SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkdd"		\
295cc9a6355SApple OSS Distributions			"OBJROOT=$(OBJROOT)"			\
296cc9a6355SApple OSS Distributions			"SYMROOT=$(SYMROOT)"			\
297cc9a6355SApple OSS Distributions			"DSTROOT=$(DSTROOT)"			\
298cc9a6355SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
299cc9a6355SApple OSS Distributions
300cc9a6355SApple OSS Distributions
301cc9a6355SApple OSS Distributionsinstallapi_libkdd_tests installhdrs_libkdd_tests install_libkdd_tests:
302cc9a6355SApple OSS Distributions	cd libkdd; \
303cc9a6355SApple OSS Distributions		xcodebuild -target tests $(subst _libkdd_tests,,$@)	\
304a5e72196SApple OSS Distributions			$(MAKEOVERRIDES)	\
305cc9a6355SApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkdd"		\
306cc9a6355SApple OSS Distributions			"OBJROOT=$(OBJROOT)"			\
307cc9a6355SApple OSS Distributions			"SYMROOT=$(SYMROOT)"			\
308cc9a6355SApple OSS Distributions			"DSTROOT=$(DSTROOT)"			\
309cc9a6355SApple OSS Distributions			"SDKROOT=$(SDKROOT)"
310cc9a6355SApple OSS Distributions
311cc9a6355SApple OSS Distributions
312cc9a6355SApple OSS Distributionsinstallapi_libkdd_host installhdrs_libkdd_host install_libkdd_host:
313cc9a6355SApple OSS Distributions	cd libkdd; \
314cc9a6355SApple OSS Distributions		xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@)	\
315a5e72196SApple OSS Distributions			$(MAKEOVERRIDES)	\
3160f3703acSApple OSS Distributions			"SRCROOT=$(SRCROOT)/libkdd"		\
3170f3703acSApple OSS Distributions			"OBJROOT=$(OBJROOT)"			\
3180f3703acSApple OSS Distributions			"SYMROOT=$(SYMROOT)"			\
3190f3703acSApple OSS Distributions			"DSTROOT=$(DSTROOT)"			\
3200f3703acSApple OSS Distributions			"SDKROOT=$(SDKROOT)"
3210f3703acSApple OSS Distributions
3220f3703acSApple OSS Distributions
3238dd02465SApple OSS Distributions# "xnu_tests" and "testbots" are targets that can be invoked via a standalone
3248dd02465SApple OSS Distributions# "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
325186b8fceSApple OSS Distributions# Define the target here in the outermost scope of the initial Makefile
326186b8fceSApple OSS Distributions
32788cc0b97SApple OSS Distributionsxnu_tests:
32888cc0b97SApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tools/tests	$(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
329186b8fceSApple OSS Distributions		SRCROOT=$(SRCROOT)/tools/tests
330cc9a6355SApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tests	$(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
331cc9a6355SApple OSS Distributions		SRCROOT=$(SRCROOT)/tests
332*8d741a5dSApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tools/lldbmacros/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
333*8d741a5dSApple OSS Distributions		SRCROOT=$(SRCROOT)/tools/lldbmacros
334bb611c8fSApple OSS Distributions
335bb611c8fSApple OSS Distributionsxnu_tests_driverkit:
336bb611c8fSApple OSS Distributions	$(MAKE) -C $(SRCROOT)/tests/driverkit $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
337bb611c8fSApple OSS Distributions		SRCROOT=$(SRCROOT)/tests/driverkit
338bb611c8fSApple OSS Distributions
339e6231be0SApple OSS Distributions
340e6231be0SApple OSS Distributionsinclude $(MakeInc_cmd)
341e6231be0SApple OSS Distributions
342bb611c8fSApple OSS Distributions#
343bb611c8fSApple OSS Distributions# The "analyze" target defined below invokes Clang Static Analyzer
344bb611c8fSApple OSS Distributions# with a predefined set of checks and options for the project.
345bb611c8fSApple OSS Distributions#
346bb611c8fSApple OSS Distributions
347bb611c8fSApple OSS Distributions# By default, analysis results are available in BUILD/StaticAnalyzer.
348bb611c8fSApple OSS Distributions# Set this variable in your make invocation to use a different directory.
349bb611c8fSApple OSS Distributions# Note that these results are only deleted when the build directory
350bb611c8fSApple OSS Distributions# is cleaned. They aren't deleted every time the analyzer is re-run,
351bb611c8fSApple OSS Distributions# but they are deleted after "make clean".
352bb611c8fSApple OSS DistributionsSTATIC_ANALYZER_OUTPUT_DIR ?= $(SRCROOT)/BUILD/StaticAnalyzer
353bb611c8fSApple OSS Distributions
354bb611c8fSApple OSS Distributions# By default, the default make target is analyzed. You can analyze
355bb611c8fSApple OSS Distributions# other targets by setting this variable in your make invocation.
356bb611c8fSApple OSS DistributionsSTATIC_ANALYZER_TARGET ?=
357bb611c8fSApple OSS Distributions
358bb611c8fSApple OSS Distributions# You can pass additional flags to scan-build by setting this variable
359bb611c8fSApple OSS Distributions# in your make invocation. For example, you can enable additional checks.
360bb611c8fSApple OSS DistributionsSTATIC_ANALYZER_EXTRA_FLAGS ?=
361bb611c8fSApple OSS Distributions
362bb611c8fSApple OSS Distributionsanalyze:
363bb611c8fSApple OSS Distributions# This is where the reports are going to be available.
364bb611c8fSApple OSS Distributions# Old reports are deleted on make clean only.
365e6231be0SApple OSS Distributions	$(_v)$(MKDIR) $(STATIC_ANALYZER_OUTPUT_DIR)
366bb611c8fSApple OSS Distributions
367bb611c8fSApple OSS Distributions# Recursively build the requested target under scan-build.
368bb611c8fSApple OSS Distributions# Exclude checks that weren't deemed to be security critical,
369bb611c8fSApple OSS Distributions# like null pointer dereferences.
370e6231be0SApple OSS Distributions	$(_v)$(XCRUN) $(SCAN_BUILD) -o $(STATIC_ANALYZER_OUTPUT_DIR) \
371bb611c8fSApple OSS Distributions		-disable-checker deadcode.DeadStores \
372bb611c8fSApple OSS Distributions		-disable-checker core.NullDereference \
373bb611c8fSApple OSS Distributions		-disable-checker core.DivideZero \
374e6231be0SApple OSS Distributions		--exclude BUILD \
375bb611c8fSApple OSS Distributions		$(STATIC_ANALYZER_EXTRA_FLAGS) \
376e6231be0SApple OSS Distributions		$(MAKE) $(STATIC_ANALYZER_TARGET) QUIET=1 2>&1 | $(GREP) "^scan-build:"
377e6231be0SApple OSS Distributions
378e6231be0SApple OSS Distributions.PHONY: analyze
379*8d741a5dSApple OSS Distributions
380*8d741a5dSApple OSS Distributions.PHONY: empty
381*8d741a5dSApple OSS Distributions
382*8d741a5dSApple OSS Distributions# Add an empty target which is useful for bringing up new build aliases
383*8d741a5dSApple OSS Distributions# Aliases can be created with this as their target, then later move to their
384*8d741a5dSApple OSS Distributions# required target in coordination with other aliases
385*8d741a5dSApple OSS Distributionsempty:
386*8d741a5dSApple OSS Distributions	$(_v)$(MKDIR) $(DSTROOT)/AppleInternal
387