]> git.saurik.com Git - apple/xnu.git/blob - Makefile
xnu-6153.11.26.tar.gz
[apple/xnu.git] / Makefile
1 #
2 # Copyright (C) 1999-2016 Apple Inc. All rights reserved.
3 #
4 ifndef VERSDIR
5 export VERSDIR := $(shell /bin/pwd)
6 endif
7
8 ifndef SRCROOT
9 export SRCROOT := $(shell /bin/pwd)
10 endif
11 ifndef OBJROOT
12 export OBJROOT = $(SRCROOT)/BUILD/obj
13 endif
14 ifndef DSTROOT
15 export DSTROOT = $(SRCROOT)/BUILD/dst
16 endif
17 ifndef SYMROOT
18 export SYMROOT = $(SRCROOT)/BUILD/sym
19 endif
20 ifndef MallocNanoZone
21 export MallocNanoZone := 1
22 endif
23
24 # Avoid make default rules, make becomes faster
25 MAKEFLAGS+=r
26
27 export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
28 export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
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
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
41 include $(MakeInc_cmd)
42
43 ifneq ($(findstring Libsyscall_,$(RC_ProjectName)),)
44 TARGET=-target $(RC_ProjectName)
45 endif
46
47 default: install
48
49 # default to OS X
50 SDKROOT ?= macosx.internal
51
52 installhdrs install:
53 cd libsyscall ; \
54 xcodebuild $@ $(TARGET) \
55 $(MAKEOVERRIDES) \
56 "SRCROOT=$(SRCROOT)/libsyscall" \
57 "OBJROOT=$(OBJROOT)" \
58 "SYMROOT=$(SYMROOT)" \
59 "DSTROOT=$(DSTROOT)" \
60 "SDKROOT=$(SDKROOT)"
61
62 Libsyscall_driverkit: install
63
64 .PHONY: Libsyscall_driverkit
65
66 clean:
67
68 installsrc:
69 pax -rw . $(SRCROOT)
70
71 else ifeq ($(RC_ProjectName),libkxld)
72
73 include $(MakeInc_cmd)
74
75 default: install
76
77 installhdrs install clean:
78 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
79
80 installsrc:
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)
84
85 else ifeq ($(RC_ProjectName),libkxld_host)
86
87 include $(MakeInc_cmd)
88
89 default: install
90
91 installhdrs install clean:
92 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
93
94 installsrc:
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)
98
99 else ifeq ($(RC_ProjectName),libkmod)
100
101 default: install
102
103 installhdrs install:
104 cd libkern/kmod ; \
105 xcodebuild $@ \
106 $(MAKEOVERRIDES) \
107 "SRCROOT=$(SRCROOT)/libkern/kmod" \
108 "OBJROOT=$(OBJROOT)" \
109 "SYMROOT=$(SYMROOT)" \
110 "DSTROOT=$(DSTROOT)" \
111 "SDKROOT=$(SDKROOT)"
112
113 clean:
114
115 installsrc:
116 pax -rw . $(SRCROOT)
117
118 else ifeq ($(RC_ProjectName),xnu_tests)
119
120 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
121 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
122 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
123
124 default: install
125
126 installhdrs:
127
128 install: xnu_tests
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 #
149 # Setup for parallel sub-makes, taking into account physical and logical
150 # CPUs. If the system does not support SMT, use N+1.
151 # If MAKEJOBS or -jN is passed on the make line, that takes precedence.
152 #
153 export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
154 export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
155 MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
156
157 TOP_TARGETS = \
158 clean \
159 installsrc \
160 exporthdrs \
161 all all_desktop all_embedded \
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 \
168 cscope tags TAGS checkstyle restyle check_uncrustify uncrustify \
169 help
170
171 DEFAULT_TARGET = all
172
173 # Targets for internal build system debugging
174 TOP_TARGETS += \
175 print_exports print_exports_first_build_config \
176 setup \
177 build \
178 config \
179 install_textfiles \
180 install_config
181
182 ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
183 MAKEARGS += -B
184 DEFAULT_TARGET := build
185 endif
186
187 .PHONY: $(TOP_TARGETS)
188
189 default: $(DEFAULT_TARGET)
190
191 ifneq ($(REMOTEBUILD),)
192 $(TOP_TARGETS):
193 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
194 else
195 $(TOP_TARGETS):
196 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
197 endif
198
199 else # CURRENT_BUILD_CONFIG
200
201 include $(MakeInc_cmd)
202 include $(MakeInc_def)
203
204 ALL_SUBDIRS = \
205 security \
206 bsd \
207 iokit \
208 osfmk \
209 pexpert \
210 libkern \
211 libsa \
212 config \
213 san
214
215 CONFIG_SUBDIRS = config tools san
216
217 INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
218 INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
219 INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
220 INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
221 INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
222
223 EXPINC_SUBDIRS = $(ALL_SUBDIRS)
224 EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
225 EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
226 EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
227 EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
228
229 SETUP_SUBDIRS = SETUP san bsd
230
231 COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
232 COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
233 COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
234 COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
235
236 INSTTEXTFILES_SUBDIRS = \
237 bsd
238
239 include $(MakeInc_kernel)
240 include $(MakeInc_rule)
241 include $(MakeInc_dir)
242
243 endif # CURRENT_BUILD_CONFIG
244
245 endif # all other RC_ProjectName
246
247 installapi_libkdd installhdrs_libkdd install_libkdd:
248 cd libkdd; \
249 xcodebuild -target Default $(subst _libkdd,,$@) \
250 $(MAKEOVERRIDES) \
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,,$@) \
261 $(MAKEOVERRIDES) \
262 "SRCROOT=$(SRCROOT)/libkdd" \
263 "OBJROOT=$(OBJROOT)" \
264 "SYMROOT=$(SYMROOT)" \
265 "DSTROOT=$(DSTROOT)" \
266 "SDKROOT=$(SDKROOT)"
267
268
269 installapi_libkdd_host installhdrs_libkdd_host install_libkdd_host:
270 cd libkdd; \
271 xcodebuild -configuration ReleaseHost -target kdd.framework $(subst _libkdd_host,,$@) \
272 $(MAKEOVERRIDES) \
273 "SRCROOT=$(SRCROOT)/libkdd" \
274 "OBJROOT=$(OBJROOT)" \
275 "SYMROOT=$(SYMROOT)" \
276 "DSTROOT=$(DSTROOT)" \
277 "SDKROOT=$(SDKROOT)"
278
279
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.
282 # Define the target here in the outermost scope of the initial Makefile
283
284 xnu_tests:
285 $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
286 SRCROOT=$(SRCROOT)/tools/tests
287 $(MAKE) -C $(SRCROOT)/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
288 SRCROOT=$(SRCROOT)/tests