bsd.subdir.mk revision 95356
1228753Smm# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 2228753Smm# $FreeBSD: head/share/mk/bsd.subdir.mk 95356 2002-04-24 11:26:19Z ru $ 3228753Smm# 4228753Smm# The include file <bsd.subdir.mk> contains the default targets 5228753Smm# for building subdirectories. 6228753Smm# 7228753Smm# For all of the directories listed in the variable SUBDIRS, the 8228753Smm# specified directory will be visited and the target made. There is 9228753Smm# also a default target which allows the command "make subdir" where 10228753Smm# subdir is any directory listed in the variable SUBDIRS. 11228753Smm# 12228753Smm# 13228753Smm# +++ variables +++ 14228753Smm# 15228753Smm# DISTRIBUTION Name of distribution. [base] 16228753Smm# 17228753Smm# SUBDIR A list of subdirectories that should be built as well. 18228753Smm# Each of the targets will execute the same target in the 19228753Smm# subdirectories. 20228753Smm# 21228753Smm# +++ targets +++ 22228753Smm# 23228753Smm# distribute: 24228753Smm# This is a variant of install, which will 25228753Smm# put the stuff into the right "distribution". 26228753Smm# 27228753Smm# afterdistribute, afterinstall, all, all-man, beforeinstall, checkdpadd, 28228753Smm# clean, cleandepend, cleandir, depend, install, lint, 29228753Smm# obj, objlink, realinstall, regress, tags 30228753Smm# 31228753Smm 32228753Smm.include <bsd.init.mk> 33228753Smm 34228753Smm_SUBDIR: .USE 35228753Smm.if defined(SUBDIR) && !empty(SUBDIR) 36228753Smm @for entry in ${SUBDIR}; do \ 37228753Smm if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ 38228753Smm ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH}"; \ 39228753Smm edir=$${entry}.${MACHINE_ARCH}; \ 40228753Smm cd ${.CURDIR}/$${edir}; \ 41228753Smm else \ 42228753Smm ${ECHODIR} "===> ${DIRPRFX}$$entry"; \ 43228753Smm edir=$${entry}; \ 44228753Smm cd ${.CURDIR}/$${edir}; \ 45228753Smm fi; \ 46228753Smm ${MAKE} ${.TARGET:realinstall=install} \ 47228753Smm DIRPRFX=${DIRPRFX}$$edir/; \ 48231200Smm done 49228753Smm.endif 50228753Smm 51228753Smm${SUBDIR}:: 52231200Smm @if test -d ${.TARGET}.${MACHINE_ARCH}; then \ 53231200Smm cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ 54231200Smm else \ 55231200Smm cd ${.CURDIR}/${.TARGET}; \ 56231200Smm fi; \ 57231200Smm ${MAKE} all 58231200Smm 59231200Smm 60231200Smm.for __target in all all-man checkdpadd clean cleandepend cleandir depend lint \ 61228753Smm obj objlink realinstall regress tags 62228753Smm${__target}: _SUBDIR 63228753Smm.endfor 64228753Smm 65228753Smm.if !target(install) 66228753Smm.if !target(beforeinstall) 67228753Smmbeforeinstall: 68228753Smm.endif 69231200Smm.if !target(afterinstall) 70228753Smmafterinstall: 71228753Smm.endif 72228753Smminstall: afterinstall 73228753Smmafterinstall: realinstall 74228753Smmrealinstall: beforeinstall 75228753Smm.endif 76228753Smm 77228753SmmDISTRIBUTION?= base 78228753Smm.if !target(afterdistribute) 79228753Smmafterdistribute: 80228753Smm.endif 81228753Smm.if !target(distribute) 82228753Smmdistribute: _SUBDIR 83228753Smm.for dist in ${DISTRIBUTION} 84231200Smm cd ${.CURDIR} ; ${MAKE} afterdistribute DESTDIR=${DISTDIR}/${dist} 85228753Smm.endfor 86231200Smm.endif 87231200Smm