:
#
# Copyright 1993 Brent Townshend (bst@tc.com)
# Townshend Computer Tools
# Montreal, Quebec
#
# Wed Aug 25 11:38:20 EDT 1993
#
# Revision History: $Log: checkhasdecl,v $
# Revision 1.3  1994/03/04  15:27:41  bst
# Save command line and all C output in SysConfig.errs
#
# Revision 1.2  1993/08/27  00:56:27  bst
# Fixed MISSING check for include files.
# Put CC errors in SysConfig.errs.
#
# Revision 1.1  1993/08/25  18:13:40  bst
# Initial revision
#
#
#
:
# Check if a function is declared in any system headers
# Usage: CheckHasDecl function [include files]
#
# Returns non-zero exit status if not declared
# CC, CCFLAGS, and DEFHEADERS must be defined before calling.
# Reads from syscap.new
# Appends to 'SysConfig.errs'
echo $0 $*  >>SysConfig.errs
function=$1
tmp=checkhasdecl$$
shift
{
    for i in $DEFHEADERS $*
    do
	grep -s "MISSING_`echo $i|tr './' '__'`" syscap.new >/dev/null || echo '#include <'$i'>'
    done
    echo "extern struct { int x; float y; } $function();"
    echo "main() { $function(); }"
} > ${tmp}.c
if $CC $CCFLAGS -c ${tmp}.c >>SysConfig.errs 2>&1
then
    rm -f ${tmp}.*
    exit 1
else
    rm -f ${tmp}.*
    exit 0
fi
