#!/bin/bash
# list of directories containing header files
headerdir="/usr/include \
/usr/X11R6/include \
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include \
/usr/lib/gcc-lib/i386-redhat-linux7/2.96/include"
# list of directories in the include path (the subdirectories must be after their directories)
includepath="/usr/include \
/usr/include/g++-3 \
/usr/X11R6/include \
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include \
/usr/lib/gcc-lib/i386-redhat-linux7/2.96/include"
# build list of header files
touch /tmp/the_header_list
for f in $headerdir
do
find $f -type f >> /tmp/the_header_list
done
rincludepath=()
for f in $includepath
do
rincludepath="$f $rincludepath"
done
for f in $rincludepath
do
sed "s|$f/||" /tmp/the_header_list > /tmp/the_header_list_
rm /tmp/the_header_list
mv /tmp/the_header_list_ /tmp/the_header_list
done
# loop on the files
for file in $*
do
stdinc=`grep '#.*include.*<.*>' $file | sed 's/[^<]*<//' | sed 's/>[^>]*//'`
nstinc=`grep '#.*include.*".*"' $file | sed 's/[^"]*"//' | sed 's/"[^"]*//'`
for f in $stdinc
do
if ! ( grep -x $f /tmp/the_header_list > /dev/null ); then
echo "cannot find standard $f ($file)"
fi
done
for f in $nstinc
do
if ( grep -x $f /tmp/the_header_list > /dev/null ); then
echo "cannot find non-standard $f ($file)"
fi
done
shift
done
rm /tmp/the_header_list
|