]> git.saurik.com Git - apple/xnu.git/blame_incremental - Makefile
xnu-6153.11.26.tar.gz
[apple/xnu.git] / Makefile
... / ...
CommitLineData
1#
2# Copyright (C) 1999-2016 Apple Inc. All rights reserved.
3#
4ifndef VERSDIR
5export VERSDIR := $(shell /bin/pwd)
6endif
7
8ifndef SRCROOT
9export SRCROOT := $(shell /bin/pwd)
10endif
11ifndef OBJROOT
12export OBJROOT = $(SRCROOT)/BUILD/obj
13endif
14ifndef DSTROOT
15export DSTROOT = $(SRCROOT)/BUILD/dst
16endif
17ifndef SYMROOT
18export SYMROOT = $(SRCROOT)/BUILD/sym
19endif
20ifndef MallocNanoZone
21export MallocNanoZone := 1
22endif
23
24# Avoid make default rules, make becomes faster
25MAKEFLAGS+=r
26
27export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
28export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
29export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
30export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
31export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
32export 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
39ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
40
41include $(MakeInc_cmd)
42
43ifneq ($(findstring Libsyscall_,$(RC_ProjectName)),)
44TARGET=-target $(RC_ProjectName)
45endif
46
47default: install
48
49# default to OS X
50SDKROOT ?= macosx.internal
51
52installhdrs 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
62Libsyscall_driverkit: install
63
64.PHONY: Libsyscall_driverkit
65
66clean:
67
68installsrc:
69 pax -rw . $(SRCROOT)
70
71else ifeq ($(RC_ProjectName),libkxld)
72
73include $(MakeInc_cmd)
74
75default: install
76
77installhdrs install clean:
78 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
79
80installsrc:
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
85else ifeq ($(RC_ProjectName),libkxld_host)
86
87include $(MakeInc_cmd)
88
89default: install
90
91installhdrs install clean:
92 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
93
94installsrc:
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
99else ifeq ($(RC_ProjectName),libkmod)
100
101default: install
102
103installhdrs 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
113clean:
114
115installsrc:
116 pax -rw . $(SRCROOT)
117
118else ifeq ($(RC_ProjectName),xnu_tests)
119
120export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
121export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
122MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
123
124default: install
125
126installhdrs:
127
128install: xnu_tests
129
130clean:
131
132installsrc:
133 pax -rw . $(SRCROOT)
134
135else # all other RC_ProjectName
136
137ifndef CURRENT_BUILD_CONFIG
138
139# avoid having to include MakeInc.cmd
140ifeq ($(RC_XBS),YES)
141_v =
142else ifeq ($(VERBOSE),YES)
143_v =
144else
145_v = @
146endif
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#
153export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
154export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
155MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_LOGICALCPU) + 1)
156
157TOP_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
171DEFAULT_TARGET = all
172
173# Targets for internal build system debugging
174TOP_TARGETS += \
175 print_exports print_exports_first_build_config \
176 setup \
177 build \
178 config \
179 install_textfiles \
180 install_config
181
182ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
183MAKEARGS += -B
184DEFAULT_TARGET := build
185endif
186
187.PHONY: $(TOP_TARGETS)
188
189default: $(DEFAULT_TARGET)
190
191ifneq ($(REMOTEBUILD),)
192$(TOP_TARGETS):
193 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
194else
195$(TOP_TARGETS):
196 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
197endif
198
199else # CURRENT_BUILD_CONFIG
200
201include $(MakeInc_cmd)
202include $(MakeInc_def)
203
204ALL_SUBDIRS = \
205 security \
206 bsd \
207 iokit \
208 osfmk \
209 pexpert \
210 libkern \
211 libsa \
212 config \
213 san
214
215CONFIG_SUBDIRS = config tools san
216
217INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
218INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
219INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
220INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
221INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
222
223EXPINC_SUBDIRS = $(ALL_SUBDIRS)
224EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
225EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
226EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
227EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
228
229SETUP_SUBDIRS = SETUP san bsd
230
231COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
232COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
233COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
234COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
235
236INSTTEXTFILES_SUBDIRS = \
237 bsd
238
239include $(MakeInc_kernel)
240include $(MakeInc_rule)
241include $(MakeInc_dir)
242
243endif # CURRENT_BUILD_CONFIG
244
245endif # all other RC_ProjectName
246
247installapi_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
258installapi_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
269installapi_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
284xnu_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