dnl Process this file with autoconf to produce a configure script.
dnl ====NOTE: When the user has PREFIX defined, use that one.
dnl ----------------------------------------------------------------
AC_INIT(tex.c)
version=2.4 #`gawk '/^.VERSION/{v=$2}END{print v}' tex2a.c`
AC_SUBST(version)

dnl The default PREFIX ('cds' user uses local definitions)
test "$USER" = "" && USER=`basename $HOME`
AC_PREFIX_DEFAULT(`test X$USER = Xcds && echo $HOME || echo /usr/local`)

dnl Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_AWK
AC_PROG_CC

dnl Checks for libraries.
AC_PROG_RANLIB
AC_MSG_CHECKING(options from computer)
case `uname -m` in 
    alpha) a="alpha";   LIBSYS="-ldnet_stub" ;;
    sun4*) a="solaris"; LIBSYS="-lnsl -lsocket" ;
	which cc | fgrep SUNWspro>/dev/null && CC=cc && cc_opt="-Xt -DSOLARIS";;
    i??6)  a="linux";   LIBSYS="-lcrypt"; cc_opt="" ;;
    *)     a="unknown"; LIBSYS="" ;;
esac
AC_MSG_RESULT($a)
AC_SUBST(cc_opt)
AC_SUBST(LIBSYS)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h termio.h dirent.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_SUBST(CC)

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(gethostname socket strerror)

dnl ---- Verify the STRIP utility is not corrupted !
AC_MSG_CHECKING(strip utility)
echo '
#include <stdio.h>
int main()
{
  char buffer[[BUFSIZ]];
    while(fgets(buffer, sizeof(buffer), stdin))
        printf(">%s\\n", buffer);
}
' > ttest.c
$CC ttest.c
a=`strip a.out 2>&1| wc -w`
rm -f ttest.* a.out
if test $a -lt 1; then
    a=" ok "
    STRIP=strip
else
    a=" ***bad strip***"
    STRIP=echo
fi
AC_MSG_RESULT($a)
AC_SUBST(STRIP)

AC_OUTPUT(Makefile)

dnl --- Indicate the Default Directory Installation ---
test $prefix = /usr/local && altprefix=\$HOME || altprefix=/usr/local
echo "----the prefix for installation directories is:	$prefix"
echo "    If this choice is not convenient, re-execute this configure"
echo "    with the --prefix option, e.g."
echo " ./configure --prefix=$altprefix"
echo "----Otherwise, proceed with   make   followed by   make install"
