#!/bin/sh

DIR=${1-.}

CV=$(grep -rh "^#.*if.* CONFIG_[A-Za-z0-9]" ${DIR} | grep -v endif)
CVARS=$(echo "${CV}" | sed "s/.*\(CONFIG_[^	 =\)\*\/]*\).*/\1/" | sort -u | grep "^CONFIG_")

kcfiles=$(find . -name "Kconfig*")

for cv in ${CVARS} ; do
	# echo "cv = ${cv}"
	str=$(echo ${cv} | sed "s/^CONFIG_//")
	# echo "str = ${str}"
	grep -wq ${str} ${kcfiles} || {
		echo ${str}
		# grep -r ${str} ${DIR}		# uncomment if you want
	}
done
