Correct math and limerick.
[dragonfly.git] / contrib / bmake / mk / meta.subdir.mk
blob2b739ee9ae9c054c295e013ac04b1476e4d8bf0c
1 # $Id: meta.subdir.mk,v 1.10 2012/07/03 05:26:46 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
11 # left intact.
13 # Please send copies of changes and bug-fixes to:
14 # sjg@crufty.net
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
25 .MAIN: all
27 .if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps)
28 # start with this
29 DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@}
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.
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$,,}
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
54 DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@}
55 .endif
57 _subdeps != cd ${.CURDIR} && \
58 find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \
59 -name .svn -prune 2> /dev/null; echo
61 .if empty(_subdeps)
62 DIRDEPS =
63 .else
64 # clean up if needed
65 DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIREPS_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
71 DEP_RELDIR = ${RELDIR}
72 .include <dirdeps.mk>
73 .endif
74 .endif
75 .else
76 all: .PHONY
77 .endif
79 .endif