aboutsummaryrefslogtreecommitdiff
path: root/.hooks/pre-commit.d/check_category_makefile
diff options
context:
space:
mode:
Diffstat (limited to '.hooks/pre-commit.d/check_category_makefile')
-rwxr-xr-x.hooks/pre-commit.d/check_category_makefile22
1 files changed, 22 insertions, 0 deletions
diff --git a/.hooks/pre-commit.d/check_category_makefile b/.hooks/pre-commit.d/check_category_makefile
new file mode 100755
index 000000000000..fea09ef6325c
--- /dev/null
+++ b/.hooks/pre-commit.d/check_category_makefile
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Check that ports are hooked into the build
+#
+
+common_functions="$(realpath "$(dirname "$0")")/common.sh"
+if [ -r "${common_functions}" ]; then
+ . "${common_functions}"
+fi
+
+newish_makefiles=$(git diff --name-only --cached --diff-filter=ACR | grep -E '^[^/]+/[^/]+/Makefile$')
+if [ $? -eq 0 ] ; then
+ for newish_makefile in ${newish_makefiles} ; do
+ category=$(echo "${newish_makefile}" | awk -F '/' '{print $1}')
+ port=$(echo "${newish_makefile}" | awk -F '/' '{print $2}')
+ grep -q -E "^[[:space:]]+SUBDIR[[:space:]]\+=[[:space:]]*${port}\$" ${category}/Makefile
+ if [ $? -ne 0 ] ; then
+ pre_commit_error "Missing 'SUBDIR += ${port}' in ${category}/Makefile"
+ exit 1
+ fi
+ done
+fi