#!/bin/sh

echo Checking */drivers.conf ...
for f in */drivers.conf; do
	arch=`dirname $f`
	grep -v '^#' $f  | grep -v '^$' | awk '{ print $1 }' |
	while read x; do
	        egrep -qw "^(device|options)[[:space:]]+$x" ../sys/${arch}/conf/GENERIC || \
		    echo $x not found in $arch/GENERIC
		sed -e'/"SMALL"/,/^else$/d' ${arch}/dokern.sh | \
		    grep -qw $x && \
		    echo "duplicate $x found in ${arch}/dokern.sh"
	done
done

echo Checking */dokern.sh ...
for f in */dokern.sh; do
	arch=`dirname $f`
	sed -e'/"SMALL"/,/^else$/d' $f | \
	grep -w -- -e | sed -e's,^[^/]*/,,' -e's,/.*$,,' |
	grep -v '^ident\.\*GENERIC$' |
	while read x; do
	        egrep -q "^(device|options|makeoptions)[[:space:]]+$x" \
		    ../sys/${arch}/conf/GENERIC || \
		    echo $x not found in $arch/GENERIC
		grep -qw ^$x ${arch}/drivers.conf && \
		    echo "duplicate $x found in ${arch}/drivers.conf"
	done
done

