:
trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
find . \( -name CVS -a -prune \) -o -type f -print | while read FILE
do
	cat "$FILE" | grep -v "^#if" | grep -v "^#else" | 
		grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a
	cat /tmp/$$a | grep "^#include" |
	sed 's/#include[ 	]*[<"]\([^>"]*\).*$/\1/g' |
	while read INCLUDE
	do
		[ -s /usr/include/$INCLUDE ] && continue
		cat /tmp/$$a |
		grep -v '^#include[ 	]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b
		echo "#include \"postgres.h\"" >/tmp/$$.c
		echo "#include \"/tmp/$$b\"" >>/tmp/$$.c
		echo "void main() {" >>/tmp/$$.c
		pgdefine "$FILE" >>/tmp/$$.c
		echo "}" >>/tmp/$$.c
		cc -Werror -Wall -I/pg/include -I/pg/backend -c /tmp/$$.c -o /tmp/$$.o >/tmp/$$ 2>&1
		if [ "$?" -eq 0 ]
		then	echo "$FILE $INCLUDE"
			if [ "$1" = "-v" ]
			then	cat /tmp/$$
				cat /tmp/$$.c
			fi
		fi
	done
done
