git: 9eaf82f27c4f - main - dirdeps.mk guard against inclusion from Makefile.depend.options

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Wed, 19 Apr 2023 03:15:58 UTC
The branch main has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=9eaf82f27c4fb368385ff759a2195bd92c369684

commit 9eaf82f27c4fb368385ff759a2195bd92c369684
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2023-04-19 03:15:25 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2023-04-19 03:15:25 +0000

    dirdeps.mk guard against inclusion from Makefile.depend.options
    
    A typo in Makefile.depend.options including dirdeps.mk rather than
    dirdeps-options.mk can result in infinite recursion - don't let that happen.
    
    Reviewed by:    stevek
---
 share/mk/dirdeps.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/share/mk/dirdeps.mk b/share/mk/dirdeps.mk
index b213ddc28fb7..90ef5f55c790 100644
--- a/share/mk/dirdeps.mk
+++ b/share/mk/dirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.155 2023/04/15 05:46:19 sjg Exp $
+# $Id: dirdeps.mk,v 1.156 2023/04/18 18:39:09 sjg Exp $
 
 # SPDX-License-Identifier: BSD-2-Clause
 #
@@ -349,6 +349,10 @@ BUILD_DIRDEPS ?= yes
 DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${_TARGETS:U${.TARGETS}:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
 .endif
 
+# sanity check: Makefile.depend.options should *not* include us
+.if ${.INCLUDEDFROMFILE:U:M${.MAKE.DEPENDFILE_PREFIX}.options} != ""
+.error ${DEP_RELDIR}/${.MAKE.DEPENDFILE_PREFIX}.options: should include dirdeps-options.mk
+.endif
 
 # pickup customizations
 # as below you can use !target(_DIRDEP_USE) to protect things