bsd.subdir.mk revision 174409
136270Swpaul# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 236270Swpaul# $FreeBSD: head/share/mk/bsd.subdir.mk 174409 2007-12-07 15:02:06Z ru $ 336270Swpaul# 436270Swpaul# The include file <bsd.subdir.mk> contains the default targets 536270Swpaul# for building subdirectories. 636270Swpaul# 736270Swpaul# For all of the directories listed in the variable SUBDIRS, the 836270Swpaul# specified directory will be visited and the target made. There is 936270Swpaul# also a default target which allows the command "make subdir" where 1036270Swpaul# subdir is any directory listed in the variable SUBDIRS. 1136270Swpaul# 1236270Swpaul# 1336270Swpaul# +++ variables +++ 1436270Swpaul# 1536270Swpaul# DISTRIBUTION Name of distribution. [base] 1636270Swpaul# 1736270Swpaul# SUBDIR A list of subdirectories that should be built as well. 1836270Swpaul# Each of the targets will execute the same target in the 1936270Swpaul# subdirectories. 2036270Swpaul# 2136270Swpaul# +++ targets +++ 2236270Swpaul# 2336270Swpaul# distribute: 2436270Swpaul# This is a variant of install, which will 2536270Swpaul# put the stuff into the right "distribution". 2636270Swpaul# 2736270Swpaul# afterinstall, all, all-man, beforeinstall, checkdpadd, 2836270Swpaul# clean, cleandepend, cleandir, depend, install, lint, maninstall, 2936270Swpaul# manlint, obj, objlink, realinstall, regress, tags 3036270Swpaul# 3136270Swpaul 3250477Speter.include <bsd.init.mk> 3336270Swpaul 3436270SwpaulDISTRIBUTION?= base 3536270Swpaul.if !target(distribute) 3636270Swpauldistribute: 3736270Swpaul.for dist in ${DISTRIBUTION} 3836270Swpaul ${_+_}cd ${.CURDIR}; \ 3936270Swpaul ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies 4036270Swpaul.endfor 4139583Swpaul.endif 4236270Swpaul 4336270Swpaul_SUBDIR: .USE 4436270Swpaul.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) 4536270Swpaul @${_+_}for entry in ${SUBDIR}; do \ 4639583Swpaul if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ 4736270Swpaul ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:realinstall=install})"; \ 4836270Swpaul edir=$${entry}.${MACHINE_ARCH}; \ 4936270Swpaul cd ${.CURDIR}/$${edir}; \ 5036270Swpaul else \ 5136270Swpaul ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \ 5236270Swpaul edir=$${entry}; \ 5336270Swpaul cd ${.CURDIR}/$${edir}; \ 5436270Swpaul fi; \ 5536270Swpaul ${MAKE} ${.TARGET:realinstall=install} \ 5636270Swpaul DIRPRFX=${DIRPRFX}$$edir/; \ 5736270Swpaul done 5839583Swpaul.endif 5936270Swpaul 6036270Swpaul${SUBDIR}: .PHONY 6136270Swpaul ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \ 6236270Swpaul cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ 6336270Swpaul else \ 6436270Swpaul cd ${.CURDIR}/${.TARGET}; \ 6536270Swpaul fi; \ 6639583Swpaul ${MAKE} all 6739583Swpaul 6839583Swpaul.for __target in all all-man checkdpadd clean cleandepend cleandir \ 6939583Swpaul depend distribute lint maninstall manlint \ 7039583Swpaul obj objlink realinstall regress tags \ 7139583Swpaul ${SUBDIR_TARGETS} 7239583Swpaul${__target}: _SUBDIR 7339583Swpaul.endfor 7439583Swpaul 7536270Swpaul.for __target in files includes 7636270Swpaul.for __stage in build install 7739583Swpaul${__stage}${__target}: 7836270Swpaul.if make(${__stage}${__target}) 7936270Swpaul${__stage}${__target}: _SUBDIR 8036270Swpaul.endif 8136270Swpaul.endfor 8236270Swpaul${__target}: 8336270Swpaul ${_+_}cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} 8436270Swpaul.endfor 8536270Swpaul 8636270Swpaul.if !target(install) 8736270Swpaul.if !target(beforeinstall) 8836270Swpaulbeforeinstall: 8936270Swpaul.endif 9036270Swpaul.if !target(afterinstall) 9136270Swpaulafterinstall: 9236270Swpaul.endif 9336270Swpaulinstall: beforeinstall realinstall afterinstall 9436270Swpaul.ORDER: beforeinstall realinstall afterinstall 9536270Swpaul.endif 9636270Swpaul