bsd.subdir.mk revision 95509
11844Swollman#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
250476Speter# $FreeBSD: head/share/mk/bsd.subdir.mk 95509 2002-04-26 17:55:27Z 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#
1595327Sobrien# DISTRIBUTION	Name of distribution. [base]
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#
2795509Sru#	afterinstall, all, all-man, beforeinstall, checkdpadd,
2895306Sru#	clean, cleandepend, cleandir, depend, install, lint,
2944922Sbde#	obj, objlink, realinstall, regress, tags
3023549Swosch#
311638Srgrimes
3294940Sru.include <bsd.init.mk>
3323549Swosch
3495306Sru_SUBDIR: .USE
3595306Sru.if defined(SUBDIR) && !empty(SUBDIR)
3690311Sru	@for entry in ${SUBDIR}; do \
3795306Sru		if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
3890311Sru			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
3990311Sru			edir=$${entry}.${MACHINE_ARCH}; \
4090311Sru			cd ${.CURDIR}/$${edir}; \
4190311Sru		else \
4290311Sru			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
4390311Sru			edir=$${entry}; \
4490311Sru			cd ${.CURDIR}/$${edir}; \
4590311Sru		fi; \
4690311Sru		${MAKE} ${.TARGET:realinstall=install} \
4795306Sru		    DIRPRFX=${DIRPRFX}$$edir/; \
481638Srgrimes	done
4995306Sru.endif
501638Srgrimes
511638Srgrimes${SUBDIR}::
5253152Smarcel	@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
5353152Smarcel		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
541638Srgrimes	else \
551638Srgrimes		cd ${.CURDIR}/${.TARGET}; \
561638Srgrimes	fi; \
571638Srgrimes	${MAKE} all
581638Srgrimes
591638Srgrimes
6095509Sru.for __target in all all-man checkdpadd clean cleandepend cleandir \
6195509Sru    depend distribute lint \
6295356Sru    obj objlink realinstall regress tags
6395306Sru${__target}: _SUBDIR
6415061Swosch.endfor
651638Srgrimes
661638Srgrimes.if !target(install)
671638Srgrimes.if !target(beforeinstall)
681638Srgrimesbeforeinstall:
691638Srgrimes.endif
701638Srgrimes.if !target(afterinstall)
711638Srgrimesafterinstall:
721638Srgrimes.endif
731638Srgrimesinstall: afterinstall
741638Srgrimesafterinstall: realinstall
7595306Srurealinstall: beforeinstall
761638Srgrimes.endif
77