dnl Process this file with autoconf to produce configure.

AC_INIT(Library/greg.c)
. ./GREG-VERSION

AC_CONFIG_HEADER(Library/config.h)

#--------------------------------------------------------------------
# Determine the host, build, and target systems
#--------------------------------------------------------------------
AC_CANONICAL_SYSTEM

HAVE_PTS_STREAM_MODULES=0
case "${target}" in
  *-sysv-*)
    HAVE_PTS_STREAM_MODULES=1
    ;;
esac
AC_DEFINE_UNQUOTED(HAVE_PTS_STREAM_MODULES, $HAVE_PTS_STREAM_MODULES)
AC_SUBST(HAVE_PTS_STREAM_MODULES)

#--------------------------------------------------------------------
# Find the compiler
#--------------------------------------------------------------------
AC_PROG_CC
AC_PROG_CPP
AM_PROG_LIBTOOL

AC_ARG_WITH(guile-path,
           [  --with-guile-path=DIR   How to call guile], ,)

AC_PATH_PROG(GUILEPATH, guile, NONE, $PATH:$with_guile_path)
if test "$GUILEPATH" = "NONE"; then
  echo "********************************************************************"
  echo "You need guile in order to use this library. If it is not in your"
  echo "path, set the correct path by calling configure with --with-guile-path"
  echo "set to the correct path (e.g. configure --with-guile-path=/usr/bin/guile)"
  echo "********************************************************************"
  AC_ERROR(No guile found - cannot continue)
fi

AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(libc.h limits.h malloc.h memory.h string.h signal.h sys/file.h sys/fcntl.h sys/ioctl.h sys/stropts.h unistd.h utime.h libguile.h)

AC_TYPE_GETGROUPS
AC_TYPE_SIGNAL
AC_TYPE_MODE_T

AC_CHECK_FUNCS(strerror grantpt setpgid setsid tcgetpgrp tcsetpgrp waitpid)

GUILE_LIB_PATH=`$GUILEPATH -c '(display (string-append (%package-data-dir) "/" (version)))'`

AC_DEFINE_UNQUOTED(GUILE_LIB_PATH, $GUILE_LIB_PATH)

GUILE_BIN_PATH=$GUILE_LIB_PATH/greg
AC_DEFINE_UNQUOTED(GUILE_BIN_PATH, $GUILE_BIN_PATH)
AC_SUBST(GUILE_BIN_PATH)

GUILE_SCM_PATH=$GUILE_LIB_PATH/ice-9
AC_DEFINE_UNQUOTED(GUILE_SCM_PATH, $GUILE_SCM_PATH)
AC_SUBST(GUILE_SCM_PATH)

GUILE_FLAGS

AC_DEFINE_UNQUOTED(VERSION, $VERSION)
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(MAJOR_VERSION, $MAJOR_VERSION)
AC_SUBST(MAJOR_VERSION)
AC_DEFINE_UNQUOTED(MINOR_VERSION, $MINOR_VERSION)
AC_SUBST(MINOR_VERSION)

AC_OUTPUT(Library/Makefile Library/greg Library/greg.scm Documentation/Makefile Documentation/gregdoc config.mak)

