Home | History | Annotate | Line # | Download | only in mk
bsd.subdir.mk revision 1.53
      1 #	$NetBSD: bsd.subdir.mk,v 1.53 2018/06/10 17:17:46 kamil Exp $
      2 #	@(#)bsd.subdir.mk	8.1 (Berkeley) 6/8/93
      3 
      4 .include <bsd.init.mk>
      5 
      6 .if !defined(NOSUBDIR)					# {
      7 
      8 .for dir in ${SUBDIR}
      9 .if ("${dir}" != "USD.doc" && "${dir}" != "PSD.doc" && "${dir}" != "SMM.doc") \
     10     || ${MKGROFF} == "yes"
     11 .if "${dir}" == ".WAIT"
     12 # Don't play with .WAIT
     13 __REALSUBDIR+=${dir}
     14 .else
     15 .if "${dir:H}" != ""
     16 # It is a relative path; make it absolute so exists can't search the path.
     17 .if exists(${.CURDIR}/${dir}.${MACHINE})
     18 __REALSUBDIR+=${dir}.${MACHINE}
     19 .else
     20 __REALSUBDIR+=${dir}
     21 .endif
     22 .else
     23 # It is an absolute path; leave it alone
     24 .if exists(${dir}.${MACHINE})
     25 __REALSUBDIR+=${dir}.${MACHINE}
     26 .else
     27 __REALSUBDIR+=${dir}
     28 .endif
     29 .endif
     30 .endif
     31 .endif
     32 .endfor
     33 
     34 __recurse: .USE
     35 	@${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
     36 
     37 .if make(cleandir)
     38 __RECURSETARG=	${TARGETS:Nclean}
     39 clean:
     40 .else
     41 __RECURSETARG=	${TARGETS}
     42 .endif
     43 
     44 # for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
     45 # but have to assign to __TARGDIR first.
     46 .for targ in ${__RECURSETARG}
     47 .for dir in ${__REALSUBDIR}
     48 __TARGDIR := ${dir}
     49 .if ${__TARGDIR} == ".WAIT"
     50 SUBDIR_${targ} += .WAIT
     51 .elif !commands(${targ}-${dir})
     52 ${targ}-${dir}: .PHONY .MAKE __recurse
     53 SUBDIR_${targ} += ${targ}-${dir}
     54 .endif
     55 .endfor
     56 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
     57 ${targ}: subdir-${targ}
     58 .endfor
     59 
     60 .endif	# ! NOSUBDIR					# }
     61 
     62 ${TARGETS}:	# ensure existence
     63