unstack, sort: cleanup and improvement
[minix.git] / share / mk / bsd.subdir.mk
blob56311af728273617d6af3435b7d52ca503f38e83
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 # MINIX: cleandepend works for SUBDIRs
7 TARGETS+= cleandepend
8 .PHONY: cleandepend
9 .NOTMAIN: cleandepend
11 .if !defined(NOSUBDIR) # {
13 .for dir in ${SUBDIR}
14 .if exists(${dir}.${MACHINE})
15 __REALSUBDIR+=${dir}.${MACHINE}
16 .else
17 __REALSUBDIR+=${dir}
18 .endif
19 .endfor
21 __recurse: .USE
22 @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
24 .if make(cleandir)
25 __RECURSETARG= ${TARGETS:Nclean}
26 clean:
27 .else
28 __RECURSETARG= ${TARGETS}
29 .endif
31 # for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
32 # but have to assign to __TARGDIR first.
33 .for targ in ${__RECURSETARG}
34 .for dir in ${__REALSUBDIR}
35 __TARGDIR := ${dir}
36 .if ${__TARGDIR} == ".WAIT"
37 SUBDIR_${targ} += .WAIT
38 .elif !commands(${targ}-${dir})
39 ${targ}-${dir}: .PHONY .MAKE __recurse
40 SUBDIR_${targ} += ${targ}-${dir}
41 .endif
42 .endfor
43 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
44 ${targ}: subdir-${targ}
45 .endfor
47 .endif # ! NOSUBDIR # }
49 ${TARGETS}: # ensure existence