]> git.saurik.com Git - apple/xnu.git/blame - Makefile
xnu-3247.10.11.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)
103
104default: install
105
106installhdrs:
107
108install: xnu_quick_test
109
110clean:
111
112installsrc:
113 pax -rw . $(SRCROOT)
114
115else # all other RC_ProjectName
116
117ifndef CURRENT_BUILD_CONFIG
118
119# avoid having to include MakeInc.cmd
120ifeq ($(RC_XBS),YES)
121_v =
122else ifeq ($(VERBOSE),YES)
123_v =
124else
125_v = @
126endif
127
128#
fe8ab488
A
129# Setup for parallel sub-makes, taking into account physical and logical
130# CPUs. If the system does not support SMT, use N+1.
39236c6e
A
131# If MAKEJOBS or -jN is passed on the make line, that takes precedence.
132#
fe8ab488
A
133export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
134export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
135ifeq ($(SYSCTL_HW_PHYSICALCPU),$(SYSCTL_HW_LOGICALCPU))
136MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_PHYSICALCPU) + 1)
137else
138MAKEJOBS := --jobs=$(SYSCTL_HW_LOGICALCPU)
139endif
39236c6e 140
3e170ce0
A
141TOP_TARGETS = \
142 clean \
143 installsrc \
144 exporthdrs \
145 all all_desktop all_embedded \
146 all_release_embedded all_development_embedded \
147 installhdrs installhdrs_desktop installhdrs_embedded \
148 installhdrs_release_embedded installhdrs_development_embedded \
149 install install_desktop install_embedded \
150 install_release_embedded install_development_embedded \
151 installopensource \
152 cscope tags TAGS reindent \
fe8ab488
A
153 help
154
3e170ce0
A
155DEFAULT_TARGET = all
156
fe8ab488
A
157# Targets for internal build system debugging
158TOP_TARGETS += \
159 print_exports print_exports_first_build_config \
160 setup \
161 build \
162 config \
163 install_textfiles \
164 install_config
39236c6e 165
3e170ce0
A
166ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
167MAKEARGS += -B
168DEFAULT_TARGET := build
169endif
170
39236c6e
A
171.PHONY: $(TOP_TARGETS)
172
3e170ce0 173default: $(DEFAULT_TARGET)
39236c6e
A
174
175ifneq ($(REMOTEBUILD),)
176$(TOP_TARGETS):
fe8ab488 177 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
39236c6e
A
178else
179$(TOP_TARGETS):
3e170ce0 180 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
39236c6e
A
181endif
182
183else # CURRENT_BUILD_CONFIG
1c79356b
A
184
185include $(MakeInc_cmd)
186include $(MakeInc_def)
187
188ALL_SUBDIRS = \
39236c6e 189 bsd \
1c79356b
A
190 iokit \
191 osfmk \
1c79356b
A
192 pexpert \
193 libkern \
2d21ac55 194 libsa \
39236c6e
A
195 security \
196 config
1c79356b 197
39236c6e 198CONFIG_SUBDIRS = config tools
55e303ae 199
91447636 200INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
6d2010ae 201INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
fe8ab488 202INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
6d2010ae 203INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
3e170ce0 204INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
2d21ac55 205
1c79356b 206EXPINC_SUBDIRS = $(ALL_SUBDIRS)
b0d623f7 207EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
fe8ab488 208EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
2d21ac55 209EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
3e170ce0 210EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
2d21ac55 211
6d2010ae 212SETUP_SUBDIRS = SETUP
b0d623f7 213
b0d623f7 214COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
fe8ab488 215COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
b0d623f7 216COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
3e170ce0 217COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
55e303ae 218
fe8ab488 219INSTTEXTFILES_SUBDIRS = \
9bccf70c
A
220 bsd
221
39236c6e 222include $(MakeInc_kernel)
1c79356b
A
223include $(MakeInc_rule)
224include $(MakeInc_dir)
6d2010ae 225
39236c6e
A
226endif # CURRENT_BUILD_CONFIG
227
228endif # all other RC_ProjectName
229
3e170ce0
A
230installhdrs_libkdd install_libkdd:
231 cd libkdd; \
232 xcodebuild $(subst _libkdd,,$@) \
233 "SRCROOT=$(SRCROOT)/libkdd" \
234 "OBJROOT=$(OBJROOT)" \
235 "SYMROOT=$(SYMROOT)" \
236 "DSTROOT=$(DSTROOT)" \
237 "SDKROOT=$(SDKROOT)"
238
239
39236c6e
A
240# "xnu_quick_test" and "testbots" are targets that can be invoked via a standalone
241# "make xnu_quick_test" or via buildit/XBS with the RC_ProjectName=xnu_quick_test.
242# Define the target here in the outermost scope of the initial Makefile
243
244xnu_quick_test:
245 $(MAKE) -C $(SRCROOT)/tools/tests \
246 SRCROOT=$(SRCROOT)/tools/tests
247
6d2010ae
A
248# This target is defined to compile and run xnu_quick_test under testbots
249testbots:
39236c6e
A
250 $(MAKE) -C $(SRCROOT)/tools/tests/xnu_quick_test \
251 SRCROOT=$(SRCROOT)/tools/tests/xnu_quick_test \
252 MORECFLAGS="-DRUN_UNDER_TESTBOTS=1" \
253 MAKE=$(MAKE) \
254 testbots