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