NetBSD/share/mk/bsd.subdir.mk

60 lines
1.3 KiB
Makefile
Raw Normal View History

2010-05-26 04:48:15 +04:00
# $NetBSD: bsd.subdir.mk,v 1.52 2010/05/26 00:48:15 uwe Exp $
1997-03-29 11:02:45 +03:00
# @(#)bsd.subdir.mk 8.1 (Berkeley) 6/8/93
1993-03-21 12:45:37 +03:00
.include <bsd.init.mk>
1993-03-21 12:45:37 +03:00
.if !defined(NOSUBDIR) # {
.for dir in ${SUBDIR}
.if "${dir}" == ".WAIT"
2010-05-26 04:48:15 +04:00
# Don't play with .WAIT
__REALSUBDIR+=${dir}
.else
.if "${dir:H}" != ""
# It is a relative path; make it absolute so exists can't search the path.
.if exists(${.CURDIR}/${dir}.${MACHINE})
__REALSUBDIR+=${dir}.${MACHINE}
.else
__REALSUBDIR+=${dir}
.endif
.else
# It is an absolute path; leave it alone
.if exists(${dir}.${MACHINE})
__REALSUBDIR+=${dir}.${MACHINE}
.else
__REALSUBDIR+=${dir}
.endif
.endif
.endif
.endfor
__recurse: .USE
@${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
.if make(cleandir)
__RECURSETARG= ${TARGETS:Nclean}
clean:
.else
__RECURSETARG= ${TARGETS}
.endif
# for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
# but have to assign to __TARGDIR first.
.for targ in ${__RECURSETARG}
.for dir in ${__REALSUBDIR}
__TARGDIR := ${dir}
.if ${__TARGDIR} == ".WAIT"
SUBDIR_${targ} += .WAIT
.elif !commands(${targ}-${dir})
${targ}-${dir}: .PHONY .MAKE __recurse
2001-01-09 05:08:32 +03:00
SUBDIR_${targ} += ${targ}-${dir}
.endif
1997-05-07 00:54:31 +04:00
.endfor
subdir-${targ}: .PHONY ${SUBDIR_${targ}}
${targ}: subdir-${targ}
.endfor
1993-03-21 12:45:37 +03:00
.endif # ! NOSUBDIR # }
${TARGETS}: # ensure existence