aboutsummaryrefslogtreecommitdiff
path: root/.hooks/pre-commit.d/check_category_makefile
blob: fea09ef6325c961cc474645c590cb9e553c67d61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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