bsd.subdir.mk revision 1.48 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}
19 clean:
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"
30 SUBDIR_${targ} += .WAIT
31 .elif !commands(${targ}-${dir})
32 ${targ}-${dir}: .PHONY .MAKE __recurse
33 SUBDIR_${targ} += ${targ}-${dir}
34 .endif
35 .endfor
36 .if defined(__REALSUBDIR)
37 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
38 ${targ}: subdir-${targ}
39 .endif
40 .endfor
41
42 ${TARGETS}: # ensure existence
43