]>
Commit | Line | Data |
---|---|---|
39236c6e | 1 | # |
2a1bd2d3 | 2 | # Copyright (C) 1999-2020 Apple Inc. All rights reserved. |
39236c6e | 3 | # |
1c79356b | 4 | ifndef VERSDIR |
39236c6e | 5 | export VERSDIR := $(shell /bin/pwd) |
1c79356b | 6 | endif |
39236c6e | 7 | |
9bccf70c | 8 | ifndef SRCROOT |
39236c6e | 9 | export SRCROOT := $(shell /bin/pwd) |
9bccf70c A |
10 | endif |
11 | ifndef OBJROOT | |
39236c6e | 12 | export OBJROOT = $(SRCROOT)/BUILD/obj |
9bccf70c A |
13 | endif |
14 | ifndef DSTROOT | |
39236c6e | 15 | export DSTROOT = $(SRCROOT)/BUILD/dst |
9bccf70c A |
16 | endif |
17 | ifndef SYMROOT | |
39236c6e | 18 | export SYMROOT = $(SRCROOT)/BUILD/sym |
9bccf70c | 19 | endif |
cb323159 A |
20 | ifndef MallocNanoZone |
21 | export MallocNanoZone := 1 | |
22 | endif | |
23 | ||
24 | # Avoid make default rules, make becomes faster | |
25 | MAKEFLAGS+=r | |
1c79356b | 26 | |
39236c6e A |
27 | export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top |
28 | export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel | |
1c79356b A |
29 | export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd |
30 | export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def | |
31 | export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule | |
32 | export MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir | |
33 | ||
a991bd8d | 34 | |
39236c6e A |
35 | # |
36 | # Dispatch non-xnu build aliases to their own build | |
37 | # systems. All xnu variants start with MakeInc_top. | |
38 | # | |
39 | ||
f427ee49 | 40 | ifneq ($(findstring Libsyscall,$(RC_ProjectName)),) |
39236c6e | 41 | |
cb323159 A |
42 | include $(MakeInc_cmd) |
43 | ||
f427ee49 A |
44 | ifeq ($(RC_ProjectName),Libsyscall_headers_Sim) |
45 | TARGET=-target Libsyscall_headers_Sim | |
46 | endif | |
47 | ||
48 | ifeq ($(RC_ProjectName),Libsyscall_driverkit) | |
49 | TARGET=-target Libsyscall_driverkit | |
39236c6e A |
50 | endif |
51 | ||
52 | default: install | |
53 | ||
39037602 A |
54 | # default to OS X |
55 | SDKROOT ?= macosx.internal | |
56 | ||
39236c6e A |
57 | installhdrs install: |
58 | cd libsyscall ; \ | |
59 | xcodebuild $@ $(TARGET) \ | |
cb323159 | 60 | $(MAKEOVERRIDES) \ |
39236c6e | 61 | "SRCROOT=$(SRCROOT)/libsyscall" \ |
39037602 A |
62 | "OBJROOT=$(OBJROOT)" \ |
63 | "SYMROOT=$(SYMROOT)" \ | |
39236c6e A |
64 | "DSTROOT=$(DSTROOT)" \ |
65 | "SDKROOT=$(SDKROOT)" | |
66 | ||
cb323159 A |
67 | Libsyscall_driverkit: install |
68 | ||
69 | .PHONY: Libsyscall_driverkit | |
70 | ||
39236c6e A |
71 | clean: |
72 | ||
73 | installsrc: | |
74 | pax -rw . $(SRCROOT) | |
75 | ||
f427ee49 | 76 | else ifneq ($(findstring libkxld_host,$(RC_ProjectName)),) |
39236c6e | 77 | |
fe8ab488 A |
78 | include $(MakeInc_cmd) |
79 | ||
39236c6e A |
80 | default: install |
81 | ||
82 | installhdrs install clean: | |
f427ee49 | 83 | $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE |
39236c6e A |
84 | |
85 | installsrc: | |
fe8ab488 A |
86 | $(_v)$(MKDIR) $(SRCROOT) |
87 | $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT) | |
88 | $(_v)$(CHMOD) -R go+rX $(SRCROOT) | |
39236c6e | 89 | |
f427ee49 | 90 | else ifneq ($(findstring libkxld,$(RC_ProjectName)),) |
39236c6e | 91 | |
fe8ab488 A |
92 | include $(MakeInc_cmd) |
93 | ||
39236c6e A |
94 | default: install |
95 | ||
96 | installhdrs install clean: | |
f427ee49 | 97 | $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all |
39236c6e A |
98 | |
99 | installsrc: | |
fe8ab488 A |
100 | $(_v)$(MKDIR) $(SRCROOT) |
101 | $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT) | |
102 | $(_v)$(CHMOD) -R go+rX $(SRCROOT) | |
39236c6e | 103 | |
f427ee49 | 104 | else ifneq ($(findstring libkmod,$(RC_ProjectName)),) |
39236c6e A |
105 | |
106 | default: install | |
107 | ||
108 | installhdrs install: | |
109 | cd libkern/kmod ; \ | |
39037602 | 110 | xcodebuild $@ \ |
cb323159 | 111 | $(MAKEOVERRIDES) \ |
39236c6e | 112 | "SRCROOT=$(SRCROOT)/libkern/kmod" \ |
39037602 A |
113 | "OBJROOT=$(OBJROOT)" \ |
114 | "SYMROOT=$(SYMROOT)" \ | |
39236c6e A |
115 | "DSTROOT=$(DSTROOT)" \ |
116 | "SDKROOT=$(SDKROOT)" | |
117 | ||
118 | clean: | |
119 | ||
4bd07ac2 A |
120 | installsrc: |
121 | pax -rw . $(SRCROOT) | |
122 | ||
f427ee49 | 123 | else ifneq ($(findstring xnu_tests,$(RC_ProjectName)),) |
39236c6e | 124 | |
39037602 A |
125 | export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu) |
126 | export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu) | |
cb323159 | 127 | MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1) |
39037602 | 128 | |
39236c6e A |
129 | default: install |
130 | ||
131 | installhdrs: | |
132 | ||
4bd07ac2 | 133 | install: xnu_tests |
39236c6e A |
134 | |
135 | clean: | |
136 | ||
f427ee49 A |
137 | installsrc: |
138 | pax -rw . $(SRCROOT) | |
139 | ||
140 | else ifeq ($(RC_ProjectName),xnu_tests_driverkit) | |
141 | ||
142 | export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu) | |
143 | export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu) | |
144 | MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1) | |
145 | ||
146 | default: install | |
147 | ||
148 | installhdrs: | |
149 | ||
150 | install: xnu_tests_driverkit | |
151 | ||
152 | clean: | |
153 | ||
39236c6e A |
154 | installsrc: |
155 | pax -rw . $(SRCROOT) | |
156 | ||
157 | else # all other RC_ProjectName | |
158 | ||
159 | ifndef CURRENT_BUILD_CONFIG | |
160 | ||
161 | # avoid having to include MakeInc.cmd | |
162 | ifeq ($(RC_XBS),YES) | |
163 | _v = | |
164 | else ifeq ($(VERBOSE),YES) | |
165 | _v = | |
166 | else | |
167 | _v = @ | |
168 | endif | |
169 | ||
170 | # | |
fe8ab488 A |
171 | # Setup for parallel sub-makes, taking into account physical and logical |
172 | # CPUs. If the system does not support SMT, use N+1. | |
39236c6e A |
173 | # If MAKEJOBS or -jN is passed on the make line, that takes precedence. |
174 | # | |
fe8ab488 A |
175 | export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu) |
176 | export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu) | |
cb323159 | 177 | MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1) |
39236c6e | 178 | |
f427ee49 A |
179 | TOP_TARGETS = \ |
180 | clean \ | |
181 | installsrc \ | |
182 | exporthdrs \ | |
183 | all all_desktop all_embedded \ | |
184 | all_release_embedded all_development_embedded \ | |
185 | installhdrs installhdrs_desktop installhdrs_embedded \ | |
186 | installhdrs_release_embedded installhdrs_development_embedded \ | |
187 | install install_desktop install_embedded \ | |
188 | install_release_embedded install_development_embedded \ | |
189 | install_kernels \ | |
a991bd8d | 190 | cscope tags TAGS \ |
fe8ab488 A |
191 | help |
192 | ||
3e170ce0 A |
193 | DEFAULT_TARGET = all |
194 | ||
fe8ab488 | 195 | # Targets for internal build system debugging |
f427ee49 A |
196 | TOP_TARGETS += \ |
197 | print_exports print_exports_first_build_config \ | |
198 | setup \ | |
199 | build \ | |
200 | config \ | |
201 | install_textfiles \ | |
fe8ab488 | 202 | install_config |
39236c6e | 203 | |
3e170ce0 A |
204 | ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1) |
205 | MAKEARGS += -B | |
206 | DEFAULT_TARGET := build | |
207 | endif | |
208 | ||
39236c6e A |
209 | .PHONY: $(TOP_TARGETS) |
210 | ||
3e170ce0 | 211 | default: $(DEFAULT_TARGET) |
39236c6e A |
212 | |
213 | ifneq ($(REMOTEBUILD),) | |
214 | $(TOP_TARGETS): | |
fe8ab488 | 215 | $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS) |
39236c6e A |
216 | else |
217 | $(TOP_TARGETS): | |
3e170ce0 | 218 | $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@ |
39236c6e A |
219 | endif |
220 | ||
221 | else # CURRENT_BUILD_CONFIG | |
1c79356b A |
222 | |
223 | include $(MakeInc_cmd) | |
224 | include $(MakeInc_def) | |
225 | ||
226 | ALL_SUBDIRS = \ | |
5ba3f43e | 227 | security \ |
39236c6e | 228 | bsd \ |
1c79356b A |
229 | iokit \ |
230 | osfmk \ | |
1c79356b A |
231 | pexpert \ |
232 | libkern \ | |
2d21ac55 | 233 | libsa \ |
5ba3f43e A |
234 | config \ |
235 | san | |
1c79356b | 236 | |
5ba3f43e | 237 | CONFIG_SUBDIRS = config tools san |
55e303ae | 238 | |
91447636 | 239 | INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS |
6d2010ae | 240 | INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS) |
fe8ab488 | 241 | INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS) |
6d2010ae | 242 | INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS) |
3e170ce0 | 243 | INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS) |
2d21ac55 | 244 | |
1c79356b | 245 | EXPINC_SUBDIRS = $(ALL_SUBDIRS) |
b0d623f7 | 246 | EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS) |
fe8ab488 | 247 | EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS) |
2d21ac55 | 248 | EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS) |
3e170ce0 | 249 | EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS) |
2d21ac55 | 250 | |
cb323159 | 251 | SETUP_SUBDIRS = SETUP san bsd |
b0d623f7 | 252 | |
b0d623f7 | 253 | COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS) |
fe8ab488 | 254 | COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS) |
b0d623f7 | 255 | COMP_SUBDIRS_ARM = $(ALL_SUBDIRS) |
3e170ce0 | 256 | COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS) |
55e303ae | 257 | |
fe8ab488 | 258 | INSTTEXTFILES_SUBDIRS = \ |
9bccf70c | 259 | bsd |
f427ee49 A |
260 | INSTTEXTFILES_SUBDIRS_X86_64 = $(INSTTEXTFILES_SUBDIRS) |
261 | INSTTEXTFILES_SUBDIRS_X86_64H = $(INSTTEXTFILES_SUBDIRS) | |
262 | INSTTEXTFILES_SUBDIRS_ARM = $(INSTTEXTFILES_SUBDIRS) | |
263 | INSTTEXTFILES_SUBDIRS_ARM64 = $(INSTTEXTFILES_SUBDIRS) | |
9bccf70c | 264 | |
39236c6e | 265 | include $(MakeInc_kernel) |
1c79356b A |
266 | include $(MakeInc_rule) |
267 | include $(MakeInc_dir) | |
6d2010ae | 268 | |
39236c6e A |
269 | endif # CURRENT_BUILD_CONFIG |
270 | ||
271 | endif # all other RC_ProjectName | |
272 | ||
a39ff7e2 | 273 | installapi_libkdd installhdrs_libkdd install_libkdd: |
3e170ce0 | 274 | cd libkdd; \ |
d9a64523 | 275 | xcodebuild -target Default $(subst _libkdd,,$@) \ |
cb323159 | 276 | $(MAKEOVERRIDES) \ |
d9a64523 A |
277 | "SRCROOT=$(SRCROOT)/libkdd" \ |
278 | "OBJROOT=$(OBJROOT)" \ | |
279 | "SYMROOT=$(SYMROOT)" \ | |
280 | "DSTROOT=$(DSTROOT)" \ | |
281 | "SDKROOT=$(SDKROOT)" | |
282 | ||
283 | ||
284 | installapi_libkdd_tests installhdrs_libkdd_tests install_libkdd_tests: | |
285 | cd libkdd; \ | |
286 | xcodebuild -target tests $(subst _libkdd_tests,,$@) \ | |
cb323159 | 287 | $(MAKEOVERRIDES) \ |
3e170ce0 | 288 | "SRCROOT=$(SRCROOT)/libkdd" \ |
39037602 A |
289 | "OBJROOT=$(OBJROOT)" \ |
290 | "SYMROOT=$(SYMROOT)" \ | |
3e170ce0 A |
291 | "DSTROOT=$(DSTROOT)" \ |
292 | "SDKROOT=$(SDKROOT)" | |
293 | ||
294 | ||
a39ff7e2 A |
295 | installapi_libkdd_host installhdrs_libkdd_host install_libkdd_host: |
296 | cd libkdd; \ | |
d9a64523 | 297 | xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@) \ |
cb323159 | 298 | $(MAKEOVERRIDES) \ |
a39ff7e2 A |
299 | "SRCROOT=$(SRCROOT)/libkdd" \ |
300 | "OBJROOT=$(OBJROOT)" \ | |
301 | "SYMROOT=$(SYMROOT)" \ | |
302 | "DSTROOT=$(DSTROOT)" \ | |
303 | "SDKROOT=$(SDKROOT)" | |
304 | ||
305 | ||
4bd07ac2 A |
306 | # "xnu_tests" and "testbots" are targets that can be invoked via a standalone |
307 | # "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests. | |
39236c6e A |
308 | # Define the target here in the outermost scope of the initial Makefile |
309 | ||
39037602 A |
310 | xnu_tests: |
311 | $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \ | |
39236c6e | 312 | SRCROOT=$(SRCROOT)/tools/tests |
d9a64523 A |
313 | $(MAKE) -C $(SRCROOT)/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \ |
314 | SRCROOT=$(SRCROOT)/tests | |
f427ee49 A |
315 | |
316 | xnu_tests_driverkit: | |
317 | $(MAKE) -C $(SRCROOT)/tests/driverkit $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \ | |
318 | SRCROOT=$(SRCROOT)/tests/driverkit | |
319 | ||
2a1bd2d3 | 320 | |
f427ee49 A |
321 | # |
322 | # The "analyze" target defined below invokes Clang Static Analyzer | |
323 | # with a predefined set of checks and options for the project. | |
324 | # | |
325 | ||
326 | # By default, analysis results are available in BUILD/StaticAnalyzer. | |
327 | # Set this variable in your make invocation to use a different directory. | |
328 | # Note that these results are only deleted when the build directory | |
329 | # is cleaned. They aren't deleted every time the analyzer is re-run, | |
330 | # but they are deleted after "make clean". | |
331 | STATIC_ANALYZER_OUTPUT_DIR ?= $(SRCROOT)/BUILD/StaticAnalyzer | |
332 | ||
333 | # By default, the default make target is analyzed. You can analyze | |
334 | # other targets by setting this variable in your make invocation. | |
335 | STATIC_ANALYZER_TARGET ?= | |
336 | ||
337 | # You can pass additional flags to scan-build by setting this variable | |
338 | # in your make invocation. For example, you can enable additional checks. | |
339 | STATIC_ANALYZER_EXTRA_FLAGS ?= | |
340 | ||
341 | analyze: | |
342 | # This is where the reports are going to be available. | |
343 | # Old reports are deleted on make clean only. | |
344 | mkdir -p $(STATIC_ANALYZER_OUTPUT_DIR) | |
345 | ||
346 | # Recursively build the requested target under scan-build. | |
347 | # Exclude checks that weren't deemed to be security critical, | |
348 | # like null pointer dereferences. | |
349 | xcrun scan-build -o $(STATIC_ANALYZER_OUTPUT_DIR) \ | |
350 | -disable-checker deadcode.DeadStores \ | |
351 | -disable-checker core.NullDereference \ | |
352 | -disable-checker core.DivideZero \ | |
353 | $(STATIC_ANALYZER_EXTRA_FLAGS) \ | |
354 | make $(STATIC_ANALYZER_TARGET) |