]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.dir
12191a3c22ef11a0b8255a62d67115439ea043e3
[apple/xnu.git] / makedefs / MakeInc.dir
1 #
2 # Install kernel header files
3 #
4 .PHONY: installhdrs
5
6 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
7 installhdrs:
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}"
19 else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
20 installhdrs:
21 make -C libkern/kxld/ installhdrs
22 else ifeq ($(RC_ProjectName),libkmod)
23 installhdrs:
24 # nothing to do
25 else # xnu, xnu_debug, or xnu_headers_Sim
26 installhdrs: exporthdrs installhdrs_mi installhdrs_md setup
27 @echo "[ $(SRCROOT) ] make installhdrs installing Kernel.framework"
28 $(_v)kincpath=$(DSTROOT)/$(KINCDIR); \
29 krespath=$(DSTROOT)/$(KRESDIR); \
30 kframepath=$(DSTROOT)/$(KINCFRAME); \
31 [ -d $$krespath ] || $(MKDIR) $$krespath; \
32 [ -d $$kincpath ] || $(MKDIR) $$kincpath; \
33 cd $(SRCROOT)/EXTERNAL_HEADERS; \
34 install $(FILE_INSTALL_FLAGS) Info.plist $$krespath; \
35 $(NEWVERS) $${krespath}/Info.plist; \
36 cd $$kframepath/Versions; \
37 [ -L Current ] || $(LN) $(KINCVERS) Current; \
38 cd $$kframepath; \
39 [ -L Headers ] || $(LN) Versions/Current/Headers Headers; \
40 [ -L Resources ] || $(LN) Versions/Current/Resources Resources; \
41 [ -d $(DSTROOT)/$(KPINCDIR) ] || $(MKDIR) $(DSTROOT)/$(KPINCDIR); \
42 cd $$kframepath; [ -L PrivateHeaders ] || \
43 $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
44 ifeq ($(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;
53 endif
54 ifeq (iPhoneOS,$(PLATFORM))
55 $(_v)$(IPHONEOS_OPTIMIZE) $(DSTROOT)/$(KRESDIR)/Info.plist
56 endif
57 endif
58
59 .PHONY: installhdrs_embedded installhdrs_devicemap
60 installhdrs_embedded installhdrs_devicemap: installhdrs
61
62 #
63 # Install header files order
64 #
65 .ORDER: installhdrs_mi installhdrs_md
66 .PHONY: installhdrs_mi installhdrs_md
67
68 #
69 # Install machine independent header files
70 #
71 installhdrs_mi: setup
72 $(_v)kernel_config=$(INSTALL_TYPE); \
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; \
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; \
85 if [ $${machine_config} = DEFAULT ] ; then \
86 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
87 else \
88 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
89 fi; \
90 [ -d $${installinc_dir} ] || $(MKDIR) $${installinc_dir}; \
91 ${MAKE} ${MAKEJOBS} -C $${installinc_dir} \
92 KERNEL_CONFIG=$${kernel_config} \
93 ARCH_CONFIG=$${arch_config} \
94 MACHINE_CONFIG=$${machine_config} \
95 MAKEFILES=${SOURCE}/Makefile \
96 SOURCE=${SOURCE}/ \
97 RELATIVE_SOURCE_PATH=. \
98 TARGET=$${installinc_dir}/ \
99 build_installhdrs_mi; \
100
101 #
102 # Install machine dependent kernel header files
103 # Uses hack for machine_config, which is not threaded through properly.
104 #
105 installhdrs_md: setup
106 $(_v)kernel_config=$(INSTALL_TYPE); \
107 machine_config=$(MACHINE_CONFIG); \
108 for arch_config in $(INSTALL_ARCHS); \
109 do \
110 if [ $${arch_config} = ARM ] ; then \
111 if [ $${machine_config} = DEFAULT ] ; then \
112 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
113 fi; \
114 fi; \
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; \
120 if [ $${machine_config} = DEFAULT ] ; then \
121 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
122 else \
123 installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
124 fi; \
125 [ -d $${installinc_dir} ] || $(MKDIR) $${installinc_dir}; \
126 ${MAKE} ${MAKEJOBS} -C $${installinc_dir} \
127 KERNEL_CONFIG=$${kernel_config} \
128 ARCH_CONFIG=$${arch_config} \
129 MACHINE_CONFIG=$${machine_config} \
130 MAKEFILES=${SOURCE}/Makefile \
131 SOURCE=${SOURCE}/ \
132 RELATIVE_SOURCE_PATH=. \
133 TARGET=$${installinc_dir}/ \
134 build_installhdrs_md; \
135 done;
136
137 #
138 # Install machine independent kernel header files
139 #
140 do_installhdrs_mi:
141
142 BUILD_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}/ \
152 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installinc_subdir} \
153 TARGET=$(TARGET)$${installinc_subdir}/ \
154 build_installhdrs_mi;
155
156 build_installhdrs_mi: $(BUILD_INSTALLHDRS_MI_SUBDIRS_TARGETS)
157 $(_v)${MAKE} do_installhdrs_mi;
158
159 #
160 # Install machine dependent kernel header files
161 #
162 do_installhdrs_md:
163
164 BUILD_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}/ \
174 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installinc_subdir} \
175 TARGET=$(TARGET)$${installinc_subdir}/ \
176 build_installhdrs_md;
177
178 build_installhdrs_md: $(BUILD_INSTALLHDRS_MD_SUBDIRS_TARGETS)
179 $(_v)${MAKE} do_installhdrs_md;
180
181 #
182 # Install kernel header files
183 #
184 .PHONY: exporthdrs
185
186 exporthdrs: exporthdrs_mi exporthdrs_md
187
188 #
189 # Install header files order
190 #
191 .ORDER: exporthdrs_mi exporthdrs_md
192 .PHONY: exporthdrs_mi exporthdrs_md
193
194 #
195 # Install machine independent header files
196 #
197 do_exporthdrs_mi:
198
199 exporthdrs_mi:
200 $(_v)kernel_config=$(INSTALL_TYPE); \
201 arch_config=$(INSTALL_ARCH_DEFAULT); \
202 machine_config=DEFAULT; \
203 if [ $${arch_config} = ARM ] ; then \
204 if [ $${machine_config} = DEFAULT ] ; then \
205 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
206 fi; \
207 fi; \
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; \
213 if [ $${machine_config} = DEFAULT ] ; then \
214 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
215 else \
216 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
217 fi; \
218 [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir}; \
219 ${MAKE} ${MAKEJOBS} -C $${exportinc_dir} \
220 KERNEL_CONFIG=$${kernel_config} \
221 ARCH_CONFIG=$${arch_config} \
222 MACHINE_CONFIG=$${machine_config} \
223 MAKEFILES=${SOURCE}/Makefile \
224 SOURCE=${SOURCE}/ \
225 RELATIVE_SOURCE_PATH=. \
226 TARGET=$${exportinc_dir}/ \
227 build_exporthdrs_mi; \
228
229 #
230 # Install machine dependent kernel header files
231 #
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.
238 exporthdrs_md:
239 $(_v)my_counter=1; \
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; \
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; \
272 if [ $${machine_config} = DEFAULT ] ; then \
273 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
274 else \
275 exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
276 fi; \
277 [ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir}; \
278 ${MAKE} ${MAKEJOBS} -C $${exportinc_dir} \
279 KERNEL_CONFIG=$${kernel_config} \
280 ARCH_CONFIG=$${arch_config} \
281 MACHINE_CONFIG=$${machine_config} \
282 MAKEFILES=${SOURCE}/Makefile \
283 SOURCE=${SOURCE}/ \
284 RELATIVE_SOURCE_PATH=. \
285 TARGET=$${exportinc_dir}/ \
286 build_exporthdrs_md; \
287 fi; \
288 fi; \
289 done;
290
291 #
292 # Install machine independent kernel header files
293 #
294 do_exporthdrs_mi:
295
296 BUILD_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}/ \
306 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${exportinc_subdir} \
307 TARGET=$(TARGET)$${exportinc_subdir}/ \
308 build_exporthdrs_mi;
309
310 build_exporthdrs_mi: $(BUILD_EXPORTHDRS_MI_SUBDIRS_TARGETS)
311 $(_v)${MAKE} do_exporthdrs_mi;
312
313 #
314 # Install machine dependent kernel header files
315 #
316 do_exporthdrs_md:
317
318 BUILD_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}/ \
328 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${exportinc_subdir} \
329 TARGET=$(TARGET)$${exportinc_subdir}/ \
330 build_exporthdrs_md;
331
332 build_exporthdrs_md: $(BUILD_EXPORTHDRS_MD_SUBDIRS_TARGETS)
333 $(_v)${MAKE} do_exporthdrs_md;
334
335 #
336 # Setup pass for all architectures for all Configuration/Architecture options
337 #
338 .PHONY: setup
339
340 setup:
341 $(_v)kernel_config=$(INSTALL_TYPE); \
342 arch_config=$(INSTALL_ARCH_DEFAULT); \
343 setup_subdir=${OBJROOT}/$${RELATIVE_SOURCE_PATH}; \
344 [ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir}; \
345 ${MAKE} ${MAKEJOBS} -C $${setup_subdir} \
346 KERNEL_CONFIG=$${kernel_config} \
347 ARCH_CONFIG=$${arch_config} \
348 MACHINE_CONFIG=$${machine_config} \
349 MAKEFILES=${SOURCE}/Makefile \
350 SOURCE=${SOURCE}/ \
351 RELATIVE_SOURCE_PATH=. \
352 TARGET=$${setup_subdir}/ \
353 build_setup;
354
355 do_build_setup:
356
357 BUILD_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}; \
364 ${MAKE} -C $${setup_subdir} \
365 MAKEFILES=${SOURCE}/$${setup_subdir}/Makefile \
366 SOURCE=${SOURCE}/$${setup_subdir}/ \
367 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}/$${setup_subdir} \
368 TARGET=${TARGET}/$${setup_subdir}/ \
369 build_setup;
370
371 build_setup: $(BUILD_SETUP_SUBDIRS_TARGETS)
372 $(_v)${MAKE} do_build_setup;
373
374
375 #
376 # Build all architectures for all Configuration/Architecture options
377 #
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 #
382 .PHONY: all
383
384 ifeq ($(RC_ProjectName),Libsyscall)
385 all:
386 cd libsyscall ; \
387 sdk="$(SDKROOT)" ; \
388 if [ $${sdk} = / ] ; then \
389 sdk="" ; \
390 fi; \
391 xcrun -sdk "$(SDKROOT)" xcodebuild install \
392 "SRCROOT=$(SRCROOT)/libsyscall" \
393 "OBJROOT=$(OBJROOT)" \
394 "SYMROOT=$(SYMROOT)" \
395 "DSTROOT=$(DSTROOT)" \
396 "SDKROOT=$${sdk}"
397 else ifeq ($(RC_ProjectName),libkxld)
398 all:
399 make -C libkern/kxld/ install
400 else ifeq ($(RC_ProjectName),libkxld_host)
401 all:
402 make -C libkern/kxld/ install PRODUCT_TYPE=ARCHIVE
403 else ifeq ($(RC_ProjectName),libkmod)
404 all:
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}"
416 else ifeq ($(findstring _headers_Sim,$(RC_ProjectName)),_headers_Sim) # Libsyscall/xnu _headers_Sim
417 all: exporthdrs
418 else # xnu or xnu_debug
419 ifeq ($(COMPONENT), .)
420 all: exporthdrs setup
421 else
422 all:
423 endif
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; \
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; \
452 if [ $${machine_config} = DEFAULT ] ; then \
453 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
454 else \
455 build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
456 fi; \
457 [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir}; \
458 ${MAKE} ${MAKEJOBS} -C $${build_subdir} \
459 KERNEL_CONFIG=$${kernel_config} \
460 ARCH_CONFIG=$${arch_config} \
461 MACHINE_CONFIG=$${machine_config} \
462 MAKEFILES=${SOURCE}/Makefile \
463 SOURCE=${SOURCE}/ \
464 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
465 build_all; \
466 fi; \
467 done;
468 endif
469
470 .PHONY: all_embedded all_devicemap
471 all_embedded all_devicemap: all
472
473 #
474 # Build all architectures for all Configuration/Architecture options
475 #
476 do_build_all:
477
478 BUILD_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):
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; \
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}/ \
493 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${comp_subdir} \
494 TARGET=$${TARGET} \
495 build_all;
496
497 build_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; \
504 _TMP_comp_subdir="$(CONFIG_SUBDIRS) $($(addprefix CONFIG_SUBDIRS_, $(ARCH_CONFIG)))"; \
505 for comp_subdir in $${_TMP_comp_subdir}; \
506 do \
507 [ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir}; \
508 ${MAKE} -C $${comp_subdir} \
509 MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile \
510 SOURCE=${SOURCE}$${comp_subdir}/ \
511 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${comp_subdir} \
512 TARGET=$${TARGET} \
513 build_all; \
514 done;
515
516
517 #
518 # Build all architectures for all Configuration/Architecture options
519 #
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 #
524 mach_kernel:
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; \
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; \
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}; \
559 ${MAKE} ${MAKEJOBS} -C $${build_subdir} \
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; \
568 done;
569
570 #
571 # Build all architectures for all Configuration/Architecture options
572 #
573 do_build_mach_kernel:
574
575 build_mach_kernel:
576 $(_v)${MAKE} do_build_mach_kernel;
577
578
579 #
580 #
581 # Install dependencies order
582 #
583 .ORDER: installhdrs exporthdrs all
584
585 #
586 # Install kernel based on RC_ARCHS for all INSTALL_TYPES
587 # Install kernel header files based on RC_ARCHS
588 #
589 install: installhdrs all installman installmachinekernels
590 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
591 # nothing to do
592 else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
593 # nothing to do, work performed in "all" action
594 else ifeq ($(RC_ProjectName),libkmod)
595 # nothing to do, work performed in "all" action
596 else ifeq ($(findstring _headers_Sim,$(RC_ProjectName)),_headers_Sim)
597 # nothing to do
598 else # xnu or xnu_debug
599 # A bit of a hack for machine_config: machine configs aren't really threaded through properly.
600 $(_v)machine_config=$(MACHINE_CONFIG); \
601 for kernel_config in $(INSTALL_TYPE); \
602 do \
603 for arch_config in $(INSTALL_ARCHS); \
604 do \
605 if [ $${arch_config} = ARM ] ; then \
606 if [ $${machine_config} = DEFAULT ] ; then \
607 machine_config=$(DEFAULT_ARM_MACHINE_CONFIG); \
608 fi; \
609 fi; \
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; \
615 if [ $${machine_config} = DEFAULT ] ; then \
616 install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/${RELATIVE_SOURCE_PATH}; \
617 else \
618 install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/${RELATIVE_SOURCE_PATH}; \
619 fi; \
620 [ -d $${install_subdir} ] || $(MKDIR) $${install_subdir}; \
621 ${MAKE} ${MAKEJOBS} -C $${install_subdir} \
622 KERNEL_CONFIG=$${kernel_config} \
623 ARCH_CONFIG=$${arch_config} \
624 MACHINE_CONFIG=$${machine_config} \
625 MAKEFILES=${SOURCE}/Makefile \
626 SOURCE=${SOURCE}/ \
627 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
628 build_install; \
629 done; \
630 done;
631 ifeq ($(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)/
639 endif
640 endif
641
642 .PHONY: install_embedded install_devicemap
643 install_embedded install_devicemap: install
644
645 installmachinekernels:
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}; \
667 install_kernel_file=mach.`printf "%s" "$${kernel_config}" | $(TR) A-Z a-z`.`printf "%s" "$${machine_config}" | $(TR) A-Z a-z`; \
668 [ -d $${build_subdir} ] || $(MKDIR) $${build_subdir}; \
669 ${MAKE} ${MAKEJOBS} -C $${build_subdir} \
670 INSTALL_KERNEL_FILE=$${install_kernel_file} \
671 KERNEL_CONFIG=$${kernel_config} \
672 ARCH_CONFIG=$${arch_config} \
673 MACHINE_CONFIG=$${machine_config} \
674 MAKEFILES=${SOURCE}/Makefile \
675 SOURCE=${SOURCE}/ \
676 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
677 TARGET=$${build_subdir}/ \
678 do_build_install; \
679 fi; \
680 fi; \
681 done;
682
683 #
684 # Install for all architectures for all Configuration/Architecture options
685 #
686 setup_build_install:
687
688 do_build_install:
689
690 BUILD_INSTALL_SUBDIRS_TARGETS = $(addprefix build_install_,$(INST_SUBDIRS))
691
692 .PHONY: $(BUILD_INSTALL_SUBDIRS_TARGETS)
693
694 $(BUILD_INSTALL_SUBDIRS_TARGETS):
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; \
700 ${MAKE} TARGET=$${TARGET} setup_build_install; \
701 kernel_config=$(KERNEL_CONFIG); \
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}/ \
708 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH}/$${install_subdir} \
709 TARGET=$${TARGET} \
710 build_install;
711
712 build_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;
719
720
721 #
722 # Install source tree
723 #
724 .PHONY: installsrc
725
726 installsrc:
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 -)
728
729
730 #
731 # Clean up source tree
732 #
733 .PHONY: clean
734
735 clean:
736
737 #
738 # Build source file list for cscope database and tags
739 #
740 cscope.files:
741 @echo "Building file list for cscope and tags"
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
751
752 #
753 # Build cscope database
754 #
755 cscope: cscope.files
756 @echo "Building cscope database"
757 @cscope -bvU 2> /dev/null
758
759 #
760 # Build tags
761 #
762
763 tags: cscope.files
764 @echo "Building ctags"
765 @-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
766 echo "Phantom files detected!" 2>&1 > /dev/null
767 @-[ -f TAGS ] || ${MAKE} TAGS
768
769 TAGS: cscope.files
770 @echo "Building etags"
771 @-cat cscope.files | etags -l auto -S - 2> /dev/null
772
773 #
774 # Install Man Pages
775 #
776 .PHONY: installman
777
778 installman:
779 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
780 # nothing to do
781 else ifeq ($(findstring libkxld,$(RC_ProjectName)),libkxld)
782 # nothing to do
783 else ifeq ($(RC_ProjectName),libkmod)
784 # nothing to do
785 else ifeq ($(findstring xnu_,$(RC_ProjectName)),xnu_)
786 installman:
787 # nothing to do
788 else # xnu
789 @echo "[ $(SRCROOT) ] Installing man pages"
790 $(_v)manpath=$(DSTROOT)/$(MANDIR); \
791 [ -d $$manpath ] || $(MKDIR) $$manpath; \
792 ${MAKE} ${MAKEJOBS} MAKEFILES=${SOURCE}/Makefile \
793 SOURCE=${SOURCE}/ \
794 RELATIVE_SOURCE_PATH=${RELATIVE_SOURCE_PATH} \
795 TARGET=${DSTROOT}/ \
796 build_installman
797 ${SRCROOT}/config/compress-man-pages.pl ${DSTROOT}/${MANDIR}
798 endif
799
800 do_installman:
801
802 BUILD_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}/ \
811 RELATIVE_SOURCE_PATH=$(RELATIVE_SOURCE_PATH)/$${installman_subdir} \
812 TARGET=$(TARGET)$${installman_subdir}/ \
813 build_installman;
814
815 build_installman: $(BUILD_INSTALLMAN_SUBDIRS_TARGETS)
816 $(_v)if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
817 ${MAKE} do_installman; \
818 fi
819
820 # vim: set ft=make: