1# $NetBSD: bsd.subdir.mk,v 1.52 2010/05/26 00:48:15 uwe Exp $ 2# @(#)bsd.subdir.mk 8.1 (Berkeley) 6/8/93 3 4.include <bsd.init.mk> 5 6.if !defined(NOSUBDIR) # { 7 8.for dir in ${SUBDIR} 9.if "${dir}" == ".WAIT" 10# Don't play with .WAIT 11__REALSUBDIR+=${dir} 12.else 13.if "${dir:H}" != "" 14# It is a relative path; make it absolute so exists can't search the path. 15.if exists(${.CURDIR}/${dir}.${MACHINE}) 16__REALSUBDIR+=${dir}.${MACHINE} 17.else 18__REALSUBDIR+=${dir} 19.endif 20.else 21# It is an absolute path; leave it alone 22.if exists(${dir}.${MACHINE}) 23__REALSUBDIR+=${dir}.${MACHINE} 24.else 25__REALSUBDIR+=${dir} 26.endif 27.endif 28.endif 29.endfor 30 31__recurse: .USE 32 @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//} 33 34.if make(cleandir) 35__RECURSETARG= ${TARGETS:Nclean} 36clean: 37.else 38__RECURSETARG= ${TARGETS} 39.endif 40 41# for obscure reasons, we can't do a simple .if ${dir} == ".WAIT" 42# but have to assign to __TARGDIR first. 43.for targ in ${__RECURSETARG} 44.for dir in ${__REALSUBDIR} 45__TARGDIR := ${dir} 46.if ${__TARGDIR} == ".WAIT" 47SUBDIR_${targ} += .WAIT 48.elif !commands(${targ}-${dir}) 49${targ}-${dir}: .PHONY .MAKE __recurse 50SUBDIR_${targ} += ${targ}-${dir} 51.endif 52.endfor 53subdir-${targ}: .PHONY ${SUBDIR_${targ}} 54${targ}: subdir-${targ} 55.endfor 56 57.endif # ! NOSUBDIR # } 58 59${TARGETS}: # ensure existence 60