1246149Ssjg# $Id: subdir.mk,v 1.14 2012/11/12 04:34:33 sjg Exp $ 2246149Ssjg# skip missing directories... 3246149Ssjg 4246149Ssjg# $NetBSD: bsd.subdir.mk,v 1.11 1996/04/04 02:05:06 jtc Exp $ 5246149Ssjg# @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 6246149Ssjg 7246149Ssjg.if ${.MAKE.LEVEL} == 0 && ${.MAKE.MODE:Uno:Mmeta*} != "" 8246149Ssjg.include <meta.subdir.mk> 9246149Ssjg# keep everyone happy 10246149Ssjg_SUBDIRUSE: 11246149Ssjg.elif !commands(_SUBDIRUSE) && !defined(NO_SUBDIR) && !defined(NOSUBDIR) 12246149Ssjg.if exists(${.CURDIR}/Makefile.inc) 13246149Ssjg.include "Makefile.inc" 14246149Ssjg.endif 15246149Ssjg.if !target(.MAIN) 16246149Ssjg.MAIN: all 17246149Ssjg.endif 18246149Ssjg 19246149SsjgECHO_DIR ?= echo 20246149Ssjg.ifdef SUBDIR_MUST_EXIST 21246149SsjgMISSING_DIR=echo "Missing ===> ${.CURDIR}/$${entry}"; exit 1 22246149Ssjg.else 23246149SsjgMISSING_DIR=echo "Skipping ===> ${.CURDIR}/$${entry}"; continue 24246149Ssjg.endif 25246149Ssjg 26246149Ssjg_SUBDIRUSE: .USE 27246149Ssjg.if defined(SUBDIR) 28246149Ssjg @Exists() { test -f $$1; }; \ 29246149Ssjg for entry in ${SUBDIR}; do \ 30246149Ssjg (set -e; \ 31246149Ssjg if Exists ${.CURDIR}/$${entry}.${MACHINE}/[mM]akefile; then \ 32246149Ssjg _newdir_="$${entry}.${MACHINE}"; \ 33246149Ssjg elif Exists ${.CURDIR}/$${entry}/[mM]akefile; then \ 34246149Ssjg _newdir_="$${entry}"; \ 35246149Ssjg else \ 36246149Ssjg ${MISSING_DIR}; \ 37246149Ssjg fi; \ 38246149Ssjg if test X"${_THISDIR_}" = X""; then \ 39246149Ssjg _nextdir_="$${_newdir_}"; \ 40246149Ssjg else \ 41246149Ssjg _nextdir_="$${_THISDIR_}/$${_newdir_}"; \ 42246149Ssjg fi; \ 43246149Ssjg ${ECHO_DIR} "===> $${_nextdir_}"; \ 44246149Ssjg cd ${.CURDIR}/$${_newdir_}; \ 45246149Ssjg ${.MAKE} _THISDIR_="$${_nextdir_}" \ 46246149Ssjg ${.TARGET:S/realinstall/install/:S/.depend/depend/}) || exit 1; \ 47246149Ssjg done 48246149Ssjg 49246149Ssjg${SUBDIR}:: 50246149Ssjg @set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \ 51246149Ssjg _newdir_=${.TARGET}.${MACHINE}; \ 52246149Ssjg else \ 53246149Ssjg _newdir_=${.TARGET}; \ 54246149Ssjg fi; \ 55246149Ssjg ${ECHO_DIR} "===> $${_newdir_}"; \ 56246149Ssjg cd ${.CURDIR}/$${_newdir_}; \ 57246149Ssjg ${.MAKE} _THISDIR_="$${_newdir_}" all 58246149Ssjg.endif 59246149Ssjg 60246149Ssjg.if !target(install) 61246149Ssjg.if !target(beforeinstall) 62246149Ssjgbeforeinstall: 63246149Ssjg.endif 64246149Ssjg.if !target(afterinstall) 65246149Ssjgafterinstall: 66246149Ssjg.endif 67246149Ssjginstall: maninstall 68246149Ssjgmaninstall: afterinstall 69246149Ssjgafterinstall: realinstall 70246149Ssjgrealinstall: beforeinstall _SUBDIRUSE 71246149Ssjg.endif 72246149Ssjg 73246149Ssjg.if defined(SRCS) 74246149Ssjgetags: ${SRCS} 75246149Ssjg -cd ${.CURDIR}; etags `echo ${.ALLSRC:N*.h} | sed 's;${.CURDIR}/;;'` 76246149Ssjg.endif 77246149Ssjg 78246149SsjgSUBDIR_TARGETS += \ 79246149Ssjg all \ 80246149Ssjg clean \ 81246149Ssjg cleandir \ 82246149Ssjg includes \ 83246149Ssjg depend \ 84246149Ssjg lint \ 85246149Ssjg obj \ 86246149Ssjg tags \ 87246149Ssjg etags 88246149Ssjg 89246149Ssjg.for t in ${SUBDIR_TARGETS:O:u} 90246149Ssjg$t: _SUBDIRUSE 91246149Ssjg.endfor 92246149Ssjg 93246149Ssjg.include <own.mk> 94246149Ssjg.if make(destroy*) 95246149Ssjg.include <obj.mk> 96246149Ssjg.endif 97246149Ssjg.endif 98246149Ssjg# make sure this exists 99246149Ssjgall: 100