:
#
# Copyright 1993 Brent Townshend (bst@tc.com)
# Townshend Computer Tools
# Montreal, Quebec
#
# Wed Aug 25 11:38:25 EDT 1993
#
# Revision History: $Log: checklibs,v $
# Revision 1.2  1994/03/04  15:28:01  bst
#  Save command line and all C output in SysConfig.errs
# Removed -o option for CC command line (not supported by Borland)
# Remove a.out when done.
#
# Revision 1.1  1993/08/25  18:13:40  bst
# Initial revision
#
#
#
# Check if a function is defined in any system library
# Usage: CheckLibs function [extra libraries]
# Returns non-zero exit status if not defined
# CC, CCFLAGS, and EXTRALIBS must be defined before calling.
# Appends to 'SysConfig.errs' and 'syscap.new'
echo $0 $*  >>SysConfig.errs
tmp=checklibs$$
function=$1
shift
echo "extern int $function();"  > ${tmp}.c
echo 'main() { printf("a=%s",(char *)'$function'); }' >>${tmp}.c
if $CC $CCFLAGS ${tmp}.c $* $EXTRALIBS >>SysConfig.errs 2>&1
then
    # It does exist
    rm -f ${tmp}.* a.out
    echo "#define HAS_$function" >>syscap.new
    echo $n "$function+...$c"
    exit 0
else
    rm -f ${tmp}.* a.out
    echo "#define MISSING_$function" >>syscap.new
    echo $n "$function-...$c"
    exit 1 
fi
