bsd.subdir.mk revision 90311
11844Swollman#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
250476Speter# $FreeBSD: head/share/mk/bsd.subdir.mk 90311 2002-02-06 18:05:53Z ru $
323549Swosch#
423549Swosch# The include file <bsd.subdir.mk> contains the default targets
535784Swosch# for building subdirectories. 
623549Swosch#
723549Swosch# For all of the directories listed in the variable SUBDIRS, the
823549Swosch# specified directory will be visited and the target made. There is
923549Swosch# also a default target which allows the command "make subdir" where
1023549Swosch# subdir is any directory listed in the variable SUBDIRS.
1123549Swosch#
1223549Swosch#
1323549Swosch# +++ variables +++
1423549Swosch#
1523549Swosch# DISTRIBUTION	Name of distribution. [bin]
1623549Swosch#
1723549Swosch# SUBDIR	A list of subdirectories that should be built as well.
1823549Swosch#		Each of the targets will execute the same target in the
1923549Swosch#		subdirectories.
2023549Swosch#
2123549Swosch# +++ targets +++
2223549Swosch#
2323549Swosch#	distribute:
2423549Swosch# 		This is a variant of install, which will
2523549Swosch# 		put the stuff into the right "distribution".
2623549Swosch#
2774842Sru#	afterdistribute, afterinstall, all, all-man, beforeinstall, checkdpadd,
2823549Swosch#	clean, cleandepend, cleandir, depend, install, lint, maninstall,
2944922Sbde#	obj, objlink, realinstall, regress, tags
3023549Swosch#
311638Srgrimes
3238183Speter.if !target(__initialized__)
3338183Speter__initialized__:
3438183Speter.if exists(${.CURDIR}/../Makefile.inc)
3538183Speter.include "${.CURDIR}/../Makefile.inc"
3638183Speter.endif
3738183Speter.endif  
3823549Swosch
391638Srgrimes.MAIN: all
401638Srgrimes
411638Srgrimes_SUBDIRUSE: .USE
4290311Sru	@for entry in ${SUBDIR}; do \
4390311Sru		(if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
4490311Sru			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
4590311Sru			edir=$${entry}.${MACHINE_ARCH}; \
4690311Sru			cd ${.CURDIR}/$${edir}; \
4790311Sru		else \
4890311Sru			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
4990311Sru			edir=$${entry}; \
5090311Sru			cd ${.CURDIR}/$${edir}; \
5190311Sru		fi; \
5290311Sru		${MAKE} ${.TARGET:realinstall=install} \
5390311Sru		    DIRPRFX=${DIRPRFX}$$edir/); \
541638Srgrimes	done
551638Srgrimes
561638Srgrimes${SUBDIR}::
5753152Smarcel	@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
5853152Smarcel		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
591638Srgrimes	else \
601638Srgrimes		cd ${.CURDIR}/${.TARGET}; \
611638Srgrimes	fi; \
621638Srgrimes	${MAKE} all
631638Srgrimes
641638Srgrimes
6574842Sru.for __target in all all-man checkdpadd clean cleandepend cleandir depend lint \
6685570Sdes		 maninstall obj objlink regress tags \
6785570Sdes		 install.debug reinstall.debug
6831177Swosch.if !target(${__target})
6915061Swosch${__target}: _SUBDIRUSE
701638Srgrimes.endif
7115061Swosch.endfor
721638Srgrimes
731638Srgrimes.if !target(install)
741638Srgrimes.if !target(beforeinstall)
751638Srgrimesbeforeinstall:
761638Srgrimes.endif
771638Srgrimes.if !target(afterinstall)
781638Srgrimesafterinstall:
791638Srgrimes.endif
801638Srgrimesinstall: afterinstall
811638Srgrimesafterinstall: realinstall
821638Srgrimesrealinstall: beforeinstall _SUBDIRUSE
831638Srgrimes.endif
841638Srgrimes
8515061SwoschDISTRIBUTION?=	bin
8615061Swosch.if !target(afterdistribute)
8715061Swoschafterdistribute:
881638Srgrimes.endif
8915061Swosch.if !target(distribute)
9023549Swoschdistribute: _SUBDIRUSE
9126760Sjkh.for dist in ${DISTRIBUTION}
9226760Sjkh	cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist}
9326760Sjkh.endfor
941638Srgrimes.endif
95