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