git: 1a2249ff0bd3 - main - include: add a check-ldirs target

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Wed, 19 Apr 2023 16:02:24 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a2249ff0bd3ce88c50bf64a573874fbe75d6026

commit 1a2249ff0bd3ce88c50bf64a573874fbe75d6026
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-04-19 15:58:06 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-04-19 15:58:06 +0000

    include: add a check-ldirs target
    
    This target ensures all LDIRS, LSUBDIRS, and LSUBSUBDIRS actually exist.
    
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D39006
---
 include/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/include/Makefile b/include/Makefile
index 24f2ed6c2a64..20d735394d9d 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -486,3 +486,16 @@ HOST_MACHINE_ARCH!= uname -p
 MACHINE:= ${HOST_MACHINE}
 MACHINE_ARCH:= ${HOST_MACHINE_ARCH}
 .endif
+
+check-ldirs:
+	missing_dirs=""; \
+	for dir in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS}; do \
+		if [ ! -d ${SRCTOP}/sys/$$dir ]; then \
+			echo "${SRCTOP}/sys/$$dir"; \
+			missing_dirs="$$missing_dirs $$dir"; \
+		fi; \
+	done; \
+	if [ -n "$$missing_dirs" ]; then \
+		echo "Nonexistant directories:" $$missing_dirs; \
+		false; \
+	fi