1# $Id: meta.subdir.mk,v 1.11 2015/11/24 22:26:51 sjg Exp $ 2 3# 4# @(#) Copyright (c) 2010, Simon J. Gerraty 5# 6# This file is provided in the hope that it will 7# be of use. There is absolutely NO WARRANTY. 8# Permission to copy, redistribute or otherwise 9# use this file is hereby granted provided that 10# the above copyright notice and this notice are 11# left intact. 12# 13# Please send copies of changes and bug-fixes to: 14# sjg@crufty.net 15# 16 17.if !defined(NO_SUBDIR) && !empty(SUBDIR) 18.if make(destroy*) || make(clean*) 19.MAKE.MODE = compat 20.if !commands(destroy) 21.-include <bsd.obj.mk> 22.endif 23.elif ${.MAKE.LEVEL} == 0 24 25.MAIN: all 26 27.if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps) 28# start with this 29DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@} 30 31.if make(gendirdeps) 32.include <meta.autodep.mk> 33.else 34# this is the cunning bit 35# actually it is probably a bit risky 36# since we may pickup subdirs which are not relevant 37# the alternative is a walk through the tree though 38# which is difficult without a sub-make. 39 40.if defined(BOOTSTRAP_DEPENDFILES) 41_find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1} 42DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} 43.elif ${.MAKE.DEPENDFILE:E} == ${MACHINE} && defined(ALL_MACHINES) 44# we want to find Makefile.depend.* ie for all machines 45# and turn the dirs into dir.<machine> 46_find_name = -name '${.MAKE.DEPENDFILE:T:R}*' 47DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,} 48.else 49# much simpler 50_find_name = -name ${.MAKE.DEPENDFILE:T} 51.if ${.MAKE.DEPENDFILE:E} == ${MACHINE} 52_find_name += -o -name ${.MAKE.DEPENDFILE:T:R} 53.endif 54DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} 55.endif 56 57_subdeps != cd ${.CURDIR} && \ 58 find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \ 59 -name .svn -prune 2> /dev/null; echo 60 61.if empty(_subdeps) 62DIRDEPS = 63.else 64# clean up if needed 65DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}} 66.endif 67# we just dealt with it, if we leave it defined, 68# dirdeps.mk will compute some interesting combinations. 69.undef ALL_MACHINES 70 71DEP_RELDIR = ${RELDIR} 72.include <dirdeps.mk> 73.endif 74.endif 75.else 76all: .PHONY 77.endif 78 79.endif 80