2015-06-13 19:20:56 +00:00
|
|
|
# $FreeBSD$
|
2020-11-24 21:45:38 +00:00
|
|
|
# $Id: meta.subdir.mk,v 1.12 2020/08/19 17:51:53 sjg Exp $
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# @(#) Copyright (c) 2010, Simon J. Gerraty
|
|
|
|
#
|
|
|
|
# This file is provided in the hope that it will
|
|
|
|
# be of use. There is absolutely NO WARRANTY.
|
|
|
|
# Permission to copy, redistribute or otherwise
|
2020-11-24 21:45:38 +00:00
|
|
|
# use this file is hereby granted provided that
|
2012-08-22 19:25:57 +00:00
|
|
|
# the above copyright notice and this notice are
|
2020-11-24 21:45:38 +00:00
|
|
|
# left intact.
|
|
|
|
#
|
2012-08-22 19:25:57 +00:00
|
|
|
# Please send copies of changes and bug-fixes to:
|
|
|
|
# sjg@crufty.net
|
|
|
|
#
|
|
|
|
|
|
|
|
.if !defined(NO_SUBDIR) && !empty(SUBDIR)
|
|
|
|
.if make(destroy*) || make(clean*)
|
|
|
|
.MAKE.MODE = compat
|
|
|
|
.if !commands(destroy)
|
|
|
|
.-include <bsd.obj.mk>
|
|
|
|
.endif
|
|
|
|
.elif ${.MAKE.LEVEL} == 0
|
|
|
|
|
|
|
|
.MAIN: all
|
|
|
|
|
|
|
|
.if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps)
|
|
|
|
# start with this
|
|
|
|
DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@}
|
|
|
|
|
|
|
|
.if make(gendirdeps)
|
|
|
|
.include <meta.autodep.mk>
|
|
|
|
.else
|
|
|
|
# this is the cunning bit
|
2020-11-24 21:45:38 +00:00
|
|
|
# actually it is probably a bit risky
|
2012-08-22 19:25:57 +00:00
|
|
|
# since we may pickup subdirs which are not relevant
|
|
|
|
# the alternative is a walk through the tree though
|
|
|
|
# which is difficult without a sub-make.
|
|
|
|
|
|
|
|
.if defined(BOOTSTRAP_DEPENDFILES)
|
|
|
|
_find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1}
|
|
|
|
DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@}
|
|
|
|
.elif ${.MAKE.DEPENDFILE:E} == ${MACHINE} && defined(ALL_MACHINES)
|
|
|
|
# we want to find Makefile.depend.* ie for all machines
|
|
|
|
# and turn the dirs into dir.<machine>
|
|
|
|
_find_name = -name '${.MAKE.DEPENDFILE:T:R}*'
|
|
|
|
DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,}
|
|
|
|
.else
|
|
|
|
# much simpler
|
|
|
|
_find_name = -name ${.MAKE.DEPENDFILE:T}
|
|
|
|
.if ${.MAKE.DEPENDFILE:E} == ${MACHINE}
|
|
|
|
_find_name += -o -name ${.MAKE.DEPENDFILE:T:R}
|
|
|
|
.endif
|
|
|
|
DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
_subdeps != cd ${.CURDIR} && \
|
|
|
|
find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \
|
|
|
|
-name .svn -prune 2> /dev/null; echo
|
|
|
|
|
|
|
|
.if empty(_subdeps)
|
|
|
|
DIRDEPS =
|
|
|
|
.else
|
|
|
|
# clean up if needed
|
2016-01-25 18:34:15 +00:00
|
|
|
DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
# we just dealt with it, if we leave it defined,
|
|
|
|
# dirdeps.mk will compute some interesting combinations.
|
|
|
|
.undef ALL_MACHINES
|
|
|
|
|
|
|
|
DEP_RELDIR = ${RELDIR}
|
|
|
|
.include <dirdeps.mk>
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.else
|
|
|
|
all: .PHONY
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.endif
|