dnl Process this file with Autoconf to produce a configure script for Web2c.
dnl
dnl Some things are no longer configurable:
dnl - SMALL{TeX,MF,BibTeX}: too painful to maintain the separate patch
dnl   files, and, for TeX, texmfmem.h would have to be fixed to support
dnl   more than 256 fonts.
dnl - NONASCII: necessary for the character translation feature.
dnl - REGFIX: modern compilers mostly ignore register declarations, anyway.
dnl The code for these things remains (where applicable), so you can
dnl get these features if you are willing to hack the sources. If not,
dnl it'll take a good argument to convince me to invest the time to make
dnl them configurable.
dnl 
dnl We don't use (for example) tex/tex.web because people who only want
dnl to build part of the distribution may not have any given program.
dnl Even main.c isn't guaranteed, but then nothing is, really ...
AC_INIT(web2c/main.c)

sinclude(../kpathsea/common.ac)

AC_PROG_YACC
AC_PROG_LEX
AC_PROG_LN_S
AC_PROG_RANLIB

AC_TYPE_SIGNAL

AC_DECL_YYTEXT
pb_AC_ASM_UNDERSCORE

# Needed on A/UX 3.0. I don't want to pull in other -lposix's, though.
# From: bernt@weinberg.pop.bio.aau.dk (Bernt Guldbrandtsen)
if test `(uname) 2>/dev/null` = aux; then
  AC_CHECK_LIB(posix, sigemptyset)
fi

dnl These tests prevent reliable cross-compilation.  Sigh.
AC_C_CHAR_UNSIGNED
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(long)

# --with and --enable options.
test "x$with_x_toolkit" = xyes && with_x=yes
: ${with_x=no} # tell PATH_XTRA no X by default, if not specified.
sinclude(withenable.ac)

# --with-x* options: Distinguish no X at all, no toolkit, or toolkit.
if test "x$with_x" = xyes; then
  wlibs="-lX11 $wlibs"
  if test -z "$x_ext_lib"; then # allow envvar override
    AC_CHECK_LIB(Xext, XextCreateExtension,
                 x_ext_lib=-lXext, :, $wlibs $X_EXTRA_LIBS)
  fi
  if test "x$with_x_toolkit" = xno; then
    wfile=x11-Xlib.c
  else
    # Effectively demote --with-x-toolkit=athena to xt since 
    # the code does not distinguish.
    x_tool_libs="-lXt $x_tool_libs"
    wfile=x11-Xt.c
  fi
  (cd window && (rm -f x11.c; $LN_S $wfile x11.c))
  AC_DEFINE(X11WIN)
fi
AC_SUBST(x_ext_lib)
AC_SUBST(x_tool_libs)
AC_SUBST(wlibs)


dnl Generate `Makefile's, `config.status', and our header file.
AC_OUTPUT(Makefile doc/Makefile lib/Makefile mpware/Makefile 
          web2c/Makefile window/Makefile tie/Makefile)
