dnl CF_MAWK_FIND_MAX_INT version: 5 updated: 2009/12/18 05:50:47
dnl --------------------
dnl Try to find a definition of MAX__INT from limits.h else compute.
AC_DEFUN([CF_MAWK_FIND_MAX_INT],
[AC_CHECK_HEADER(limits.h,cf_limits_h=yes)
if test "$cf_limits_h" = yes ; then :
else
AC_CHECK_HEADER(values.h,cf_values_h=yes)
   if test "$cf_values_h" = yes ; then
   AC_TRY_RUN(
[#include <values.h>
#include <stdio.h>
int main()
{   FILE *out = fopen("conftest.out", "w") ;
	unsigned max_uint = 0;
    if ( ! out ) exit(1) ;
    fprintf(out, "MAX__INT  0x%x\n", MAXINT) ;
    fprintf(out, "MAX__LONG 0x%lx\n", MAXLONG) ;
#ifdef MAXUINT
	max_uint = MAXUINT;	/* not likely (SunOS/Solaris lacks it) */
#else
	max_uint = MAXINT;
	max_uint <<= 1;
	max_uint |= 1;
#endif
    fprintf(out, "MAX__UINT 0x%lx\n", max_uint) ;
    exit(0) ; return(0) ;
}
], cf_maxint_set=yes,[CF_MAWK_CHECK_LIMITS_MSG])
   fi
if test "x$cf_maxint_set" != xyes ; then
# compute it  --  assumes two's complement
AC_TRY_RUN(CF_MAWK_MAX__INT_PROGRAM,:,[CF_MAWK_CHECK_LIMITS_MSG])
fi
cat conftest.out | while true
do
	read name value
	test -z "$name" && break
	AC_DEFINE_UNQUOTED($name,$value)
done
rm -f conftest.out
fi
])dnl
