1# $FreeBSD$ 2# $Id: meta.subdir.mk,v 1.12 2020/08/19 17:51:53 sjg Exp $ 3 4# 5# @(#) Copyright (c) 2010, Simon J. Gerraty 6# 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 12# left intact. 13# 14# Please send copies of changes and bug-fixes to: 15# sjg@crufty.net 16# 17 18.if !defined(NO_SUBDIR) && !empty(SUBDIR) 19.if make(destroy*) || make(clean*) 20.MAKE.MODE = compat 21.if !commands(destroy) 22.-include <bsd.obj.mk> 23.endif 24.elif ${.MAKE.LEVEL} == 0 25 26.MAIN: all 27 28.if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps) 29# start with this 30DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@} 31 32.if make(gendirdeps) 33.include <meta.autodep.mk> 34.else 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. 40 41.if defined(BOOTSTRAP_DEPENDFILES) 42_find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1} 43DIRDEPS = ${_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}*' 48DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,} 49.else 50# much simpler 51_find_name = -name ${.MAKE.DEPENDFILE:T} 52.if ${.MAKE.DEPENDFILE:E} == ${MACHINE} 53_find_name += -o -name ${.MAKE.DEPENDFILE:T:R} 54.endif 55DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} 56.endif 57 58_subdeps != cd ${.CURDIR} && \ 59 find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \ 60 -name .svn -prune 2> /dev/null; echo 61 62.if empty(_subdeps) 63DIRDEPS = 64.else 65# clean up if needed 66DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}} 67.endif 68# we just dealt with it, if we leave it defined, 69# dirdeps.mk will compute some interesting combinations. 70.undef ALL_MACHINES 71 72DEP_RELDIR = ${RELDIR} 73.include <dirdeps.mk> 74.endif 75.endif 76.else 77all: .PHONY 78.endif 79 80.endif 81