:
#
# Copyright 1993 Brent Townshend (bst@tc.com)
# Townshend Computer Tools
# Montreal, Quebec
#
# Wed Aug 25 11:38:22 EDT 1993
#
# Revision History: $Log: checkheader,v $
# Revision 1.3  1994/03/04  15:27:55  bst
#  Save command line and all C output in SysConfig.errs
#
# Revision 1.2  1993/08/27  00:56:52  bst
# Fixed MISSING check for include files.
#
# Revision 1.1  1993/08/25  18:13:40  bst
# Initial revision
#
#
#
# Check if a system header exists
# Usage: checkheader header [prereq headers]
# Returns non-zero exit status if header is missing
# CC and CCFLAGS must be defined before calling.
# Reads from syscap.new
# Appends to 'SysConfig.errs' and 'syscap.new'
echo $0 $*  >>SysConfig.errs
tmp=checkheader$$
header=$1
shift
for i in $*
do
    grep -s "MISSING_`echo $i|tr './' '__'`" syscap.new >/dev/null || echo '#include <'$i'>'
done >${tmp}.c
echo '#include <'$header'>' >>${tmp}.c
if $CC $CCFLAGS -c ${tmp}.c >>SysConfig.errs 2>&1
then
    rm -f ${tmp}.*
    echo "#define HAS_$header" | tr '/.' '__' >>syscap.new
    echo $n "$header+...$c"
    exit 0
else
    rm -f ${tmp}.*
    echo "#define MISSING_$header" | tr '/.' '__' >>syscap.new
    echo $n "$header-...$c"
    exit 1
fi
