bsd.subdir.mk revision 252048
11844Swollman#	from: @(#)bsd.subdir.mk	5.9 (Berkeley) 2/1/91
250476Speter# $FreeBSD: stable/9/share/mk/bsd.subdir.mk 252048 2013-06-20 22:50:08Z sjg $
323549Swosch#
423549Swosch# The include file <bsd.subdir.mk> contains the default targets
5139761Skrion# 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#
27200178Sed#	afterinstall, all, all-man, beforeinstall, checkdpadd, clean,
28200178Sed#	cleandepend, cleandir, cleanilinks depend, install, lint,
29200178Sed#	maninstall, manlint, 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)
45252048Ssjg	@${_+_}set -e; for entry in ${SUBDIR}; do \
4695306Sru		if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
47134903Simp			${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:realinstall=install})"; \
4890311Sru			edir=$${entry}.${MACHINE_ARCH}; \
4990311Sru			cd ${.CURDIR}/$${edir}; \
5090311Sru		else \
51134903Simp			${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \
5290311Sru			edir=$${entry}; \
5390311Sru			cd ${.CURDIR}/$${edir}; \
5490311Sru		fi; \
5590311Sru		${MAKE} ${.TARGET:realinstall=install} \
5695306Sru		    DIRPRFX=${DIRPRFX}$$edir/; \
571638Srgrimes	done
5895306Sru.endif
591638Srgrimes
60146817Sru${SUBDIR}: .PHONY
61133369Sharti	${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
6253152Smarcel		cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
631638Srgrimes	else \
641638Srgrimes		cd ${.CURDIR}/${.TARGET}; \
651638Srgrimes	fi; \
66146817Sru	${MAKE} all
671638Srgrimes
6895509Sru.for __target in all all-man checkdpadd clean cleandepend cleandir \
69200178Sed    cleanilinks depend distribute lint maninstall manlint obj objlink \
70200178Sed    realinstall regress tags ${SUBDIR_TARGETS}
7195306Sru${__target}: _SUBDIR
7215061Swosch.endfor
731638Srgrimes
7497769Sru.for __target in files includes
7596668Sru.for __stage in build install
7696668Sru${__stage}${__target}:
7796668Sru.if make(${__stage}${__target})
7896668Sru${__stage}${__target}: _SUBDIR
7996668Sru.endif
8096668Sru.endfor
8196668Sru${__target}:
82252048Ssjg	${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
8396668Sru.endfor
8496668Sru
851638Srgrimes.if !target(install)
861638Srgrimes.if !target(beforeinstall)
871638Srgrimesbeforeinstall:
881638Srgrimes.endif
891638Srgrimes.if !target(afterinstall)
901638Srgrimesafterinstall:
911638Srgrimes.endif
9299215Sruinstall: beforeinstall realinstall afterinstall
9399215Sru.ORDER: beforeinstall realinstall afterinstall
941638Srgrimes.endif
95