No empty .Rs/.Re
[netbsd-mini2440.git] / share / mk / bsd.subdir.mk
blob7b002b90573699b2b62caa50c2cf000a42feddc0
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
4 .include <bsd.init.mk>
6 .if !defined(NOSUBDIR) # {
8 .for dir in ${SUBDIR}
9 .if "${dir}" == ".WAIT"
10 # Don't play with .WAI
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
31 __recurse: .USE
32 @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
34 .if make(cleandir)
35 __RECURSETARG= ${TARGETS:Nclean}
36 clean:
37 .else
38 __RECURSETARG= ${TARGETS}
39 .endif
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"
47 SUBDIR_${targ} += .WAIT
48 .elif !commands(${targ}-${dir})
49 ${targ}-${dir}: .PHONY .MAKE __recurse
50 SUBDIR_${targ} += ${targ}-${dir}
51 .endif
52 .endfor
53 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
54 ${targ}: subdir-${targ}
55 .endfor
57 .endif # ! NOSUBDIR # }
59 ${TARGETS}: # ensure existence