]>
Commit | Line | Data |
---|---|---|
39236c6e | 1 | # |
39037602 | 2 | # Copyright (C) 1999-2016 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 | ||
39236c6e A |
34 | # |
35 | # Dispatch non-xnu build aliases to their own build | |
36 | # systems. All xnu variants start with MakeInc_top. | |
37 | # | |
38 | ||
39 | ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall) | |
40 | ||
cb323159 A |
41 | include $(MakeInc_cmd) |
42 | ||
43 | ifneq ($(findstring Libsyscall_,$(RC_ProjectName)),) | |
44 | TARGET=-target $(RC_ProjectName) | |
39236c6e A |
45 | endif |
46 | ||
47 | default: install | |
48 | ||
39037602 A |
49 | # default to OS X |
50 | SDKROOT ?= macosx.internal | |
51 | ||
39236c6e A |
52 | installhdrs install: |
53 | cd libsyscall ; \ | |
54 | xcodebuild $@ $(TARGET) \ | |
cb323159 | 55 | $(MAKEOVERRIDES) \ |
39236c6e | 56 | "SRCROOT=$(SRCROOT)/libsyscall" \ |
39037602 A |
57 | "OBJROOT=$(OBJROOT)" \ |
58 | "SYMROOT=$(SYMROOT)" \ | |
39236c6e A |
59 | "DSTROOT=$(DSTROOT)" \ |
60 | "SDKROOT=$(SDKROOT)" | |
61 | ||
cb323159 A |
62 | Libsyscall_driverkit: install |
63 | ||
64 | .PHONY: Libsyscall_driverkit | |
65 | ||
39236c6e A |
66 | clean: |
67 | ||
68 | installsrc: | |
69 | pax -rw . $(SRCROOT) | |
70 | ||
71 | else ifeq ($(RC_ProjectName),libkxld) | |
72 | ||
fe8ab488 A |
73 | include $(MakeInc_cmd) |
74 | ||
39236c6e A |
75 | default: install |
76 | ||
77 | installhdrs install clean: | |
78 | $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all | |
79 | ||
80 | installsrc: | |
fe8ab488 A |
81 | $(_v)$(MKDIR) $(SRCROOT) |
82 | $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT) | |
83 | $(_v)$(CHMOD) -R go+rX $(SRCROOT) | |
39236c6e A |
84 | |
85 | else ifeq ($(RC_ProjectName),libkxld_host) | |
86 | ||
fe8ab488 A |
87 | include $(MakeInc_cmd) |
88 | ||
39236c6e A |
89 | default: install |
90 | ||
91 | installhdrs install clean: | |
92 | $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE | |
93 | ||
94 | installsrc: | |
fe8ab488 A |
95 | $(_v)$(MKDIR) $(SRCROOT) |
96 | $(_v)$(FIND) -x . \! \( \( -name BUILD -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -print0 | $(PAX) -rw -p a -d0 $(SRCROOT) | |
97 | $(_v)$(CHMOD) -R go+rX $(SRCROOT) | |
39236c6e A |
98 | |
99 | else ifeq ($(RC_ProjectName),libkmod) | |
100 | ||
101 | default: install | |
102 | ||
103 | installhdrs install: | |
104 | cd libkern/kmod ; \ | |
39037602 | 105 | xcodebuild $@ \ |
cb323159 | 106 | $(MAKEOVERRIDES) \ |
39236c6e | 107 | "SRCROOT=$(SRCROOT)/libkern/kmod" \ |
39037602 A |
108 | "OBJROOT=$(OBJROOT)" \ |
109 | "SYMROOT=$(SYMROOT)" \ | |
39236c6e A |
110 | "DSTROOT=$(DSTROOT)" \ |
111 | "SDKROOT=$(SDKROOT)" | |
112 | ||
113 | clean: | |
114 | ||
4bd07ac2 A |
115 | installsrc: |
116 | pax -rw . $(SRCROOT) | |
117 | ||
118 | else ifeq ($(RC_ProjectName),xnu_tests) | |
39236c6e | 119 | |
39037602 A |
120 | export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu) |
121 | export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu) | |
cb323159 | 122 | MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1) |
39037602 | 123 | |
39236c6e A |
124 | default: install |
125 | ||
126 | installhdrs: | |
127 | ||
4bd07ac2 | 128 | install: xnu_tests |
39236c6e A |
129 | |
130 | clean: | |
131 | ||
132 | installsrc: | |
133 | pax -rw . $(SRCROOT) | |
134 | ||
135 | else # all other RC_ProjectName | |
136 | ||
137 | ifndef CURRENT_BUILD_CONFIG | |
138 | ||
139 | # avoid having to include MakeInc.cmd | |
140 | ifeq ($(RC_XBS),YES) | |
141 | _v = | |
142 | else ifeq ($(VERBOSE),YES) | |
143 | _v = | |
144 | else | |
145 | _v = @ | |
146 | endif | |
147 | ||
148 | # | |
fe8ab488 A |
149 | # Setup for parallel sub-makes, taking into account physical and logical |
150 | # CPUs. If the system does not support SMT, use N+1. | |
39236c6e A |
151 | # If MAKEJOBS or -jN is passed on the make line, that takes precedence. |
152 | # | |
fe8ab488 A |
153 | export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu) |
154 | export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu) | |
cb323159 | 155 | MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1) |
39236c6e | 156 | |
39037602 A |
157 | TOP_TARGETS = \ |
158 | clean \ | |
159 | installsrc \ | |
160 | exporthdrs \ | |
3e170ce0 | 161 | all all_desktop all_embedded \ |
39037602 A |
162 | all_release_embedded all_development_embedded \ |
163 | installhdrs installhdrs_desktop installhdrs_embedded \ | |
164 | installhdrs_release_embedded installhdrs_development_embedded \ | |
165 | install install_desktop install_embedded \ | |
166 | install_release_embedded install_development_embedded \ | |
167 | installopensource \ | |
0a7de745 | 168 | cscope tags TAGS checkstyle restyle check_uncrustify uncrustify \ |
fe8ab488 A |
169 | help |
170 | ||
3e170ce0 A |
171 | DEFAULT_TARGET = all |
172 | ||
fe8ab488 | 173 | # Targets for internal build system debugging |
39037602 | 174 | TOP_TARGETS += \ |
fe8ab488 | 175 | print_exports print_exports_first_build_config \ |
39037602 | 176 | setup \ |
fe8ab488 A |
177 | build \ |
178 | config \ | |
179 | install_textfiles \ | |
180 | install_config | |
39236c6e | 181 | |
3e170ce0 A |
182 | ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1) |
183 | MAKEARGS += -B | |
184 | DEFAULT_TARGET := build | |
185 | endif | |
186 | ||
39236c6e A |
187 | .PHONY: $(TOP_TARGETS) |
188 | ||
3e170ce0 | 189 | default: $(DEFAULT_TARGET) |
39236c6e A |
190 | |
191 | ifneq ($(REMOTEBUILD),) | |
192 | $(TOP_TARGETS): | |
fe8ab488 | 193 | $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS) |
39236c6e A |
194 | else |
195 | $(TOP_TARGETS): | |
3e170ce0 | 196 | $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@ |
39236c6e A |
197 | endif |
198 | ||
199 | else # CURRENT_BUILD_CONFIG | |
1c79356b A |
200 | |
201 | include $(MakeInc_cmd) | |
202 | include $(MakeInc_def) | |
203 | ||
204 | ALL_SUBDIRS = \ | |
5ba3f43e | 205 | security \ |
39236c6e | 206 | bsd \ |
1c79356b A |
207 | iokit \ |
208 | osfmk \ | |
1c79356b A |
209 | pexpert \ |
210 | libkern \ | |
2d21ac55 | 211 | libsa \ |
5ba3f43e A |
212 | config \ |
213 | san | |
1c79356b | 214 | |
5ba3f43e | 215 | CONFIG_SUBDIRS = config tools san |
55e303ae | 216 | |
91447636 | 217 | INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS |
6d2010ae | 218 | INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS) |
fe8ab488 | 219 | INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS) |
6d2010ae | 220 | INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS) |
3e170ce0 | 221 | INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS) |
2d21ac55 | 222 | |
1c79356b | 223 | EXPINC_SUBDIRS = $(ALL_SUBDIRS) |
b0d623f7 | 224 | EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS) |
fe8ab488 | 225 | EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS) |
2d21ac55 | 226 | EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS) |
3e170ce0 | 227 | EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS) |
2d21ac55 | 228 | |
cb323159 | 229 | SETUP_SUBDIRS = SETUP san bsd |
b0d623f7 | 230 | |
b0d623f7 | 231 | COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS) |
fe8ab488 | 232 | COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS) |
b0d623f7 | 233 | COMP_SUBDIRS_ARM = $(ALL_SUBDIRS) |
3e170ce0 | 234 | COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS) |
55e303ae | 235 | |
fe8ab488 | 236 | INSTTEXTFILES_SUBDIRS = \ |
9bccf70c A |
237 | bsd |
238 | ||
39236c6e | 239 | include $(MakeInc_kernel) |
1c79356b A |
240 | include $(MakeInc_rule) |
241 | include $(MakeInc_dir) | |
6d2010ae | 242 | |
39236c6e A |
243 | endif # CURRENT_BUILD_CONFIG |
244 | ||
245 | endif # all other RC_ProjectName | |
246 | ||
a39ff7e2 | 247 | installapi_libkdd installhdrs_libkdd install_libkdd: |
3e170ce0 | 248 | cd libkdd; \ |
d9a64523 | 249 | xcodebuild -target Default $(subst _libkdd,,$@) \ |
cb323159 | 250 | $(MAKEOVERRIDES) \ |
d9a64523 A |
251 | "SRCROOT=$(SRCROOT)/libkdd" \ |
252 | "OBJROOT=$(OBJROOT)" \ | |
253 | "SYMROOT=$(SYMROOT)" \ | |
254 | "DSTROOT=$(DSTROOT)" \ | |
255 | "SDKROOT=$(SDKROOT)" | |
256 | ||
257 | ||
258 | installapi_libkdd_tests installhdrs_libkdd_tests install_libkdd_tests: | |
259 | cd libkdd; \ | |
260 | xcodebuild -target tests $(subst _libkdd_tests,,$@) \ | |
cb323159 | 261 | $(MAKEOVERRIDES) \ |
3e170ce0 | 262 | "SRCROOT=$(SRCROOT)/libkdd" \ |
39037602 A |
263 | "OBJROOT=$(OBJROOT)" \ |
264 | "SYMROOT=$(SYMROOT)" \ | |
3e170ce0 A |
265 | "DSTROOT=$(DSTROOT)" \ |
266 | "SDKROOT=$(SDKROOT)" | |
267 | ||
268 | ||
a39ff7e2 A |
269 | installapi_libkdd_host installhdrs_libkdd_host install_libkdd_host: |
270 | cd libkdd; \ | |
d9a64523 | 271 | xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@) \ |
cb323159 | 272 | $(MAKEOVERRIDES) \ |
a39ff7e2 A |
273 | "SRCROOT=$(SRCROOT)/libkdd" \ |
274 | "OBJROOT=$(OBJROOT)" \ | |
275 | "SYMROOT=$(SYMROOT)" \ | |
276 | "DSTROOT=$(DSTROOT)" \ | |
277 | "SDKROOT=$(SDKROOT)" | |
278 | ||
279 | ||
4bd07ac2 A |
280 | # "xnu_tests" and "testbots" are targets that can be invoked via a standalone |
281 | # "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests. | |
39236c6e A |
282 | # Define the target here in the outermost scope of the initial Makefile |
283 | ||
39037602 A |
284 | xnu_tests: |
285 | $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \ | |
39236c6e | 286 | SRCROOT=$(SRCROOT)/tools/tests |
d9a64523 A |
287 | $(MAKE) -C $(SRCROOT)/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \ |
288 | SRCROOT=$(SRCROOT)/tests |