]>
Commit | Line | Data |
---|---|---|
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 | bsd \ | |
200 | iokit \ | |
201 | osfmk \ | |
202 | pexpert \ | |
203 | libkern \ | |
204 | libsa \ | |
205 | security \ | |
206 | config | |
207 | ||
208 | CONFIG_SUBDIRS = config tools | |
209 | ||
210 | INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS | |
211 | INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS) | |
212 | INSTINC_SUBDIRS_X86_64H = $(INSTINC_SUBDIRS) | |
213 | INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS) | |
214 | INSTINC_SUBDIRS_ARM64 = $(INSTINC_SUBDIRS) | |
215 | ||
216 | EXPINC_SUBDIRS = $(ALL_SUBDIRS) | |
217 | EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS) | |
218 | EXPINC_SUBDIRS_X86_64H = $(EXPINC_SUBDIRS) | |
219 | EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS) | |
220 | EXPINC_SUBDIRS_ARM64 = $(EXPINC_SUBDIRS) | |
221 | ||
222 | SETUP_SUBDIRS = SETUP | |
223 | ||
224 | COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS) | |
225 | COMP_SUBDIRS_X86_64H = $(ALL_SUBDIRS) | |
226 | COMP_SUBDIRS_ARM = $(ALL_SUBDIRS) | |
227 | COMP_SUBDIRS_ARM64 = $(ALL_SUBDIRS) | |
228 | ||
229 | INSTTEXTFILES_SUBDIRS = \ | |
230 | bsd | |
231 | ||
232 | include $(MakeInc_kernel) | |
233 | include $(MakeInc_rule) | |
234 | include $(MakeInc_dir) | |
235 | ||
236 | endif # CURRENT_BUILD_CONFIG | |
237 | ||
238 | endif # all other RC_ProjectName | |
239 | ||
240 | installhdrs_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 | ||
254 | xnu_tests: | |
255 | $(MAKE) -C $(SRCROOT)/tools/tests $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) \ | |
256 | SRCROOT=$(SRCROOT)/tools/tests |