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