1# $Id: meta.subdir.mk,v 1.16 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 2010, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11.if !defined(NO_SUBDIR) && !empty(SUBDIR) 12.if make(destroy*) || make(clean*) 13.MAKE.MODE = compat 14.if !commands(obj) 15.-include <bsd.obj.mk> 16.endif 17.elif ${.MAKE.LEVEL} == 0 18 19.MAIN: all 20 21.if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps) 22# start with this 23DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@} 24 25.if make(gendirdeps) 26.include <meta.autodep.mk> 27.else 28# this is the cunning bit 29# actually it is probably a bit risky 30# since we may pickup subdirs which are not relevant 31# the alternative is a walk through the tree though 32# which is difficult without a sub-make. 33 34.if defined(BOOTSTRAP_DEPENDFILES) 35_find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1} 36DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} 37.elif ${.MAKE.DEPENDFILE:E} == ${MACHINE} && defined(ALL_MACHINES) 38# we want to find Makefile.depend.* ie for all machines 39# and turn the dirs into dir.<machine> 40_find_name = -name '${.MAKE.DEPENDFILE:T:R}*' 41DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,} 42.else 43# much simpler 44_find_name = -name ${.MAKE.DEPENDFILE:T} 45.if ${.MAKE.DEPENDFILE:E} == ${MACHINE} 46_find_name += -o -name ${.MAKE.DEPENDFILE:T:R} 47.endif 48DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} 49.endif 50 51_subdeps != cd ${.CURDIR} && \ 52 find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \ 53 -name .svn -prune 2> /dev/null; echo 54 55.if empty(_subdeps) 56DIRDEPS = 57.else 58# clean up if needed 59DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}} 60.endif 61# we just dealt with it, if we leave it defined, 62# dirdeps.mk will compute some interesting combinations. 63.undef ALL_MACHINES 64 65.include <dirdeps.mk> 66.endif 67.endif 68.else 69all: .PHONY 70.endif 71 72.endif 73