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