Home | History | Annotate | Line # | Download | only in mk
bsd.subdir.mk revision 1.46
      1 #	$NetBSD: bsd.subdir.mk,v 1.46 2001/11/02 05:21:51 tv Exp $
      2 #	@(#)bsd.subdir.mk	8.1 (Berkeley) 6/8/93
      3 
      4 .include <bsd.init.mk>
      5 
      6 .for dir in ${SUBDIR}
      7 .if exists(${dir}.${MACHINE})
      8 __REALSUBDIR+=${dir}.${MACHINE}
      9 .else
     10 __REALSUBDIR+=${dir}
     11 .endif
     12 .endfor
     13 
     14 __recurse: .USE
     15 	@targ=${.TARGET:C/-.*$//};dir=${.TARGET:C/^[^-]*-//};		\
     16 	case "$$dir" in /*)						\
     17 		echo "$$targ ===> $$dir";				\
     18 		cd "$$dir";						\
     19 		${MAKE} "_THISDIR_=$$dir/" $$targ;			\
     20 		;;							\
     21 	*)								\
     22 		echo "$$targ ===> ${_THISDIR_}$$dir";			\
     23 		cd "${.CURDIR}/$$dir";					\
     24 		${MAKE} "_THISDIR_=${_THISDIR_}$$dir/" $$targ;		\
     25 		;;							\
     26 	esac
     27 
     28 .if make(cleandir)
     29 __RECURSETARG=	${TARGETS:Nclean}
     30 clean:
     31 .else
     32 __RECURSETARG=	${TARGETS}
     33 .endif
     34 
     35 # for obscure reasons, we can't do a simple .if ${dir} == ".WAIT"
     36 # but have to assign to __TARGDIR first.
     37 .for targ in ${__RECURSETARG}
     38 .for dir in ${__REALSUBDIR}
     39 __TARGDIR := ${dir}
     40 .if ${__TARGDIR} == ".WAIT"
     41 SUBDIR_${targ} += .WAIT
     42 .elif !commands(${targ}-${dir})
     43 .PHONY: ${targ}-${dir}
     44 ${targ}-${dir}: .MAKE __recurse
     45 SUBDIR_${targ} += ${targ}-${dir}
     46 .endif
     47 .endfor
     48 .if defined(__REALSUBDIR)
     49 .PHONY: subdir-${targ}
     50 subdir-${targ}: ${SUBDIR_${targ}}
     51 ${targ}: subdir-${targ}
     52 .endif
     53 .endfor
     54 
     55 ${TARGETS}:	# ensure existence
     56