]> git.saurik.com Git - apple/xnu.git/blame - makedefs/MakeInc.dir
xnu-2050.18.24.tar.gz
[apple/xnu.git] / makedefs / MakeInc.dir
CommitLineData
1c79356b
A
1#
2# Install kernel header files
3#
6d2010ae
A
4.PHONY: installhdrs
5
316670eb 6ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
2d21ac55 7installhdrs:
6d2010ae
A
8 cd libsyscall ; \
9 sdk="$(SDKROOT)" ; \
10 if [ $${sdk} = / ] ; then \
11 sdk="" ; \
12 fi; \
13 xcrun -sdk "$(SDKROOT)" xcodebuild installhdrs \
14 "SRCROOT=$(SRCROOT)/libsyscall" \
15 "OBJROOT=$(OBJROOT)" \
16 "SYMROOT=$(SYMROOT)" \
17 "DSTROOT=$(DSTROOT)" \
18 "SDKROOT=$${sdk}"
b0d623f7
A
19else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
20installhdrs:
21 make -C libkern/kxld/ installhdrs
316670eb
A
22else ifeq ($(RC_ProjectName),libkmod)
23installhdrs:
24# nothing to do
6d2010ae 25else # xnu, xnu_debug, or xnu_headers_Sim
316670eb 26installhdrs: exporthdrs installhdrs_mi installhdrs_md setup
2d21ac55
A
27 @echo "[ $(SRCROOT) ] make installhdrs installing Kernel.framework"
28 $(_v)kincpath=$(DSTROOT)/$(KINCDIR); \
91447636 29 krespath=$(DSTROOT)/$(KRESDIR); \
1c79356b 30 kframepath=$(DSTROOT)/$(KINCFRAME); \
91447636
A
31 [ -d $$krespath ] || $(MKDIR) $$krespath; \
32 [ -d $$kincpath ] || $(MKDIR) $$kincpath; \
1c79356b 33 cd $(SRCROOT)/EXTERNAL_HEADERS; \
91447636 34 install $(FILE_INSTALL_FLAGS) Info.plist $$krespath; \
b0d623f7 35 $(NEWVERS) $${krespath}/Info.plist; \
1c79356b
A
36 cd $$kframepath/Versions; \
37 [ -L Current ] || $(LN) $(KINCVERS) Current; \
38 cd $$kframepath; \
39 [ -L Headers ] || $(LN) Versions/Current/Headers Headers; \
91447636
A
40 [ -L Resources ] || $(LN) Versions/Current/Resources Resources; \
41 [ -d $(DSTROOT)/$(KPINCDIR) ] || $(MKDIR) $(DSTROOT)/$(KPINCDIR); \
0b4e3aa0 42 cd $$kframepath; [ -L PrivateHeaders ] || \
91447636 43 $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
6d2010ae
A
44ifeq ($(RC_ProjectName),xnu_headers_Sim)
45 @echo "[ $(SRCROOT) ] make installhdrs installing System.framework"
46 $(_v)spincpath=$(DSTROOT)/$(SPINCDIR); \
47 sframepath=$(DSTROOT)/$(SINCFRAME); \
48 [ -d $$spincpath ] || $(MKDIR) $$spincpath; \
49 cd $$sframepath/Versions; \
50 [ -L Current ] || $(LN) $(SINCVERS) Current; \
51 cd $$sframepath; [ -L PrivateHeaders ] || \
52 $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
53endif
54ifeq (iPhoneOS,$(PLATFORM))
55 $(_v)$(IPHONEOS_OPTIMIZE) $(DSTROOT)/$(KRESDIR)/Info.plist
56endif
2d21ac55 57endif
1c79356b 58
316670eb
A
59.PHONY: installhdrs_embedded installhdrs_devicemap
60installhdrs_embedded installhdrs_devicemap: installhdrs
61
1c79356b
A
62#
63# Install header files order
64#
65.ORDER: installhdrs_mi installhdrs_md
6d2010ae 66.PHONY: installhdrs_mi installhdrs_md
1c79356b
A
67
68#
69# Install machine independent header files
70#
316670eb
A
71installhdrs_mi: setup
72 $(_v)kernel_config=$(INSTALL_TYPE); \
6d2010ae
A
73 machine_config=$(MACHINE_CONFIG); \
74 arch_config=$(INSTALL_ARCH_DEFAULT); \
75 if [ $${arch_config} = ARM ] ; then \
76 if [ $${machine_config} = DEFAULT ] ; then \
77 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
78 fi; \
79 fi; \
316670eb
A
80 if [ $${arch_config} = L4_ARM ] ; then \
81 if [ $${machine_config} = DEFAULT ] ; then \
82 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG); \
83 fi; \
84 fi; \
6d2010ae 85 if [ $${machine_config} = DEFAULT ] ; then \
316670eb 86 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
6d2010ae 87 else \
316670eb 88 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
6d2010ae
A
89 fi; \
90 [ -d $${installinc_dir} ] || $(MKDIR) $${installinc_dir}; \
b0d623f7 91 ${MAKE} ${MAKEJOBS} -C $${installinc_dir} \
9bccf70c 92 KERNEL_CONFIG=$${kernel_config} \
1c79356b 93 ARCH_CONFIG=$${arch_config} \
316670eb 94 MACHINE_CONFIG=$${machine_config} \
1c79356b
A
95 MAKEFILES=${SOURCE}/Makefile \
96 SOURCE=${SOURCE}/ \
316670eb 97 RELATIVE_SOURCE_PATH=. \
6d2010ae 98 TARGET=$${installinc_dir}/ \
9bccf70c 99 build_installhdrs_mi; \
1c79356b
A
100
101#
102# Install machine dependent kernel header files
316670eb 103# Uses hack for machine_config, which is not threaded through properly.
1c79356b 104#
316670eb
A
105installhdrs_md: setup
106 $(_v)kernel_config=$(INSTALL_TYPE); \
107 machine_config=$(MACHINE_CONFIG); \
1c79356b
A
108 for arch_config in $(INSTALL_ARCHS); \
109 do \
2d21ac55
A
110 if [ $${arch_config} = ARM ] ; then \
111 if [ $${machine_config} = DEFAULT ] ; then \
112 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
113 fi; \
114 fi; \
316670eb
A
115 if [ $${arch_config} = L4_ARM ] ; then \
116 if [ $${machine_config} = DEFAULT ] ; then \
117 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG); \
118 fi; \
119 fi; \
2d21ac55 120 if [ $${machine_config} = DEFAULT ] ; then \
316670eb 121 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55 122 else \
316670eb 123 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55 124 fi; \
6d2010ae
A
125 [ -d $${installinc_dir} ] || $(MKDIR) $${installinc_dir}; \
126 ${MAKE} ${MAKEJOBS} -C $${installinc_dir} \
9bccf70c 127 KERNEL_CONFIG=$${kernel_config} \
1c79356b 128 ARCH_CONFIG=$${arch_config} \
316670eb 129 MACHINE_CONFIG=$${machine_config} \
1c79356b
A
130 MAKEFILES=${SOURCE}/Makefile \
131 SOURCE=${SOURCE}/ \
316670eb 132 RELATIVE_SOURCE_PATH=. \
6d2010ae 133 TARGET=$${installinc_dir}/ \
9bccf70c 134 build_installhdrs_md; \
1c79356b
A
135 done;
136
137#
138# Install machine independent kernel header files
139#
140do_installhdrs_mi:
141
b0d623f7
A
142BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS = $(addprefix build_installhdrs_mi_,$(INSTINC_SUBDIRS))
143
144.PHONY: $(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS)
145
146$(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS):
147 $(_v)installinc_subdir="$(patsubst build_installhdrs_mi_%,%,$@)"; \
148 [ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir}; \
149 ${MAKE} -C $${installinc_subdir} \
150 MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile \
151 SOURCE=$(SOURCE)$${installinc_subdir}/ \
316670eb 152 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installinc_subdir} \
b0d623f7
A
153 TARGET=$(TARGET)$${installinc_subdir}/ \
154 build_installhdrs_mi;
155
156build_installhdrs_mi: $(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS)
157 $(_v)${MAKE} do_installhdrs_mi;
1c79356b
A
158
159#
160# Install machine dependent kernel header files
161#
162do_installhdrs_md:
163
b0d623f7
A
164BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS = $(addprefix build_installhdrs_md_,$($(addprefix INSTINC_SUBDIRS_, $(ARCH_CONFIG))))
165
166.PHONY: $(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS)
167
168$(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS):
169 $(_v)installinc_subdir="$(patsubst build_installhdrs_md_%,%,$@)"; \
170 [ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir}; \
171 ${MAKE} -C $${installinc_subdir} \
172 MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile \
173 SOURCE=$(SOURCE)$${installinc_subdir}/ \
316670eb 174 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installinc_subdir} \
b0d623f7
A
175 TARGET=$(TARGET)$${installinc_subdir}/ \
176 build_installhdrs_md;
177
178build_installhdrs_md: $(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS)
179 $(_v)${MAKE} do_installhdrs_md;
1c79356b
A
180
181#
182# Install kernel header files
183#
6d2010ae
A
184.PHONY: exporthdrs
185
9bccf70c 186exporthdrs: exporthdrs_mi exporthdrs_md
1c79356b
A
187
188#
189# Install header files order
190#
191.ORDER: exporthdrs_mi exporthdrs_md
6d2010ae 192.PHONY: exporthdrs_mi exporthdrs_md
1c79356b
A
193
194#
195# Install machine independent header files
196#
197do_exporthdrs_mi:
198
0b4e3aa0 199exporthdrs_mi:
316670eb 200 $(_v)kernel_config=$(INSTALL_TYPE); \
6d2010ae 201 arch_config=$(INSTALL_ARCH_DEFAULT); \
316670eb 202 machine_config=DEFAULT; \
6d2010ae
A
203 if [ $${arch_config} = ARM ] ; then \
204 if [ $${machine_config} = DEFAULT ] ; then \
205 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
206 fi; \
207 fi; \
316670eb
A
208 if [ $${arch_config} = L4_ARM ] ; then \
209 if [ $${machine_config} = DEFAULT ] ; then \
210 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG);\
211 fi; \
212 fi; \
6d2010ae 213 if [ $${machine_config} = DEFAULT ] ; then \
316670eb 214 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
6d2010ae 215 else \
316670eb 216 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
6d2010ae
A
217 fi; \
218 [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir}; \
b0d623f7 219 ${MAKE} ${MAKEJOBS} -C $${exportinc_dir} \
9bccf70c 220 KERNEL_CONFIG=$${kernel_config} \
1c79356b 221 ARCH_CONFIG=$${arch_config} \
316670eb 222 MACHINE_CONFIG=$${machine_config} \
1c79356b
A
223 MAKEFILES=${SOURCE}/Makefile \
224 SOURCE=${SOURCE}/ \
316670eb 225 RELATIVE_SOURCE_PATH=. \
1c79356b 226 TARGET=$${exportinc_dir}/ \
9bccf70c 227 build_exporthdrs_mi; \
1c79356b
A
228
229#
230# Install machine dependent kernel header files
231#
2d21ac55
A
232# Note - installation of machine dependent kernel header files only occurs for architecture
233# defined in INSTALL_TYPE. We use skipit variable to skip over architectures that are not
234# equal to what is in the INSTALL_TYPE variable.
235# TARGET_CONFIGS_UC variable holds sets of three configuration options. The first item in the
236# set is the kernel configuration. The second item in the set is the architecture and the
237# third item is the machine configuration. There may be multiple sets to build.
0b4e3aa0 238exporthdrs_md:
316670eb 239 $(_v)my_counter=1; \
2d21ac55
A
240 for my_config in $(TARGET_CONFIGS_UC); \
241 do \
242 if [ $${my_counter} -eq 1 ] ; then \
243 skipit=0; \
244 my_counter=2; \
245 kernel_config=$${my_config}; \
246 if [ $${kernel_config} = DEFAULT ] ; then \
247 kernel_config=$(DEFAULT_KERNEL_CONFIG); \
248 fi; \
249 if [ $${kernel_config} != $(INSTALL_TYPE) ] ; then \
250 skipit=1; \
251 fi; \
252 elif [ $${my_counter} -eq 2 ] ; then \
253 my_counter=3; \
254 arch_config=$${my_config}; \
255 if [ $${arch_config} = DEFAULT ] ; then \
256 arch_config=`arch | $(TR) a-z A-Z`; \
257 fi; \
258 else \
259 my_counter=1; \
260 machine_config=$${my_config}; \
261 if [ $${skipit} -eq 0 ] ; then \
262 if [ $${arch_config} = ARM ] ; then \
263 if [ $${machine_config} = DEFAULT ] ; then \
264 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
265 fi; \
266 fi; \
316670eb
A
267 if [ $${arch_config} = L4_ARM ] ; then \
268 if [ $${machine_config} = DEFAULT ] ; then \
269 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG); \
270 fi; \
271 fi; \
2d21ac55 272 if [ $${machine_config} = DEFAULT ] ; then \
316670eb 273 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55 274 else \
316670eb 275 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55
A
276 fi; \
277 [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir}; \
b0d623f7 278 ${MAKE} ${MAKEJOBS} -C $${exportinc_dir} \
2d21ac55
A
279 KERNEL_CONFIG=$${kernel_config} \
280 ARCH_CONFIG=$${arch_config} \
316670eb 281 MACHINE_CONFIG=$${machine_config} \
2d21ac55
A
282 MAKEFILES=${SOURCE}/Makefile \
283 SOURCE=${SOURCE}/ \
316670eb 284 RELATIVE_SOURCE_PATH=. \
2d21ac55
A
285 TARGET=$${exportinc_dir}/ \
286 build_exporthdrs_md; \
287 fi; \
288 fi; \
1c79356b
A
289 done;
290
291#
292# Install machine independent kernel header files
293#
294do_exporthdrs_mi:
295
b0d623f7
A
296BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS = $(addprefix build_exporthdrs_mi_,$(EXPINC_SUBDIRS))
297
298.PHONY: $(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS)
299
300$(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS):
301 $(_v)exportinc_subdir="$(patsubst build_exporthdrs_mi_%,%,$@)"; \
302 [ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir}; \
303 ${MAKE} -C $${exportinc_subdir} \
304 MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile \
305 SOURCE=$(SOURCE)$${exportinc_subdir}/ \
316670eb 306 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${exportinc_subdir} \
b0d623f7
A
307 TARGET=$(TARGET)$${exportinc_subdir}/ \
308 build_exporthdrs_mi;
309
310build_exporthdrs_mi: $(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS)
311 $(_v)${MAKE} do_exporthdrs_mi;
1c79356b
A
312
313#
314# Install machine dependent kernel header files
315#
316do_exporthdrs_md:
317
b0d623f7
A
318BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS = $(addprefix build_exporthdrs_md_,$($(addprefix EXPINC_SUBDIRS_, $(ARCH_CONFIG))))
319
320.PHONY: $(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS)
321
322$(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS):
323 $(_v)exportinc_subdir="$(patsubst build_exporthdrs_md_%,%,$@)"; \
324 [ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir}; \
325 ${MAKE} -C $${exportinc_subdir} \
326 MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile \
327 SOURCE=$(SOURCE)$${exportinc_subdir}/ \
316670eb 328 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${exportinc_subdir} \
b0d623f7
A
329 TARGET=$(TARGET)$${exportinc_subdir}/ \
330 build_exporthdrs_md;
331
332build_exporthdrs_md: $(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS)
333 $(_v)${MAKE} do_exporthdrs_md;
1c79356b
A
334
335#
336# Setup pass for all architectures for all Configuration/Architecture options
337#
6d2010ae
A
338.PHONY: setup
339
9bccf70c 340setup:
316670eb 341 $(_v)kernel_config=$(INSTALL_TYPE); \
6d2010ae 342 arch_config=$(INSTALL_ARCH_DEFAULT); \
316670eb 343 setup_subdir=${OBJROOT}/$${RELATIVE_SOURCE_PATH}; \
6d2010ae
A
344 [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir}; \
345 ${MAKE} ${MAKEJOBS} -C $${setup_subdir} \
9bccf70c 346 KERNEL_CONFIG=$${kernel_config} \
1c79356b 347 ARCH_CONFIG=$${arch_config} \
316670eb 348 MACHINE_CONFIG=$${machine_config} \
1c79356b
A
349 MAKEFILES=${SOURCE}/Makefile \
350 SOURCE=${SOURCE}/ \
316670eb 351 RELATIVE_SOURCE_PATH=. \
1c79356b 352 TARGET=$${setup_subdir}/ \
6d2010ae 353 build_setup;
1c79356b
A
354
355do_build_setup:
356
b0d623f7
A
357BUILD_SETUP_SUBDIRS_TARGETS = $(addprefix build_setup_,$(SETUP_SUBDIRS) $($(addprefix SETUP_SUBDIRS_, $(ARCH_CONFIG))))
358
359.PHONY: $(BUILD_SETUP_SUBDIRS_TARGETS)
360
361$(BUILD_SETUP_SUBDIRS_TARGETS):
362 $(_v)setup_subdir="$(patsubst build_setup_%,%,$@)"; \
363 [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir}; \
9bccf70c
A
364 ${MAKE} -C $${setup_subdir} \
365 MAKEFILES=${SOURCE}/$${setup_subdir}/Makefile \
1c79356b 366 SOURCE=${SOURCE}/$${setup_subdir}/ \
316670eb 367 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}/$${setup_subdir} \
1c79356b 368 TARGET=${TARGET}/$${setup_subdir}/ \
b0d623f7
A
369 build_setup;
370
371build_setup: $(BUILD_SETUP_SUBDIRS_TARGETS)
372 $(_v)${MAKE} do_build_setup;
1c79356b
A
373
374
375#
376# Build all architectures for all Configuration/Architecture options
377#
2d21ac55
A
378# Note - TARGET_CONFIGS_UC variable holds sets of three configuration options. The first
379# item in the set is the kernel configuration. The second item in the set is the architecture
380# and the third item is the machine configuration. There may be multiple sets to build.
381#
6d2010ae
A
382.PHONY: all
383
2d21ac55
A
384ifeq ($(RC_ProjectName),Libsyscall)
385all:
6d2010ae 386 cd libsyscall ; \
316670eb 387 sdk="$(SDKROOT)" ; \
6d2010ae 388 if [ $${sdk} = / ] ; then \
316670eb
A
389 sdk="" ; \
390 fi; \
391 xcrun -sdk "$(SDKROOT)" xcodebuild install \
6d2010ae
A
392 "SRCROOT=$(SRCROOT)/libsyscall" \
393 "OBJROOT=$(OBJROOT)" \
394 "SYMROOT=$(SYMROOT)" \
395 "DSTROOT=$(DSTROOT)" \
396 "SDKROOT=$${sdk}"
397else ifeq ($(RC_ProjectName),libkxld)
b0d623f7
A
398all:
399 make -C libkern/kxld/ install
6d2010ae
A
400else ifeq ($(RC_ProjectName),libkxld_host)
401all:
402 make -C libkern/kxld/ install PRODUCT_TYPE=ARCHIVE
316670eb
A
403else ifeq ($(RC_ProjectName),libkmod)
404all:
405 cd libkern/kmod ; \
406 sdk="$(SDKROOT)" ; \
407 if [ $${sdk} = / ] ; then \
408 sdk="" ; \
409 fi; \
410 xcrun -sdk "$(SDKROOT)" xcodebuild install \
411 "SRCROOT=$(SRCROOT)/libkern/kmod" \
412 "OBJROOT=$(OBJROOT)" \
413 "SYMROOT=$(SYMROOT)" \
414 "DSTROOT=$(DSTROOT)" \
415 "SDKROOT=$${sdk}"
416else ifeq ($(findstring _headers_Sim,$(RC_ProjectName)),_headers_Sim) # Libsyscall/xnu _headers_Sim
6d2010ae 417all: exporthdrs
b0d623f7 418else # xnu or xnu_debug
9bccf70c 419ifeq ($(COMPONENT), .)
6d2010ae 420all: exporthdrs setup
9bccf70c
A
421else
422all:
423endif
2d21ac55
A
424 $(_v)my_counter=1; \
425 for my_config in $(TARGET_CONFIGS_UC); \
426 do \
427 if [ $${my_counter} -eq 1 ] ; then \
428 my_counter=2; \
429 kernel_config=$${my_config}; \
430 if [ $${kernel_config} = DEFAULT ] ; then \
431 kernel_config=$(DEFAULT_KERNEL_CONFIG); \
432 fi; \
433 elif [ $${my_counter} -eq 2 ] ; then \
434 my_counter=3; \
435 arch_config=$${my_config}; \
436 if [ $${arch_config} = DEFAULT ] ; then \
437 arch_config=`arch | $(TR) a-z A-Z`; \
438 fi; \
439 else \
440 my_counter=1; \
441 machine_config=$${my_config}; \
442 if [ $${arch_config} = ARM ] ; then \
443 if [ $${machine_config} = DEFAULT ] ; then \
444 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
445 fi; \
446 fi; \
316670eb
A
447 if [ $${arch_config} = L4_ARM ] ; then \
448 if [ $${machine_config} = DEFAULT ] ; then \
449 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG); \
450 fi; \
451 fi; \
2d21ac55 452 if [ $${machine_config} = DEFAULT ] ; then \
316670eb 453 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55 454 else \
316670eb 455 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55
A
456 fi; \
457 [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir}; \
b0d623f7 458 ${MAKE} ${MAKEJOBS} -C $${build_subdir} \
2d21ac55 459 KERNEL_CONFIG=$${kernel_config} \
b0d623f7 460 ARCH_CONFIG=$${arch_config} \
2d21ac55
A
461 MACHINE_CONFIG=$${machine_config} \
462 MAKEFILES=${SOURCE}/Makefile \
463 SOURCE=${SOURCE}/ \
316670eb 464 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
2d21ac55
A
465 build_all; \
466 fi; \
1c79356b 467 done;
2d21ac55 468endif
1c79356b 469
316670eb
A
470.PHONY: all_embedded all_devicemap
471all_embedded all_devicemap: all
472
1c79356b
A
473#
474# Build all architectures for all Configuration/Architecture options
475#
476do_build_all:
477
b0d623f7
A
478BUILD_ALL_SUBDIRS_TARGETS = $(addprefix build_all_,$(COMP_SUBDIRS) $($(addprefix COMP_SUBDIRS_, $(ARCH_CONFIG))))
479
480.PHONY: $(BUILD_ALL_SUBDIRS_TARGETS)
481
482$(BUILD_ALL_SUBDIRS_TARGETS):
2d21ac55
A
483 $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then \
484 TARGET=$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
485 else \
486 TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)"; \
487 fi; \
b0d623f7
A
488 comp_subdir="$(patsubst build_all_%,%,$@)"; \
489 [ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir}; \
490 ${MAKE} -C $${comp_subdir} \
491 MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile \
492 SOURCE=${SOURCE}$${comp_subdir}/ \
316670eb 493 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${comp_subdir} \
b0d623f7
A
494 TARGET=$${TARGET} \
495 build_all;
496
497build_all: $(BUILD_ALL_SUBDIRS_TARGETS)
498 $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then \
499 TARGET=$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
500 else \
501 TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)"; \
502 fi; \
503 ${MAKE} INCL_MAKEDEP=TRUE TARGET=$${TARGET} do_build_all; \
55e303ae
A
504 _TMP_comp_subdir="$(CONFIG_SUBDIRS) $($(addprefix CONFIG_SUBDIRS_, $(ARCH_CONFIG)))"; \
505 for comp_subdir in $${_TMP_comp_subdir}; \
506 do \
91447636 507 [ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir}; \
55e303ae
A
508 ${MAKE} -C $${comp_subdir} \
509 MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile \
510 SOURCE=${SOURCE}$${comp_subdir}/ \
316670eb 511 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${comp_subdir} \
55e303ae
A
512 TARGET=$${TARGET} \
513 build_all; \
2d21ac55 514 done;
55e303ae 515
1c79356b
A
516
517#
518# Build all architectures for all Configuration/Architecture options
519#
2d21ac55
A
520# Note - TARGET_CONFIGS_UC variable holds sets of three configuration options. The first
521# item in the set is the kernel configuration. The second item is the architecture
522# and the third item is the machine configuration. There may be multiple sets to build.
523#
9bccf70c 524mach_kernel:
2d21ac55
A
525 $(_v)my_counter=1; \
526 for my_config in $(TARGET_CONFIGS_UC); \
527 do \
528 if [ $${my_counter} -eq 1 ] ; then \
529 my_counter=2; \
530 kernel_config=$${my_config}; \
531 if [ $${kernel_config} = DEFAULT ] ; then \
532 kernel_config=$(DEFAULT_KERNEL_CONFIG); \
533 fi; \
534 elif [ $${my_counter} -eq 2 ] ; then \
535 my_counter=3; \
536 arch_config=$${my_config}; \
537 if [ $${arch_config} = DEFAULT ] ; then \
538 arch_config=`arch | $(TR) a-z A-Z`; \
539 fi; \
540 else \
541 my_counter=1; \
542 machine_config=$${my_config}; \
543 if [ $${arch_config} = ARM ] ; then \
544 if [ $${machine_config} = DEFAULT ] ; then \
545 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
546 fi; \
547 fi; \
316670eb
A
548 if [ $${arch_config} = L4_ARM ] ; then \
549 if [ $${machine_config} = DEFAULT ] ; then \
550 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG); \
551 fi; \
552 fi; \
2d21ac55
A
553 if [ $${machine_config} = DEFAULT ] ; then \
554 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}; \
555 else \
556 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}; \
557 fi; \
558 [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir}; \
b0d623f7 559 ${MAKE} ${MAKEJOBS} -C $${build_subdir} \
2d21ac55
A
560 KERNEL_CONFIG=$${kernel_config} \
561 ARCH_CONFIG=$${arch_config} \
562 MACHINE_CONFIG=$${machine_config} \
563 MAKEFILES=${SOURCE}/Makefile \
564 SOURCE=${SOURCE}/ \
565 TARGET=$${build_subdir}/ \
566 build_mach_kernel; \
567 fi; \
1c79356b
A
568 done;
569
570#
571# Build all architectures for all Configuration/Architecture options
572#
573do_build_mach_kernel:
574
575build_mach_kernel:
b0d623f7 576 $(_v)${MAKE} do_build_mach_kernel;
1c79356b 577
55e303ae 578
1c79356b
A
579#
580#
581# Install dependencies order
582#
9bccf70c 583.ORDER: installhdrs exporthdrs all
1c79356b
A
584
585#
586# Install kernel based on RC_ARCHS for all INSTALL_TYPES
587# Install kernel header files based on RC_ARCHS
588#
2d21ac55 589install: installhdrs all installman installmachinekernels
316670eb 590ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
2d21ac55 591# nothing to do
b0d623f7 592else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
6d2010ae 593# nothing to do, work performed in "all" action
316670eb
A
594else ifeq ($(RC_ProjectName),libkmod)
595# nothing to do, work performed in "all" action
596else ifeq ($(findstring _headers_Sim,$(RC_ProjectName)),_headers_Sim)
b0d623f7
A
597# nothing to do
598else # xnu or xnu_debug
316670eb
A
599# A bit of a hack for machine_config: machine configs aren't really threaded through properly.
600 $(_v)machine_config=$(MACHINE_CONFIG); \
1c79356b
A
601 for kernel_config in $(INSTALL_TYPE); \
602 do \
603 for arch_config in $(INSTALL_ARCHS); \
604 do \
2d21ac55
A
605 if [ $${arch_config} = ARM ] ; then \
606 if [ $${machine_config} = DEFAULT ] ; then \
607 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
608 fi; \
609 fi; \
316670eb
A
610 if [ $${arch_config} = L4_ARM ] ; then \
611 if [ $${machine_config} = DEFAULT ] ; then \
612 machine_config=$(DEFAULT_L4_ARM_MACHINE_CONFIG); \
613 fi; \
614 fi; \
2d21ac55 615 if [ $${machine_config} = DEFAULT ] ; then \
316670eb 616 install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55 617 else \
316670eb 618 install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
2d21ac55 619 fi; \
91447636 620 [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir}; \
b0d623f7 621 ${MAKE} ${MAKEJOBS} -C $${install_subdir} \
9bccf70c 622 KERNEL_CONFIG=$${kernel_config} \
1c79356b 623 ARCH_CONFIG=$${arch_config} \
2d21ac55 624 MACHINE_CONFIG=$${machine_config} \
1c79356b
A
625 MAKEFILES=${SOURCE}/Makefile \
626 SOURCE=${SOURCE}/ \
316670eb 627 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
9bccf70c 628 build_install; \
1c79356b
A
629 done; \
630 done;
b0d623f7
A
631ifeq ($(RC_ProjectName),xnu_debug)
632 $(_v)$(MKDIR) $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
633 $(_v)$(MV) $(DSTROOT)/mach_kernel* $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
634 $(_v)$(CP) $(SYMROOT)/kgmacros $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
635 $(_v)$(CP) -r $(SYMROOT)/System.kext $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
636 $(_v)$(CP) -r $(SYMROOT)/mach_kernel.dSYM $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
637 $(_v)$(CP) $(SRCROOT)/config/README.DEBUG-kernel.txt $(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)
638 $(_v)$(MV) $(DSTROOT)/System $(DSTROOT)/usr $(OBJROOT)/
639endif
2d21ac55
A
640endif
641
316670eb
A
642.PHONY: install_embedded install_devicemap
643install_embedded install_devicemap: install
644
2d21ac55
A
645installmachinekernels:
646 @echo "[ $(SOURCE) ] make installmachinekernels"; \
647 my_counter=1; \
648 for my_config in $(TARGET_CONFIGS_UC); \
649 do \
650 if [ $${my_counter} -eq 1 ] ; then \
651 my_counter=2; \
652 kernel_config=$${my_config}; \
653 if [ $${kernel_config} = DEFAULT ] ; then \
654 kernel_config=$(DEFAULT_KERNEL_CONFIG); \
655 fi; \
656 elif [ $${my_counter} -eq 2 ] ; then \
657 my_counter=3; \
658 arch_config=$${my_config}; \
659 if [ $${arch_config} = DEFAULT ] ; then \
660 arch_config=`arch | $(TR) a-z A-Z`; \
661 fi; \
662 else \
663 my_counter=1; \
664 machine_config=$${my_config}; \
665 if [ $${machine_config} != DEFAULT ] ; then \
666 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}; \
6d2010ae 667 install_kernel_file=mach.`printf "%s" "$${kernel_config}" | $(TR) A-Z a-z`.`printf "%s" "$${machine_config}" | $(TR) A-Z a-z`; \
2d21ac55 668 [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir}; \
b0d623f7 669 ${MAKE} ${MAKEJOBS} -C $${build_subdir} \
6d2010ae 670 INSTALL_KERNEL_FILE=$${install_kernel_file} \
2d21ac55
A
671 KERNEL_CONFIG=$${kernel_config} \
672 ARCH_CONFIG=$${arch_config} \
673 MACHINE_CONFIG=$${machine_config} \
674 MAKEFILES=${SOURCE}/Makefile \
675 SOURCE=${SOURCE}/ \
316670eb 676 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
2d21ac55
A
677 TARGET=$${build_subdir}/ \
678 do_build_install; \
679 fi; \
680 fi; \
681 done;
1c79356b
A
682
683#
684# Install for all architectures for all Configuration/Architecture options
685#
686setup_build_install:
687
688do_build_install:
689
b0d623f7
A
690BUILD_INSTALL_SUBDIRS_TARGETS = $(addprefix build_install_,$(INST_SUBDIRS))
691
692.PHONY: $(BUILD_INSTALL_SUBDIRS_TARGETS)
693
694$(BUILD_INSTALL_SUBDIRS_TARGETS):
2d21ac55
A
695 $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then \
696 TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
697 else \
698 TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)"; \
699 fi; \
0b4e3aa0 700 ${MAKE} TARGET=$${TARGET} setup_build_install; \
1c79356b 701 kernel_config=$(KERNEL_CONFIG); \
b0d623f7
A
702 install_subdir="$(patsubst build_install_%,%,$@)"; \
703 [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir}; \
704 ${MAKE} -C $${install_subdir} \
705 KERNEL_CONFIG=$${kernel_config} \
706 MAKEFILES=${SOURCE}/$${install_subdir}/Makefile \
707 SOURCE=${SOURCE}$${install_subdir}/ \
316670eb 708 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}/$${install_subdir} \
b0d623f7
A
709 TARGET=$${TARGET} \
710 build_install;
711
712build_install: $(BUILD_INSTALL_SUBDIRS_TARGETS)
713 $(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then \
714 TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT); \
715 else \
716 TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)"; \
717 fi; \
718 ${MAKE} TARGET=$${TARGET} do_build_install;
1c79356b
A
719
720
721#
722# Install source tree
723#
6d2010ae
A
724.PHONY: installsrc
725
9bccf70c 726installsrc:
6d2010ae 727 $(_v)($(TAR) -c --mode go=r,+X --no-ignore-case --exclude .svn --exclude .git --exclude cscope.\* --exclude BUILD --exclude \*~ -f - .) | (cd $(SRCROOT) && $(TAR) --no-same-owner -xf -)
1c79356b
A
728
729
730#
731# Clean up source tree
732#
6d2010ae
A
733.PHONY: clean
734
9bccf70c 735clean:
1c79356b
A
736
737#
738# Build source file list for cscope database and tags
739#
740cscope.files:
741 @echo "Building file list for cscope and tags"
0c530ab8
A
742 @find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
743 @find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
744 @find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
745 @find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
746 @find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
747 @find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
748 @echo -k -q -c > cscope.files 2> /dev/null
749 @sort -u < _cscope.files >> cscope.files 2> /dev/null
750 @rm -f _cscope.files _cscope.files2 2> /dev/null
1c79356b
A
751
752#
753# Build cscope database
754#
755cscope: cscope.files
756 @echo "Building cscope database"
0c530ab8 757 @cscope -bvU 2> /dev/null
1c79356b
A
758
759#
760# Build tags
761#
762
763tags: cscope.files
764 @echo "Building ctags"
2d21ac55 765 @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
1c79356b 766 echo "Phantom files detected!" 2>&1 > /dev/null
2d21ac55
A
767 @-[ -f TAGS ] || ${MAKE} TAGS
768
769TAGS: cscope.files
1c79356b
A
770 @echo "Building etags"
771 @-cat cscope.files | etags -l auto -S - 2> /dev/null
772
9bccf70c
A
773#
774# Install Man Pages
775#
6d2010ae
A
776.PHONY: installman
777
9bccf70c 778installman:
316670eb 779ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
6d2010ae 780# nothing to do
b0d623f7
A
781else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
782# nothing to do
316670eb
A
783else ifeq ($(RC_ProjectName),libkmod)
784# nothing to do
6d2010ae
A
785else ifeq ($(findstring xnu_,$(RC_ProjectName)),xnu_)
786installman:
787# nothing to do
788else # xnu
2d21ac55
A
789 @echo "[ $(SRCROOT) ] Installing man pages"
790 $(_v)manpath=$(DSTROOT)/$(MANDIR); \
91447636 791 [ -d $$manpath ] || $(MKDIR) $$manpath; \
b0d623f7 792 ${MAKE} ${MAKEJOBS} MAKEFILES=${SOURCE}/Makefile \
9bccf70c 793 SOURCE=${SOURCE}/ \
316670eb 794 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
9bccf70c
A
795 TARGET=${DSTROOT}/ \
796 build_installman
b0d623f7 797 ${SRCROOT}/config/compress-man-pages.pl ${DSTROOT}/${MANDIR}
2d21ac55 798endif
9bccf70c
A
799
800do_installman:
801
b0d623f7
A
802BUILD_INSTALLMAN_SUBDIRS_TARGETS = $(addprefix build_installman_,$(INSTMAN_SUBDIRS))
803
804.PHONY: $(BUILD_INSTALLMAN_SUBDIRS_TARGETS)
805
806$(BUILD_INSTALLMAN_SUBDIRS_TARGETS):
807 $(_v)installman_subdir="$(patsubst build_installman_%,%,$@)"; \
808 ${MAKE} -C $${installman_subdir} -r \
809 MAKEFILES=$(SOURCE)$${installman_subdir}/Makefile \
810 SOURCE=$(SOURCE)$${installman_subdir}/ \
316670eb 811 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installman_subdir} \
b0d623f7
A
812 TARGET=$(TARGET)$${installman_subdir}/ \
813 build_installman;
814
815build_installman: $(BUILD_INSTALLMAN_SUBDIRS_TARGETS)
816 $(_v)if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
817 ${MAKE} do_installman; \
1c79356b 818 fi
2d21ac55
A
819
820# vim: set ft=make: