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