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