]> git.saurik.com Git - apple/xnu.git/blame_incremental - Makefile
xnu-3789.1.32.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
20
21export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
22export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
23export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
24export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
25export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
26export 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
33ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
34
35ifeq ($(RC_ProjectName),Libsyscall_headers_Sim)
36TARGET=-target Libsyscall_headers_Sim
37endif
38
39default: install
40
41# default to OS X
42SDKROOT ?= macosx.internal
43
44installhdrs install:
45 cd libsyscall ; \
46 xcodebuild $@ $(TARGET) \
47 "SRCROOT=$(SRCROOT)/libsyscall" \
48 "OBJROOT=$(OBJROOT)" \
49 "SYMROOT=$(SYMROOT)" \
50 "DSTROOT=$(DSTROOT)" \
51 "SDKROOT=$(SDKROOT)"
52
53clean:
54
55installsrc:
56 pax -rw . $(SRCROOT)
57
58else ifeq ($(RC_ProjectName),libkxld)
59
60include $(MakeInc_cmd)
61
62default: install
63
64installhdrs install clean:
65 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
66
67installsrc:
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
72else ifeq ($(RC_ProjectName),libkxld_host)
73
74include $(MakeInc_cmd)
75
76default: install
77
78installhdrs install clean:
79 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
80
81installsrc:
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
86else ifeq ($(RC_ProjectName),libkmod)
87
88default: install
89
90installhdrs 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
99clean:
100
101installsrc:
102 pax -rw . $(SRCROOT)
103
104else ifeq ($(RC_ProjectName),xnu_tests)
105
106export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
107export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
108ifeq ($(SYSCTL_HW_PHYSICALCPU),$(SYSCTL_HW_LOGICALCPU))
109MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_PHYSICALCPU) + 1)
110else
111MAKEJOBS := --jobs=$(SYSCTL_HW_LOGICALCPU)
112endif
113
114default: install
115
116installhdrs:
117
118install: xnu_tests
119
120clean:
121
122installsrc:
123 pax -rw . $(SRCROOT)
124
125else # all other RC_ProjectName
126
127ifndef CURRENT_BUILD_CONFIG
128
129# avoid having to include MakeInc.cmd
130ifeq ($(RC_XBS),YES)
131_v =
132else ifeq ($(VERBOSE),YES)
133_v =
134else
135_v = @
136endif
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#
143export SYSCTL_HW_PHYSICALCPU := $(shell /usr/sbin/sysctl -n hw.physicalcpu)
144export SYSCTL_HW_LOGICALCPU := $(shell /usr/sbin/sysctl -n hw.logicalcpu)
145ifeq ($(SYSCTL_HW_PHYSICALCPU),$(SYSCTL_HW_LOGICALCPU))
146MAKEJOBS := --jobs=$(shell expr $(SYSCTL_HW_PHYSICALCPU) + 1)
147else
148MAKEJOBS := --jobs=$(SYSCTL_HW_LOGICALCPU)
149endif
150
151TOP_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
165DEFAULT_TARGET = all
166
167# Targets for internal build system debugging
168TOP_TARGETS += \
169 print_exports print_exports_first_build_config \
170 setup \
171 build \
172 config \
173 install_textfiles \
174 install_config
175
176ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
177MAKEARGS += -B
178DEFAULT_TARGET := build
179endif
180
181.PHONY: $(TOP_TARGETS)
182
183default: $(DEFAULT_TARGET)
184
185ifneq ($(REMOTEBUILD),)
186$(TOP_TARGETS):
187 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
188else
189$(TOP_TARGETS):
190 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
191endif
192
193else # CURRENT_BUILD_CONFIG
194
195include $(MakeInc_cmd)
196include $(MakeInc_def)
197
198ALL_SUBDIRS = \
199 bsd \
200 iokit \
201 osfmk \
202 pexpert \
203 libkern \
204 libsa \
205 security \
206 config
207
208CONFIG_SUBDIRS = config tools
209
210INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
211INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
212INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
213INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
214INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
215
216EXPINC_SUBDIRS = $(ALL_SUBDIRS)
217EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
218EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
219EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
220EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
221
222SETUP_SUBDIRS = SETUP
223
224COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
225COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
226COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
227COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
228
229INSTTEXTFILES_SUBDIRS = \
230 bsd
231
232include $(MakeInc_kernel)
233include $(MakeInc_rule)
234include $(MakeInc_dir)
235
236endif # CURRENT_BUILD_CONFIG
237
238endif # all other RC_ProjectName
239
240installhdrs_libkdd install_libkdd:
241 cd libkdd; \
242 xcodebuild -target libkdd $(subst _libkdd,,$@) \
243 "SRCROOT=$(SRCROOT)/libkdd" \
244 "OBJROOT=$(OBJROOT)" \
245 "SYMROOT=$(SYMROOT)" \
246 "DSTROOT=$(DSTROOT)" \
247 "SDKROOT=$(SDKROOT)"
248
249
250# "xnu_tests" and "testbots" are targets that can be invoked via a standalone
251# "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
252# Define the target here in the outermost scope of the initial Makefile
253
254xnu_tests:
255 $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
256 SRCROOT=$(SRCROOT)/tools/tests