1 1.47 lukem # $NetBSD: bsd.subdir.mk,v 1.47 2004/01/29 01:48:45 lukem Exp $ 2 1.14 mikel # @(#)bsd.subdir.mk 8.1 (Berkeley) 6/8/93 3 1.1 cgd 4 1.46 tv .include <bsd.init.mk> 5 1.1 cgd 6 1.25 mycroft .for dir in ${SUBDIR} 7 1.25 mycroft .if exists(${dir}.${MACHINE}) 8 1.25 mycroft __REALSUBDIR+=${dir}.${MACHINE} 9 1.25 mycroft .else 10 1.25 mycroft __REALSUBDIR+=${dir} 11 1.25 mycroft .endif 12 1.25 mycroft .endfor 13 1.1 cgd 14 1.35 mycroft __recurse: .USE 15 1.36 mycroft @targ=${.TARGET:C/-.*$//};dir=${.TARGET:C/^[^-]*-//}; \ 16 1.35 mycroft case "$$dir" in /*) \ 17 1.35 mycroft echo "$$targ ===> $$dir"; \ 18 1.35 mycroft cd "$$dir"; \ 19 1.44 tv ${MAKE} "_THISDIR_=$$dir/" $$targ; \ 20 1.35 mycroft ;; \ 21 1.35 mycroft *) \ 22 1.35 mycroft echo "$$targ ===> ${_THISDIR_}$$dir"; \ 23 1.35 mycroft cd "${.CURDIR}/$$dir"; \ 24 1.44 tv ${MAKE} "_THISDIR_=${_THISDIR_}$$dir/" $$targ; \ 25 1.35 mycroft ;; \ 26 1.35 mycroft esac 27 1.35 mycroft 28 1.42 tv .if make(cleandir) 29 1.42 tv __RECURSETARG= ${TARGETS:Nclean} 30 1.45 tv clean: 31 1.42 tv .else 32 1.42 tv __RECURSETARG= ${TARGETS} 33 1.42 tv .endif 34 1.42 tv 35 1.39 sommerfe # for obscure reasons, we can't do a simple .if ${dir} == ".WAIT" 36 1.39 sommerfe # but have to assign to __TARGDIR first. 37 1.42 tv .for targ in ${__RECURSETARG} 38 1.25 mycroft .for dir in ${__REALSUBDIR} 39 1.39 sommerfe __TARGDIR := ${dir} 40 1.39 sommerfe .if ${__TARGDIR} == ".WAIT" 41 1.39 sommerfe SUBDIR_${targ} += .WAIT 42 1.43 tv .elif !commands(${targ}-${dir}) 43 1.47 lukem ${targ}-${dir}: .PHONY .MAKE __recurse 44 1.41 sommerfe SUBDIR_${targ} += ${targ}-${dir} 45 1.39 sommerfe .endif 46 1.17 mycroft .endfor 47 1.38 mycroft .if defined(__REALSUBDIR) 48 1.47 lukem subdir-${targ}: .PHONY ${SUBDIR_${targ}} 49 1.40 sommerfe ${targ}: subdir-${targ} 50 1.38 mycroft .endif 51 1.12 cgd .endfor 52 1.21 christos 53 1.46 tv ${TARGETS}: # ensure existence 54