bsd.subdir.mk revision 95327
155714Skris#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
255714Skris# $FreeBSD: head/share/mk/bsd.subdir.mk 95327 2002-04-23 22:16:41Z obrien $
355714Skris#
455714Skris# The include file <bsd.subdir.mk> contains the default targets
555714Skris# for building subdirectories. 
655714Skris#
755714Skris# For all of the directories listed in the variable SUBDIRS, the
8237657Sjkim# specified directory will be visited and the target made. There is
9237657Sjkim# also a default target which allows the command "make subdir" where
10237657Sjkim# subdir is any directory listed in the variable SUBDIRS.
11237657Sjkim#
12237657Sjkim#
13237657Sjkim# +++ variables +++
14237657Sjkim#
15237657Sjkim# DISTRIBUTION	Name of distribution. [base]
16237657Sjkim#
17237657Sjkim# SUBDIR	A list of subdirectories that should be built as well.
18237657Sjkim#		Each of the targets will execute the same target in the
19237657Sjkim#		subdirectories.
20237657Sjkim#
21237657Sjkim# +++ targets +++
22237657Sjkim#
23237657Sjkim#	distribute:
24237657Sjkim# 		This is a variant of install, which will
25237657Sjkim# 		put the stuff into the right "distribution".
26237657Sjkim#
27237657Sjkim#	afterdistribute, afterinstall, all, all-man, beforeinstall, checkdpadd,
28237657Sjkim#	clean, cleandepend, cleandir, depend, install, lint,
29237657Sjkim#	obj, objlink, realinstall, regress, tags
30237657Sjkim#
31237657Sjkim
32237657Sjkim.include <bsd.init.mk>
33237657Sjkim
34237657Sjkim_SUBDIR: .USE
35237657Sjkim.if defined(SUBDIR) && !empty(SUBDIR)
36237657Sjkim	@for entry in ${SUBDIR}; do \
37237657Sjkim		if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
38237657Sjkim			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
39237657Sjkim			edir=$${entry}.${MACHINE_ARCH}; \
40237657Sjkim			cd ${.CURDIR}/$${edir}; \
41237657Sjkim		else \
42216166Ssimon			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
43216166Ssimon			edir=$${entry}; \
44216166Ssimon			cd ${.CURDIR}/$${edir}; \
45216166Ssimon		fi; \
46216166Ssimon		${MAKE} ${.TARGET:realinstall=install} \
47215697Ssimon		    DIRPRFX=${DIRPRFX}$$edir/; \
48215697Ssimon	done
49215697Ssimon.endif
50215697Ssimon
51215697Ssimon${SUBDIR}::
52215697Ssimon	@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
53215697Ssimon		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
54215697Ssimon	else \
55215697Ssimon		cd ${.CURDIR}/${.TARGET}; \
56215697Ssimon	fi; \
57215697Ssimon	${MAKE} all
58215697Ssimon
59206046Ssimon
60206046Ssimon.for __target in all all-man checkdpadd clean cleandepend cleandir depend lint \
61206046Ssimon		 obj objlink realinstall regress tags \
62206046Ssimon		 install.debug reinstall.debug
63206046Ssimon${__target}: _SUBDIR
64205128Ssimon.endfor
65205128Ssimon
66205128Ssimon.if !target(install)
67205128Ssimon.if !target(beforeinstall)
68205128Ssimonbeforeinstall:
69205128Ssimon.endif
70205128Ssimon.if !target(afterinstall)
71205128Ssimonafterinstall:
72205128Ssimon.endif
73205128Ssimoninstall: afterinstall
74205128Ssimonafterinstall: realinstall
75205128Ssimonrealinstall: beforeinstall
76205128Ssimon.endif
77205128Ssimon
78205128SsimonDISTRIBUTION?=	base
79205128Ssimon.if !target(afterdistribute)
80194206Ssimonafterdistribute:
81194206Ssimon.endif
82194206Ssimon.if !target(distribute)
83194206Ssimondistribute: _SUBDIR
84194206Ssimon.for dist in ${DISTRIBUTION}
85194206Ssimon	cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist}
86194206Ssimon.endfor
87194206Ssimon.endif
88194206Ssimon