]> git.saurik.com Git - apple/xnu.git/blame - Makefile
xnu-4570.51.1.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
1c79356b 20
39236c6e
A
21export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
22export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
1c79356b
A
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
39236c6e
A
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
39037602
A
41# default to OS X
42SDKROOT ?= macosx.internal
43
39236c6e
A
44installhdrs install:
45 cd libsyscall ; \
46 xcodebuild $@ $(TARGET) \
47 "SRCROOT=$(SRCROOT)/libsyscall" \
39037602
A
48 "OBJROOT=$(OBJROOT)" \
49 "SYMROOT=$(SYMROOT)" \
39236c6e
A
50 "DSTROOT=$(DSTROOT)" \
51 "SDKROOT=$(SDKROOT)"
52
53clean:
54
55installsrc:
56 pax -rw . $(SRCROOT)
57
58else ifeq ($(RC_ProjectName),libkxld)
59
fe8ab488
A
60include $(MakeInc_cmd)
61
39236c6e
A
62default: install
63
64installhdrs install clean:
65 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
66
67installsrc:
fe8ab488
A
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)
39236c6e
A
71
72else ifeq ($(RC_ProjectName),libkxld_host)
73
fe8ab488
A
74include $(MakeInc_cmd)
75
39236c6e
A
76default: install
77
78installhdrs install clean:
79 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
80
81installsrc:
fe8ab488
A
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)
39236c6e
A
85
86else ifeq ($(RC_ProjectName),libkmod)
87
88default: install
89
90installhdrs install:
91 cd libkern/kmod ; \
39037602 92 xcodebuild $@ \
39236c6e 93 "SRCROOT=$(SRCROOT)/libkern/kmod" \
39037602
A
94 "OBJROOT=$(OBJROOT)" \
95 "SYMROOT=$(SYMROOT)" \
39236c6e
A
96 "DSTROOT=$(DSTROOT)" \
97 "SDKROOT=$(SDKROOT)"
98
99clean:
100
4bd07ac2
A
101installsrc:
102 pax -rw . $(SRCROOT)
103
104else ifeq ($(RC_ProjectName),xnu_tests)
39236c6e 105
39037602
A
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
39236c6e
A
114default: install
115
116installhdrs:
117
4bd07ac2 118install: xnu_tests
39236c6e
A
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#
fe8ab488
A
139# Setup for parallel sub-makes, taking into account physical and logical
140# CPUs. If the system does not support SMT, use N+1.
39236c6e
A
141# If MAKEJOBS or -jN is passed on the make line, that takes precedence.
142#
fe8ab488
A
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
39236c6e 150
39037602
A
151TOP_TARGETS = \
152 clean \
153 installsrc \
154 exporthdrs \
3e170ce0 155 all all_desktop all_embedded \
39037602
A
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 \
3e170ce0 162 cscope tags TAGS reindent \
fe8ab488
A
163 help
164
3e170ce0
A
165DEFAULT_TARGET = all
166
fe8ab488 167# Targets for internal build system debugging
39037602 168TOP_TARGETS += \
fe8ab488 169 print_exports print_exports_first_build_config \
39037602 170 setup \
fe8ab488
A
171 build \
172 config \
173 install_textfiles \
174 install_config
39236c6e 175
3e170ce0
A
176ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
177MAKEARGS += -B
178DEFAULT_TARGET := build
179endif
180
39236c6e
A
181.PHONY: $(TOP_TARGETS)
182
3e170ce0 183default: $(DEFAULT_TARGET)
39236c6e
A
184
185ifneq ($(REMOTEBUILD),)
186$(TOP_TARGETS):
fe8ab488 187 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(if $(filter --,$(MAKEFLAGS)),-,)$(MAKEFLAGS)
39236c6e
A
188else
189$(TOP_TARGETS):
3e170ce0 190 $(_v)$(MAKE) $(MAKEARGS) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
39236c6e
A
191endif
192
193else # CURRENT_BUILD_CONFIG
1c79356b
A
194
195include $(MakeInc_cmd)
196include $(MakeInc_def)
197
198ALL_SUBDIRS = \
5ba3f43e 199 security \
39236c6e 200 bsd \
1c79356b
A
201 iokit \
202 osfmk \
1c79356b
A
203 pexpert \
204 libkern \
2d21ac55 205 libsa \
5ba3f43e
A
206 config \
207 san
1c79356b 208
5ba3f43e 209CONFIG_SUBDIRS = config tools san
55e303ae 210
91447636 211INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
6d2010ae 212INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
fe8ab488 213INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS)
6d2010ae 214INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
3e170ce0 215INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS)
2d21ac55 216
1c79356b 217EXPINC_SUBDIRS = $(ALL_SUBDIRS)
b0d623f7 218EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
fe8ab488 219EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS)
2d21ac55 220EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
3e170ce0 221EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS)
2d21ac55 222
5ba3f43e 223SETUP_SUBDIRS = SETUP san
b0d623f7 224
b0d623f7 225COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
fe8ab488 226COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS)
b0d623f7 227COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
3e170ce0 228COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS)
55e303ae 229
fe8ab488 230INSTTEXTFILES_SUBDIRS = \
9bccf70c
A
231 bsd
232
39236c6e 233include $(MakeInc_kernel)
1c79356b
A
234include $(MakeInc_rule)
235include $(MakeInc_dir)
6d2010ae 236
39236c6e
A
237endif # CURRENT_BUILD_CONFIG
238
239endif # all other RC_ProjectName
240
a39ff7e2 241installapi_libkdd installhdrs_libkdd install_libkdd:
3e170ce0 242 cd libkdd; \
39037602 243 xcodebuild -target libkdd $(subst _libkdd,,$@) \
3e170ce0 244 "SRCROOT=$(SRCROOT)/libkdd" \
39037602
A
245 "OBJROOT=$(OBJROOT)" \
246 "SYMROOT=$(SYMROOT)" \
3e170ce0
A
247 "DSTROOT=$(DSTROOT)" \
248 "SDKROOT=$(SDKROOT)"
249
250
a39ff7e2
A
251installapi_libkdd_host installhdrs_libkdd_host install_libkdd_host:
252 cd libkdd; \
253 xcodebuild -target kdd.framework $(subst _libkdd_host,,$@) \
254 "SRCROOT=$(SRCROOT)/libkdd" \
255 "OBJROOT=$(OBJROOT)" \
256 "SYMROOT=$(SYMROOT)" \
257 "DSTROOT=$(DSTROOT)" \
258 "SDKROOT=$(SDKROOT)"
259
260
4bd07ac2
A
261# "xnu_tests" and "testbots" are targets that can be invoked via a standalone
262# "make xnu_tests" or via buildit/XBS with the RC_ProjectName=xnu_tests.
39236c6e
A
263# Define the target here in the outermost scope of the initial Makefile
264
39037602
A
265xnu_tests:
266 $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \
39236c6e 267 SRCROOT=$(SRCROOT)/tools/tests