bsd.subdir.mk revision 1.47       1 #	$NetBSD: bsd.subdir.mk,v 1.47 2004/01/29 01:48:45 lukem 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 ${targ}-${dir}: .PHONY .MAKE __recurse
     44 SUBDIR_${targ} += ${targ}-${dir}
     45 .endif
     46 .endfor
     47 .if defined(__REALSUBDIR)
     48 subdir-${targ}: .PHONY ${SUBDIR_${targ}}
     49 ${targ}: subdir-${targ}
     50 .endif
     51 .endfor
     52 
     53 ${TARGETS}:	# ensure existence
     54