xref: /minix3/share/mk/bsd.subdir.mk (revision 9152e1c5a7225885973292842eaa6ab5121d1a38)
1*9152e1c5SLionel Sambuc#	$NetBSD: bsd.subdir.mk,v 1.52 2010/05/26 00:48:15 uwe Exp $
2e1091647SArun Thomas#	@(#)bsd.subdir.mk	8.1 (Berkeley) 6/8/93
3e1091647SArun Thomas
4e1091647SArun Thomas.include <bsd.init.mk>
5e1091647SArun Thomas
6e1091647SArun Thomas.if !defined(NOSUBDIR)					# {
7e1091647SArun Thomas
8e1091647SArun Thomas.for dir in ${SUBDIR}
9*9152e1c5SLionel Sambuc.if "${dir}" == ".WAIT"
10*9152e1c5SLionel Sambuc# Don't play with .WAIT
11*9152e1c5SLionel Sambuc__REALSUBDIR+=${dir}
12*9152e1c5SLionel Sambuc.else
13*9152e1c5SLionel Sambuc.if "${dir:H}" != ""
14*9152e1c5SLionel Sambuc# It is a relative path; make it absolute so exists can't search the path.
15*9152e1c5SLionel Sambuc.if exists(${.CURDIR}/${dir}.${MACHINE})
16*9152e1c5SLionel Sambuc__REALSUBDIR+=${dir}.${MACHINE}
17*9152e1c5SLionel Sambuc.else
18*9152e1c5SLionel Sambuc__REALSUBDIR+=${dir}
19*9152e1c5SLionel Sambuc.endif
20*9152e1c5SLionel Sambuc.else
21*9152e1c5SLionel Sambuc# It is an absolute path; leave it alone
22e1091647SArun Thomas.if exists(${dir}.${MACHINE})
23e1091647SArun Thomas__REALSUBDIR+=${dir}.${MACHINE}
24e1091647SArun Thomas.else
25e1091647SArun Thomas__REALSUBDIR+=${dir}
26e1091647SArun Thomas.endif
27*9152e1c5SLionel Sambuc.endif
28*9152e1c5SLionel Sambuc.endif
29e1091647SArun Thomas.endfor
30e1091647SArun Thomas
31e1091647SArun Thomas__recurse: .USE
32e1091647SArun Thomas	@${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
33e1091647SArun Thomas
34e1091647SArun Thomas.if make(cleandir)
35e1091647SArun Thomas__RECURSETARG=	${TARGETS:Nclean}
36e1091647SArun Thomasclean:
37e1091647SArun Thomas.else
38e1091647SArun Thomas__RECURSETARG=	${TARGETS}
39e1091647SArun Thomas.endif
40e1091647SArun Thomas
41e1091647SArun Thomas# for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
42e1091647SArun Thomas# but have to assign to __TARGDIR first.
43e1091647SArun Thomas.for targ in ${__RECURSETARG}
44e1091647SArun Thomas.for dir in ${__REALSUBDIR}
45e1091647SArun Thomas__TARGDIR := ${dir}
46e1091647SArun Thomas.if ${__TARGDIR} == ".WAIT"
47e1091647SArun ThomasSUBDIR_${targ} += .WAIT
48e1091647SArun Thomas.elif !commands(${targ}-${dir})
49e1091647SArun Thomas${targ}-${dir}: .PHONY .MAKE __recurse
50e1091647SArun ThomasSUBDIR_${targ} += ${targ}-${dir}
51e1091647SArun Thomas.endif
52e1091647SArun Thomas.endfor
53e1091647SArun Thomassubdir-${targ}: .PHONY ${SUBDIR_${targ}}
54e1091647SArun Thomas${targ}: subdir-${targ}
55e1091647SArun Thomas.endfor
56e1091647SArun Thomas
57e1091647SArun Thomas.endif	# ! NOSUBDIR					# }
58e1091647SArun Thomas
59e1091647SArun Thomas${TARGETS}:	# ensure existence
60