1#
2# Install kernel header files
3#
4ifeq ($(RC_ProjectName),Libsyscall)
5installhdrs:
6	bsdmake -C libsyscall installhdrs
7else # xnu
8installhdrs: exporthdrs installhdrs_mi installhdrs_md 
9	@echo "[ $(SRCROOT) ] make installhdrs installing Kernel.framework"
10	$(_v)kincpath=$(DSTROOT)/$(KINCDIR);					\
11	krespath=$(DSTROOT)/$(KRESDIR);					\
12	kframepath=$(DSTROOT)/$(KINCFRAME);				\
13	[ -d $$krespath ] || $(MKDIR) $$krespath;			\
14	[ -d $$kincpath ] || $(MKDIR) $$kincpath;			\
15	cd $(SRCROOT)/EXTERNAL_HEADERS;					\
16		install $(FILE_INSTALL_FLAGS) Info.plist $$krespath;	\
17		$(SRCROOT)/config/newvers.pl $${krespath}/Info.plist;	\
18	cd $$kframepath/Versions;					\
19	    [ -L Current ] || $(LN) $(KINCVERS) Current;		\
20	cd $$kframepath;						\
21	    [ -L Headers ] || $(LN) Versions/Current/Headers Headers;	\
22	    [ -L Resources ] || $(LN) Versions/Current/Resources Resources;	\
23	[ -d $(DSTROOT)/$(KPINCDIR) ] || $(MKDIR) $(DSTROOT)/$(KPINCDIR);	\
24	cd $$kframepath; [ -L PrivateHeaders ] ||		 	\
25	    $(LN) Versions/Current/PrivateHeaders PrivateHeaders;
26endif
27
28#
29# Install header files order
30#
31.ORDER: installhdrs_mi installhdrs_md
32
33#
34# Install machine independent header files
35#
36installhdrs_mi:
37	$(_v)rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));			\
38	kernel_config=$(INSTALL_TYPE);					\
39	arch_config=$(INSTALL_ARCH_DEFAULT);					\
40	installinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};	\
41	[ -d $${installinc_dir} ] ||$(MKDIR) $${installinc_dir};	\
42	${MAKE} -C $${installinc_dir}					\
43		KERNEL_CONFIG=$${kernel_config}				\
44		ARCH_CONFIG=$${arch_config}				\
45		MAKEFILES=${SOURCE}/Makefile				\
46		SOURCE=${SOURCE}/					\
47		TARGET=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}/	\
48		build_installhdrs_mi;					\
49
50#
51# Install machine dependent kernel header files 
52#
53installhdrs_md:
54	$(_v)rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));			\
55	kernel_config=$(INSTALL_TYPE);					\
56	machine_config=$(MACHINE_CONFIG);		\
57	for arch_config in $(INSTALL_ARCHS);				\
58	do								\
59	if [ $${arch_config} = ARM ] ; then	\
60		if [ $${machine_config} = DEFAULT ] ; then	\
61			machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);		\
62		fi;		\
63	fi;		\
64	if [ $${machine_config} = DEFAULT ] ; then	\
65		objpath=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};	\
66	else		\
67		objpath=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/$${rel_path};	\
68	fi;		\
69	[ -d $${objpath} ] || $(MKDIR) $${objpath};	\
70	${MAKE} -C $${objpath}	\
71		KERNEL_CONFIG=$${kernel_config}				\
72		ARCH_CONFIG=$${arch_config}				\
73		MAKEFILES=${SOURCE}/Makefile				\
74		SOURCE=${SOURCE}/					\
75		TARGET=$${objpath}/			\
76		build_installhdrs_md;					\
77	done;
78
79#
80# Install machine independent kernel header files 
81#
82do_installhdrs_mi:
83
84build_installhdrs_mi::
85	@echo "[ $(SOURCE) ] make build_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
86	$(_v)for installinc_subdir in $(INSTINC_SUBDIRS);			\
87	do								\
88		[ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir};		\
89		${MAKE} -C $${installinc_subdir}			\
90			MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile	\
91			SOURCE=$(SOURCE)$${installinc_subdir}/		\
92			TARGET=$(TARGET)$${installinc_subdir}/		\
93		build_installhdrs_mi;					\
94	done;								\
95	${MAKE} ${MAKEJOBS} do_installhdrs_mi;
96
97#
98# Install machine dependent kernel header files 
99#
100do_installhdrs_md:
101
102build_installhdrs_md::
103	@echo "[ $(SOURCE) ] make installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
104	$(_v)for installinc_subdir in $($(addprefix INSTINC_SUBDIRS_, $(ARCH_CONFIG)));		\
105	do								\
106		[ -d $${installinc_subdir} ] || $(MKDIR) $${installinc_subdir};			\
107		${MAKE} -C $${installinc_subdir}			\
108			MAKEFILES=$(SOURCE)$${installinc_subdir}/Makefile	\
109			SOURCE=$(SOURCE)$${installinc_subdir}/		\
110			TARGET=$(TARGET)$${installinc_subdir}/		\
111		build_installhdrs_md;					\
112	done;								\
113	${MAKE} ${MAKEJOBS} do_installhdrs_md;
114
115#
116# Install kernel header files
117#
118exporthdrs: exporthdrs_mi exporthdrs_md 
119
120#
121# Install header files order
122#
123.ORDER: exporthdrs_mi exporthdrs_md
124
125#
126# Install machine independent header files
127#
128do_exporthdrs_mi:
129
130exporthdrs_mi:
131	$(_v)rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));			\
132	kernel_config=$(INSTALL_TYPE);					\
133	arch_config=$(INSTALL_ARCH_DEFAULT);					\
134	exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};	\
135	[ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir};					\
136	${MAKE} -C $${exportinc_dir}					\
137		KERNEL_CONFIG=$${kernel_config}				\
138		ARCH_CONFIG=$${arch_config}				\
139		MAKEFILES=${SOURCE}/Makefile				\
140		SOURCE=${SOURCE}/					\
141		TARGET=$${exportinc_dir}/				\
142		build_exporthdrs_mi;					\
143
144#
145# Install machine dependent kernel header files 
146#
147# Note - installation of machine dependent kernel header files only occurs for architecture
148# defined in INSTALL_TYPE.  We use skipit variable to skip over architectures that are not
149# equal to what is in the INSTALL_TYPE variable.
150# TARGET_CONFIGS_UC variable holds sets of three configuration options.  The first item in the
151# set is the kernel configuration.  The second item in the set is the architecture and the 
152# third item is the machine configuration.  There may be multiple sets to build.
153exporthdrs_md:
154	$(_v)rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));			\
155	my_counter=1;		\
156	for my_config in $(TARGET_CONFIGS_UC);				\
157	do		\
158	if [ $${my_counter} -eq 1 ] ; then	\
159		skipit=0;			\
160		my_counter=2;		\
161		kernel_config=$${my_config};		\
162		if [ $${kernel_config} = DEFAULT ] ; then	\
163			kernel_config=$(DEFAULT_KERNEL_CONFIG);		\
164		fi;		\
165		if [ $${kernel_config} != $(INSTALL_TYPE) ] ; then	\
166			skipit=1;	\
167		fi;		\
168	elif [ $${my_counter} -eq 2 ] ; then	\
169		my_counter=3;		\
170		arch_config=$${my_config};		\
171		if [ $${arch_config} = DEFAULT ] ; then	\
172			arch_config=`arch | $(TR) a-z A-Z`;		\
173		fi;		\
174	else		\
175		my_counter=1;		\
176		machine_config=$${my_config};		\
177		if [ $${skipit} -eq 0 ] ; then	\
178			if [ $${arch_config} = ARM ] ; then	\
179				if [ $${machine_config} = DEFAULT ] ; then	\
180					machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);		\
181				fi;		\
182			fi;		\
183			if [ $${machine_config} = DEFAULT ] ; then	\
184				exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};	\
185			else		\
186				exportinc_dir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/$${rel_path};	\
187			fi;		\
188			[ -d $${exportinc_dir} ] || $(MKDIR) $${exportinc_dir};					\
189			${MAKE} -C $${exportinc_dir}					\
190				KERNEL_CONFIG=$${kernel_config}				\
191				ARCH_CONFIG=$${arch_config}				\
192				MAKEFILES=${SOURCE}/Makefile				\
193				SOURCE=${SOURCE}/					\
194				TARGET=$${exportinc_dir}/				\
195				build_exporthdrs_md;					\
196		fi;		\
197	fi;		\
198	done;
199
200#
201# Install machine independent kernel header files 
202#
203do_exporthdrs_mi:
204
205build_exporthdrs_mi:
206	$(_v)_TMP_EXPINC_SUBDIRS="$(EXPINC_SUBDIRS)";			\
207	for exportinc_subdir in $${_TMP_EXPINC_SUBDIRS};		\
208	do								\
209		[ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir};				\
210		${MAKE} -C $${exportinc_subdir}				\
211			MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile	\
212			SOURCE=$(SOURCE)$${exportinc_subdir}/		\
213			TARGET=$(TARGET)$${exportinc_subdir}/		\
214		build_exporthdrs_mi;					\
215	done;								\
216	${MAKE} ${MAKEJOBS} do_exporthdrs_mi;
217
218#
219# Install machine dependent kernel header files 
220#
221do_exporthdrs_md:
222
223build_exporthdrs_md:
224	$(_v)_TMP_exportinc_subdir="$($(addprefix EXPINC_SUBDIRS_, $(ARCH_CONFIG)))";	\
225	for exportinc_subdir in $${_TMP_exportinc_subdir};			\
226	do								\
227		[ -d $${exportinc_subdir} ] || $(MKDIR) $${exportinc_subdir};				\
228		${MAKE} -C $${exportinc_subdir}				\
229			MAKEFILES=$(SOURCE)$${exportinc_subdir}/Makefile	\
230			SOURCE=$(SOURCE)$${exportinc_subdir}/		\
231			TARGET=$(TARGET)$${exportinc_subdir}/		\
232		build_exporthdrs_md;					\
233	done;								\
234	${MAKE} ${MAKEJOBS} do_exporthdrs_md;
235
236#
237# Setup pass for  all architectures for all Configuration/Architecture options
238#
239setup:
240	$(_v)rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));			\
241	for kernel_config in $(KERNEL_CONFIGS);				\
242	do								\
243	for arch_config in $(ARCH_CONFIGS);				\
244	do								\
245	setup_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}; \
246	[ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir};					\
247	${MAKE} -C $${setup_subdir}					\
248		KERNEL_CONFIG=$${kernel_config}				\
249		ARCH_CONFIG=$${arch_config}				\
250		MAKEFILES=${SOURCE}/Makefile				\
251		SOURCE=${SOURCE}/					\
252		TARGET=$${setup_subdir}/				\
253	build_setup;							\
254	done;								\
255	done;
256
257do_build_setup:
258
259build_setup:
260	$(_v)_TMP_setup_subdir="$(SETUP_SUBDIRS) $($(addprefix SETUP_SUBDIRS_, $(ARCH_CONFIG)))";	\
261	for setup_subdir in $${_TMP_setup_subdir};		\
262	do							\
263	[ -d $${setup_subdir} ] || $(MKDIR) $${setup_subdir};				\
264	${MAKE} -C $${setup_subdir}				\
265		MAKEFILES=${SOURCE}/$${setup_subdir}/Makefile	\
266		SOURCE=${SOURCE}/$${setup_subdir}/		\
267		TARGET=${TARGET}/$${setup_subdir}/		\
268		build_setup;					\
269	done;							\
270	${MAKE} do_build_setup;
271
272
273#
274# Build all architectures for all Configuration/Architecture options
275#
276# Note - TARGET_CONFIGS_UC variable holds sets of three configuration options.  The first 
277# item in the set is the kernel configuration.  The second item in the set is the architecture  
278# and the third item is the machine configuration.  There may be multiple sets to build.
279#
280ifeq ($(RC_ProjectName),Libsyscall)
281all:
282	bsdmake -C libsyscall install
283else # xnu
284ifeq ($(COMPONENT), .)
285all: exporthdrs
286else
287all:
288endif
289	$(_v)my_counter=1;		\
290	for my_config in $(TARGET_CONFIGS_UC);				\
291	do		\
292	if [ $${my_counter} -eq 1 ] ; then	\
293		my_counter=2;		\
294		kernel_config=$${my_config};		\
295		if [ $${kernel_config} = DEFAULT ] ; then	\
296			kernel_config=$(DEFAULT_KERNEL_CONFIG);		\
297		fi;		\
298	elif [ $${my_counter} -eq 2 ] ; then	\
299		my_counter=3;		\
300		arch_config=$${my_config};		\
301		if [ $${arch_config} = DEFAULT ] ; then	\
302			arch_config=`arch | $(TR) a-z A-Z`;		\
303		fi;		\
304	else		\
305		my_counter=1;		\
306		machine_config=$${my_config};		\
307		if [ $${arch_config} = ARM ] ; then	\
308			if [ $${machine_config} = DEFAULT ] ; then	\
309				machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);		\
310			fi;		\
311		fi;		\
312		if [ $${machine_config} = DEFAULT ] ; then	\
313			build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path}; \
314		else		\
315			build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/$${rel_path}; \
316		fi;		\
317		[ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};					\
318			${MAKE} -C $${build_subdir}					\
319				KERNEL_CONFIG=$${kernel_config}				\
320				ARCH_CONFIG=$${arch_config}			\
321				MACHINE_CONFIG=$${machine_config}			\
322				MAKEFILES=${SOURCE}/Makefile 				\
323				SOURCE=${SOURCE}/					\
324				build_all;						\
325	fi;		\
326	done;
327endif
328
329#
330# Build all architectures for all Configuration/Architecture options
331#
332do_build_all:
333
334build_all: 
335	$(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then  \
336		TARGET=$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT);	\
337	else		\
338		TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)";	\
339	fi;		\
340	_TMP_comp_subdir="$(COMP_SUBDIRS) $($(addprefix COMP_SUBDIRS_, $(ARCH_CONFIG)))";	\
341	for comp_subdir in $${_TMP_comp_subdir};			\
342	do								\
343		[ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir};				\
344		${MAKE} -C $${comp_subdir}				\
345			MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile	\
346			SOURCE=${SOURCE}$${comp_subdir}/		\
347			TARGET=$${TARGET}				\
348		build_all;						\
349	done;								\
350	${MAKE} ${MAKEJOBS} INCL_MAKEDEP=TRUE TARGET=$${TARGET} do_build_all;	\
351	_TMP_comp_subdir="$(CONFIG_SUBDIRS) $($(addprefix CONFIG_SUBDIRS_, $(ARCH_CONFIG)))";	\
352	for comp_subdir in $${_TMP_comp_subdir};			\
353	do								\
354		[ -d $${comp_subdir} ] || $(MKDIR) $${comp_subdir};				\
355		${MAKE} -C $${comp_subdir}				\
356			MAKEFILES=${SOURCE}/$${comp_subdir}/Makefile	\
357			SOURCE=${SOURCE}$${comp_subdir}/		\
358			TARGET=$${TARGET}				\
359		build_all;						\
360	done;								
361	
362
363#
364# Build all architectures for all Configuration/Architecture options
365#
366# Note - TARGET_CONFIGS_UC variable holds sets of three configuration options.  The first 
367# item in the set is the kernel configuration.  The second item is the architecture  
368# and the third item is the machine configuration.  There may be multiple sets to build.
369#
370mach_kernel:
371	$(_v)my_counter=1;		\
372	for my_config in $(TARGET_CONFIGS_UC);				\
373	do		\
374	if [ $${my_counter} -eq 1 ] ; then	\
375		my_counter=2;		\
376		kernel_config=$${my_config};		\
377		if [ $${kernel_config} = DEFAULT ] ; then	\
378			kernel_config=$(DEFAULT_KERNEL_CONFIG);		\
379		fi;		\
380	elif [ $${my_counter} -eq 2 ] ; then	\
381		my_counter=3;		\
382		arch_config=$${my_config};		\
383		if [ $${arch_config} = DEFAULT ] ; then	\
384			arch_config=`arch | $(TR) a-z A-Z`;		\
385		fi;		\
386	else		\
387		my_counter=1;		\
388		machine_config=$${my_config};		\
389		if [ $${arch_config} = ARM ] ; then	\
390			if [ $${machine_config} = DEFAULT ] ; then	\
391				machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);		\
392			fi;		\
393		fi;		\
394		if [ $${machine_config} = DEFAULT ] ; then	\
395			build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config};	\
396		else		\
397			build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config};	\
398		fi;		\
399		[ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};					\
400		${MAKE} -C $${build_subdir}					\
401			KERNEL_CONFIG=$${kernel_config}				\
402			ARCH_CONFIG=$${arch_config}				\
403			MACHINE_CONFIG=$${machine_config}			\
404			MAKEFILES=${SOURCE}/Makefile 				\
405			SOURCE=${SOURCE}/					\
406			TARGET=$${build_subdir}/				\
407			build_mach_kernel;					\
408	fi;		\
409	done;
410
411#
412# Build all architectures for all Configuration/Architecture options
413#
414do_build_mach_kernel:
415
416build_mach_kernel: 
417	$(_v)${MAKE} ${MAKEJOBS} do_build_mach_kernel;
418
419
420#
421#
422# Install dependencies order
423#
424.ORDER: installhdrs exporthdrs all
425
426#
427# Install kernel based on RC_ARCHS for all INSTALL_TYPES
428# Install kernel header files based on RC_ARCHS
429#
430install: installhdrs all installman installmachinekernels
431ifeq ($(RC_ProjectName),Libsyscall)
432# nothing to do
433else # xnu
434	$(_v)rel_path=$(shell $(RELPATH) $(SRCROOT) $(SOURCE));			\
435	machine_config=$(MACHINE_CONFIG);		\
436	for kernel_config in $(INSTALL_TYPE);				\
437	do								\
438	for arch_config in $(INSTALL_ARCHS);				\
439	do								\
440	if [ $${arch_config} = ARM ] ; then	\
441		if [ $${machine_config} = DEFAULT ] ; then	\
442			machine_config=$(DEFAULT_ARM_MACHINE_CONFIG);		\
443		fi;		\
444	fi;		\
445	if [ $${machine_config} = DEFAULT ] ; then	\
446		install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}/$${rel_path};	\
447	else		\
448		install_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config}/$${rel_path};	\
449	fi;		\
450	[ -d $${install_subdir} ] || $(MKDIR) $${install_subdir};					\
451	${MAKE} -C $${install_subdir}					\
452		KERNEL_CONFIG=$${kernel_config}				\
453		ARCH_CONFIG=$${arch_config}				\
454		MACHINE_CONFIG=$${machine_config}			\
455		MAKEFILES=${SOURCE}/Makefile 				\
456		SOURCE=${SOURCE}/					\
457		build_install;						\
458	done;								\
459	done;
460endif
461
462installmachinekernels:
463	@echo "[ $(SOURCE) ] make installmachinekernels";				\
464	my_counter=1;		\
465	for my_config in $(TARGET_CONFIGS_UC);				\
466	do		\
467	if [ $${my_counter} -eq 1 ] ; then	\
468		my_counter=2;		\
469		kernel_config=$${my_config};		\
470		if [ $${kernel_config} = DEFAULT ] ; then	\
471			kernel_config=$(DEFAULT_KERNEL_CONFIG);		\
472		fi;		\
473	elif [ $${my_counter} -eq 2 ] ; then	\
474		my_counter=3;		\
475		arch_config=$${my_config};		\
476		if [ $${arch_config} = DEFAULT ] ; then	\
477			arch_config=`arch | $(TR) a-z A-Z`;		\
478		fi;		\
479	else		\
480		my_counter=1;		\
481		machine_config=$${my_config};		\
482		if [ $${machine_config} != DEFAULT ] ; then	\
483			build_subdir=${OBJROOT}/$${kernel_config}_$${arch_config}_$${machine_config};	\
484			install_file_list=mach.`printf "%s" "$${kernel_config}" | $(TR) A-Z a-z`.`printf "%s" "$${machine_config}" | $(TR) A-Z a-z`;	\
485			[ -d $${build_subdir} ] || $(MKDIR) $${build_subdir};					\
486			${MAKE} -C $${build_subdir}					\
487				INSTALL_FILE_LIST=$${install_file_list}			\
488				KERNEL_CONFIG=$${kernel_config}				\
489				ARCH_CONFIG=$${arch_config}				\
490				MACHINE_CONFIG=$${machine_config}			\
491				MAKEFILES=${SOURCE}/Makefile 				\
492				SOURCE=${SOURCE}/					\
493				TARGET=$${build_subdir}/				\
494				do_build_install;					\
495		fi;		\
496	fi;		\
497	done;
498
499#
500# Install for all architectures for all Configuration/Architecture options
501#
502setup_build_install:
503
504do_build_install:
505
506build_install: 
507	$(_v)if [ $(MACHINE_CONFIG) = DEFAULT ] ; then  \
508		TARGET=${OBJROOT}/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(COMPONENT);	\
509	else		\
510		TARGET="$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)_$(MACHINE_CONFIG)/$(COMPONENT)";	\
511	fi;		\
512	${MAKE} TARGET=$${TARGET} setup_build_install;			\
513	kernel_config=$(KERNEL_CONFIG);					\
514	for install_subdir in $(INST_SUBDIRS);				\
515	do								\
516		[ -d $${install_subdir} ] || $(MKDIR) $${install_subdir};				\
517		${MAKE} -C $${install_subdir}				\
518			KERNEL_CONFIG=$${kernel_config}			\
519			MAKEFILES=${SOURCE}/$${install_subdir}/Makefile	\
520			SOURCE=${SOURCE}$${install_subdir}/		\
521			TARGET=$${TARGET}				\
522		build_install;						\
523	done;								\
524	${MAKE} ${MAKEJOBS} TARGET=$${TARGET} do_build_install;
525
526
527#
528# Install source tree
529#
530installsrc:
531	$(_v)(tar -c --mode go=r,+X --no-ignore-case --exclude .svn --exclude cscope.\* --exclude BUILD --exclude \*~ -f - .) | (cd $(SRCROOT) && tar --no-same-owner -xf -)
532
533
534#
535# Clean up source tree
536#
537clean:
538
539#
540# Build source file list for cscope database and tags
541#
542cscope.files:
543	@echo "Building file list for cscope and tags"
544	@find . -name '*.h' -type f | grep -v ^..BUILD > _cscope.files 2> /dev/null
545	@find . -name '*.defs' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
546	@find . -name '*.c' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
547	@find . -name '*.cpp' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
548	@find . -name '*.s' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
549	@find . -name '*.h.template' -type f | grep -v ^..BUILD >> _cscope.files 2> /dev/null
550	@echo -k -q -c > cscope.files 2> /dev/null
551	@sort -u < _cscope.files >> cscope.files 2> /dev/null
552	@rm -f _cscope.files _cscope.files2 2> /dev/null
553
554#
555# Build cscope database
556#
557cscope: cscope.files
558	@echo "Building cscope database"
559	@cscope -bvU 2> /dev/null
560
561#
562# Build tags
563#
564
565tags: cscope.files
566	@echo "Building ctags"
567	@-sed 1d cscope.files | xargs ctags -dtw 2> /dev/null || \
568		echo "Phantom files detected!" 2>&1 > /dev/null
569	@-[ -f TAGS ] || ${MAKE} TAGS
570
571TAGS: cscope.files
572	@echo "Building etags"
573	@-cat cscope.files | etags -l auto -S - 2> /dev/null
574
575#
576# Install Man Pages
577#
578installman:
579ifeq ($(RC_ProjectName),Libsyscall)
580	bsdmake -C libsyscall install-man
581else # xnu
582	@echo "[ $(SRCROOT) ] Installing man pages"
583	$(_v)manpath=$(DSTROOT)/$(MANDIR);   \
584	[ -d $$manpath ] || $(MKDIR) $$manpath;             \
585	${MAKE} MAKEFILES=${SOURCE}/Makefile \
586		SOURCE=${SOURCE}/ \
587		TARGET=${DSTROOT}/ \
588		build_installman
589	${SOURCE}/config/compress-man-pages.pl ${DSTROOT}/${MANDIR}
590endif
591
592do_installman:
593
594build_installman:
595	@echo "[ $(SOURCE) ] make build_installman"
596	$(_v)if [ -n "$(strip $(INSTMAN_SUBDIRS))" ]; then \
597		for installman_subdir in $(INSTMAN_SUBDIRS); do \
598			${MAKE} -C $${installman_subdir} -r \
599				MAKEFILES=$(SOURCE)$${installman_subdir}/Makefile \
600				SOURCE=$(SOURCE)$${installman_subdir}/ \
601				TARGET=$(TARGET)$${installman_subdir}/ \
602				build_installman; \
603		done; \
604	fi; \
605	if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
606		${MAKE} ${MAKEJOBS} do_installman; \
607	fi
608
609# vim: set ft=make:
610