Home | History | Annotate | Line # | Download | only in mk
bsd.subdir.mk revision 1.52.44.1
      1 #	$NetBSD: bsd.subdir.mk,v 1.52.44.1 2018/06/25 07:25:37 pgoyette 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}" == ".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
     30 
     31 .if ${MKGROFF} == "yes"
     32 __REALSUBDIR+=${SUBDIR.roff}
     33 .endif
     34 
     35 __recurse: .USE
     36 	@${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//}
     37 
     38 .if make(cleandir)
     39 __RECURSETARG=	${TARGETS:Nclean}
     40 clean:
     41 .else
     42 __RECURSETARG=	${TARGETS}
     43 .endif
     44 
     45 # for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
     46 # but have to assign to __TARGDIR first.
     47 .for targ in ${__RECURSETARG}
     48 .for dir in ${__REALSUBDIR}
     49 __TARGDIR := ${dir}
     50 .if ${__TARGDIR} == ".WAIT"
     51 SUBDIR_${targ} += .WAIT
     52 .elif !commands(${targ}-${dir})
     53 ${targ}-${dir}: .PHONY .MAKE __recurse
     54 SUBDIR_${targ} += ${targ}-${dir}
     55 .endif
     56 .endfor
     57 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
     58 ${targ}: subdir-${targ}
     59 .endfor
     60 
     61 .endif	# ! NOSUBDIR					# }
     62 
     63 ${TARGETS}:	# ensure existence
     64