bsd.subdir.mk revision 95306
1204739Sjoel#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
2192551Sthompsa# $FreeBSD: head/share/mk/bsd.subdir.mk 95306 2002-04-23 09:03:56Z ru $
3192551Sthompsa#
4192551Sthompsa# The include file <bsd.subdir.mk> contains the default targets
5192551Sthompsa# for building subdirectories. 
6192551Sthompsa#
7192551Sthompsa# For all of the directories listed in the variable SUBDIRS, the
8192551Sthompsa# specified directory will be visited and the target made. There is
9192551Sthompsa# also a default target which allows the command "make subdir" where
10192551Sthompsa# subdir is any directory listed in the variable SUBDIRS.
11192551Sthompsa#
12192551Sthompsa#
13192551Sthompsa# +++ variables +++
14192551Sthompsa#
15192551Sthompsa# DISTRIBUTION	Name of distribution. [bin]
16192551Sthompsa#
17192551Sthompsa# SUBDIR	A list of subdirectories that should be built as well.
18192551Sthompsa#		Each of the targets will execute the same target in the
19192551Sthompsa#		subdirectories.
20192551Sthompsa#
21192551Sthompsa# +++ targets +++
22192551Sthompsa#
23192551Sthompsa#	distribute:
24192551Sthompsa# 		This is a variant of install, which will
2550476Speter# 		put the stuff into the right "distribution".
2644192Sn_hibma#
27262137Smarkj#	afterdistribute, afterinstall, all, all-man, beforeinstall, checkdpadd,
2853200Sphantom#	clean, cleandepend, cleandir, depend, install, lint,
2979538Sru#	obj, objlink, realinstall, regress, tags
3044192Sn_hibma#
3144192Sn_hibma
3244192Sn_hibma.include <bsd.init.mk>
3344192Sn_hibma
34164524Sbrueffer_SUBDIR: .USE
35164524Sbrueffer.if defined(SUBDIR) && !empty(SUBDIR)
36164524Sbrueffer	@for entry in ${SUBDIR}; do \
37164524Sbrueffer		if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
3856467Sasmodai			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
39164524Sbrueffer			edir=$${entry}.${MACHINE_ARCH}; \
4089891Sjoe			cd ${.CURDIR}/$${edir}; \
41164524Sbrueffer		else \
42164524Sbrueffer			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
43164524Sbrueffer			edir=$${entry}; \
44164524Sbrueffer			cd ${.CURDIR}/$${edir}; \
45164524Sbrueffer		fi; \
46164524Sbrueffer		${MAKE} ${.TARGET:realinstall=install} \
47192551Sthompsa		    DIRPRFX=${DIRPRFX}$$edir/; \
48192551Sthompsa	done
49192551Sthompsa.endif
50192551Sthompsa
51192551Sthompsa${SUBDIR}::
5244192Sn_hibma	@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
5350845Schris		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
5444192Sn_hibma	else \
5544192Sn_hibma		cd ${.CURDIR}/${.TARGET}; \
56192551Sthompsa	fi; \
5744192Sn_hibma	${MAKE} all
5844192Sn_hibma
5944192Sn_hibma
60192551Sthompsa.for __target in all all-man checkdpadd clean cleandepend cleandir depend lint \
61236443Sjoel		 obj objlink realinstall regress tags \
62192551Sthompsa		 install.debug reinstall.debug
63192551Sthompsa${__target}: _SUBDIR
64192551Sthompsa.endfor
65192551Sthompsa
66192551Sthompsa.if !target(install)
6757676Ssheldonh.if !target(beforeinstall)
68192551Sthompsabeforeinstall:
69192551Sthompsa.endif
7044192Sn_hibma.if !target(afterinstall)
7144192Sn_hibmaafterinstall:
7292585Sru.endif
7344192Sn_hibmainstall: afterinstall
7444192Sn_hibmaafterinstall: realinstall
7592585Srurealinstall: beforeinstall
7692585Sru.endif
7792585Sru
7844192Sn_hibmaDISTRIBUTION?=	bin
7944192Sn_hibma.if !target(afterdistribute)
8044192Sn_hibmaafterdistribute:
8144192Sn_hibma.endif
8244192Sn_hibma.if !target(distribute)
8344192Sn_hibmadistribute: _SUBDIR
8444192Sn_hibma.for dist in ${DISTRIBUTION}
8544192Sn_hibma	cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist}
86192551Sthompsa.endfor
87192551Sthompsa.endif
88236443Sjoel