bsd.subdir.mk revision 1.50 1 # $NetBSD: bsd.subdir.mk,v 1.50 2009/11/29 16:00:00 uebayasi 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 exists(${dir}.${MACHINE})
10 __REALSUBDIR+=${dir}.${MACHINE}
11 .else
12 __REALSUBDIR+=${dir}
13 .endif
14 .endfor
15
16 __recurse: .USE
17 @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
18
19 .if make(cleandir)
20 __RECURSETARG= ${TARGETS:Nclean}
21 clean:
22 .else
23 __RECURSETARG= ${TARGETS}
24 .endif
25
26 # for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
27 # but have to assign to __TARGDIR first.
28 .for targ in ${__RECURSETARG}
29 .for dir in ${__REALSUBDIR}
30 __TARGDIR := ${dir}
31 .if ${__TARGDIR} == ".WAIT"
32 SUBDIR_${targ} += .WAIT
33 .elif !commands(${targ}-${dir})
34 ${targ}-${dir}: .PHONY .MAKE __recurse
35 SUBDIR_${targ} += ${targ}-${dir}
36 .endif
37 .endfor
38 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
39 ${targ}: subdir-${targ}
40 .endfor
41
42 .endif # ! NOSUBDIR # }
43
44 ${TARGETS}: # ensure existence
45