AC_REVISION($Id: configure.in,v 1.15 1997/04/17 15:59:03 dps Exp $)dnl
AC_INIT(word2x.cc)
AC_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_INSTALL

dnl check for built in getopt_long, alloca and strftime
AC_FUNC_CHECK(getopt_long, getopt="", getopt=gopt.o)
AC_SUBST(getopt)
AC_FUNC_ALLOCA
AC_HEADER_TIME
AC_STRUCT_TM

dnl locate some symbols I want (why does SUN have to do this to me?)
dnl At least these is some hack value in this stuff.
AC_DEFUN(ac_FIND_HDR,
[AC_MSG_CHECKING([header file for $1])
AC_CACHE_VAL(ac_cv_hdrfile_$1,
[ac_cv_hdrfile_$1=""
for xhdr in $2; do
if test -z "${ac_cv_hdrfile_$1}"; then
AC_TRY_COMPILE([#include <stdio.h>
#include<${xhdr}>],[ if ($1==$1) printf("ok");],
[ac_cv_hdrfile_$1=${xhdr}])
fi
done
if test -z "${ac_cv_hdrfile_$1}"; then
AC_MSG_RESULT("not found")
AC_ERROR([Could not locate $1])
fi])
AC_MSG_RESULT(<${ac_cv_hdrfile_$1}>)
$3="${ac_cv_hdrfile_$1}"])dnl

dnl Quite why Sun OS puts SEEK_SET in unistd.h (and not in stdio.h)
dnl is a mystery!!
ac_FIND_HDR(SEEK_SET, stdio.h unistd.h, seek_hdr)

if test "${seek_hdr}" = "stdio.h"; then
	seek_set_hdr=""
else
	seek_set_hdr="--include /usr/include/${seek_hdr}"
fi
AC_SUBST(seek_set_hdr)
AC_STDC_HEADERS
AC_CHECK_HEADERS(ctype.h string.h strings.h time.h sys/time.h sys/stat.h unistd.h alloca.h)
AC_CHECK_FUNCS(strncasecmp strcasecmp strdup localtime fstat)
AC_CHECK_LIB(sun)

dnl on some systems ld and g++ are not compatible, so we have to kludge it
dnl using the sunos_link shell script instead
AC_CHECKING([if I know ld and ${ac_cv_prog_CXX} might not work together])
AC_CANONICAL_SYSTEM
case "$target" in
*-*-hpux*) ld=ld
	AC_MSG_RESULT(
[Using ld, as on ${target} I know ld and ${ac_cv_prog_CXX} mix])
	;;
*-*-linux*) ld=ld
	AC_MSG_RESULT(
[Using ld, as on ${target} I know ld and ${ac_cv_prog_CXX} mix])
	;;

*SPARC*-*-SUN*)	ld=./fake_link
	AC_MSG_RESULT(
[Using my ar and ranlib shell script since ${ac_cv_prog_CXX} and ld do not mix])
	;;

*)          ld=./fake_link
	AC_MSG_RESULT(
[Using my ar and ranlib shell script lest ${ac_cv_prog_CXX} and ld do not mix])
	;;
esac
AC_SUBST(ld)

AC_OUTPUT(Makefile)
