1# $NetBSD: bsd.subdir.mk,v 1.48 2004/04/13 12:25:03 lukem Exp $ 2# @(#)bsd.subdir.mk 8.1 (Berkeley) 6/8/93 3 4.include <bsd.init.mk> 5 6.for dir in ${SUBDIR} 7.if exists(${dir}.${MACHINE}) 8__REALSUBDIR+=${dir}.${MACHINE} 9.else 10__REALSUBDIR+=${dir} 11.endif 12.endfor 13 14__recurse: .USE 15 @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//} 16 17.if make(cleandir) 18__RECURSETARG= ${TARGETS:Nclean} 19clean: 20.else 21__RECURSETARG= ${TARGETS} 22.endif 23 24# for obscure reasons, we can't do a simple .if ${dir} == ".WAIT" 25# but have to assign to __TARGDIR first. 26.for targ in ${__RECURSETARG} 27.for dir in ${__REALSUBDIR} 28__TARGDIR := ${dir} 29.if ${__TARGDIR} == ".WAIT" 30SUBDIR_${targ} += .WAIT 31.elif !commands(${targ}-${dir}) 32${targ}-${dir}: .PHONY .MAKE __recurse 33SUBDIR_${targ} += ${targ}-${dir} 34.endif 35.endfor 36.if defined(__REALSUBDIR) 37subdir-${targ}: .PHONY ${SUBDIR_${targ}} 38${targ}: subdir-${targ} 39.endif 40.endfor 41 42${TARGETS}: # ensure existence 43