1 # $Id: meta.subdir.mk,v 1.11 2015/11/24 22:26:51 sjg Exp $
4 # @(#) Copyright (c) 2010, Simon J. Gerraty
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
13 # Please send copies of changes and bug-fixes to:
17 .if !defined(NO_SUBDIR) && !empty(SUBDIR)
18 .if make(destroy*) || make(clean*)
20 .if !commands(destroy)
21 .-include <bsd.obj.mk>
23 .elif ${.MAKE.LEVEL} == 0
27 .if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps)
29 DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@}
32 .include <meta.autodep.mk>
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.
40 .if defined(BOOTSTRAP_DEPENDFILES)
41 _find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1}
42 DIRDEPS = ${_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}*'
47 DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,}
50 _find_name = -name ${.MAKE.DEPENDFILE:T}
51 .if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
52 _find_name += -o -name ${.MAKE.DEPENDFILE:T:R}
54 DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@}
57 _subdeps != cd ${.CURDIR} && \
58 find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \
59 -name .svn -prune 2> /dev/null; echo
65 DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}}
67 # we just dealt with it, if we leave it defined,
68 # dirdeps.mk will compute some interesting combinations.
71 DEP_RELDIR = ${RELDIR}