vfs: fix clobbering fd_nr
[minix.git] / share / mk / bsd.subdir.mk
blob0692f40cfe1d45f43a8c0ffe9d4f798f215cb8e6
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
4 .include <bsd.init.mk>
6 .if !defined(NOSUBDIR) # {
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
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