bsd.subdir.mk revision 133369
11844Swollman#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
250476Speter# $FreeBSD: head/share/mk/bsd.subdir.mk 133369 2004-08-09 10:54:05Z harti $
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,
2896164Sru#	clean, cleandepend, cleandir, depend, install, lint, maninstall,
2944922Sbde#	obj, objlink, realinstall, regress, tags
3023549Swosch#
311638Srgrimes
3294940Sru.include <bsd.init.mk>
3323549Swosch
3499875SruDISTRIBUTION?=	base
3599875Sru.if !target(distribute)
3699875Srudistribute:
3799875Sru.for dist in ${DISTRIBUTION}
38133369Sharti	${_+_}cd ${.CURDIR}; \
3999875Sru	    ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
4099875Sru.endfor
4199875Sru.endif
4299875Sru
4395306Sru_SUBDIR: .USE
4499875Sru.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
45133369Sharti	@${_+_}for entry in ${SUBDIR}; do \
4695306Sru		if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
4790311Sru			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \
4890311Sru			edir=$${entry}.${MACHINE_ARCH}; \
4990311Sru			cd ${.CURDIR}/$${edir}; \
5090311Sru		else \
5190311Sru			${ECHODIR} "===> ${DIRPRFX}$$entry"; \
5290311Sru			edir=$${entry}; \
5390311Sru			cd ${.CURDIR}/$${edir}; \
5490311Sru		fi; \
5590311Sru		${MAKE} ${.TARGET:realinstall=install} \
5695306Sru		    DIRPRFX=${DIRPRFX}$$edir/; \
571638Srgrimes	done
5895306Sru.endif
591638Srgrimes
601638Srgrimes${SUBDIR}::
61133369Sharti	${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
6253152Smarcel		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
631638Srgrimes	else \
641638Srgrimes		cd ${.CURDIR}/${.TARGET}; \
651638Srgrimes	fi; \
66133369Sharti	${_+_}${MAKE} all
671638Srgrimes
681638Srgrimes
6995509Sru.for __target in all all-man checkdpadd clean cleandepend cleandir \
7096668Sru    depend distribute lint maninstall \
7195356Sru    obj objlink realinstall regress tags
7295306Sru${__target}: _SUBDIR
7315061Swosch.endfor
741638Srgrimes
7597769Sru.for __target in files includes
7696668Sru.for __stage in build install
7796668Sru${__stage}${__target}:
7896668Sru.if make(${__stage}${__target})
7996668Sru${__stage}${__target}: _SUBDIR
8096668Sru.endif
8196668Sru.endfor
8296668Sru${__target}:
83133369Sharti	${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
8496668Sru.endfor
8596668Sru
861638Srgrimes.if !target(install)
871638Srgrimes.if !target(beforeinstall)
881638Srgrimesbeforeinstall:
891638Srgrimes.endif
901638Srgrimes.if !target(afterinstall)
911638Srgrimesafterinstall:
921638Srgrimes.endif
9399215Sruinstall: beforeinstall realinstall afterinstall
9499215Sru.ORDER: beforeinstall realinstall afterinstall
951638Srgrimes.endif
96