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