dnl     This file is an input file used by the GNU "autoconf" program to
dnl     generate the file "configure", which is run during vbox installation
dnl     to configure the system for the local environment.

AC_INIT(src/vboxgetty.h)
AC_CONFIG_HEADER(src/config.h)

dnl #------------------------------------------------------------------------#
dnl # Some defaults:                                                         #
dnl #------------------------------------------------------------------------#

AC_PREFIX_DEFAULT(/usr/local/vbox)

dnl #------------------------------------------------------------------------#
dnl # Version of the vbox package. Theres no need to change this ;-)         #
dnl #------------------------------------------------------------------------#

PACKAGE="vbox"
VERSION="2.0.0 BETA 3"
VERDATE="01-May-97"

AC_DEFINE_UNQUOTED(PACKAGE, "${PACKAGE}")
AC_DEFINE_UNQUOTED(VERSION, "${VERSION}")
AC_DEFINE_UNQUOTED(VERDATE, "${VERDATE}")

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(VERDATE)

dnl #------------------------------------------------------------------------#
dnl # Checks for programs:                                                   #
dnl #------------------------------------------------------------------------#

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S

AC_PATH_PROG(VBOX_RM, rm, "rm")
AC_PATH_PROG(VBOX_MV, mv, "mv")
AC_PATH_PROG(VBOX_SED, sed, "sed")
AC_PATH_PROG(VBOX_MAIL, mail, "mail")
AC_PATH_PROG(VBOX_AR, ar, "ar")
AC_PATH_PROG(VBOX_RANLIB, ranlib, "ranlib")

AC_SUBST(VBOX_RM)
AC_SUBST(VBOX_MV)
AC_SUBST(VBOX_SED)
AC_SUBST(VBOX_MAIL)
AC_SUBST(VBOX_AR)
AC_SUBST(VBOX_RANLIB)

dnl #------------------------------------------------------------------------#
dnl # Checks for header files:                                               #
dnl #------------------------------------------------------------------------#

AC_HEADER_TIME
AC_CHECK_HEADERS(sys/time.h)

dnl #------------------------------------------------------------------------#
dnl # Checks for typedefs, structures, and compiler characteristics:         #
dnl #------------------------------------------------------------------------#

AC_C_CONST
AC_C_INLINE

AC_CHECK_FUNCS(vsnprintf)

dnl #------------------------------------------------------------------------#
dnl # Checks for needed external packages:                                   #
dnl #------------------------------------------------------------------------#

GND_PACKAGE_NCURSES
GND_PACKAGE_TCL

dnl #------------------------------------------------------------------------#
dnl # Checks for the configure options (--prefix, --with-*, etc.):           #
dnl #------------------------------------------------------------------------#

   dnl #==========#
   dnl # --prefix #
   dnl #==========#

AC_MSG_CHECKING(for prefix)

if (test "${prefix}" = "NONE")
then
   VBOX_PREFIX="${ac_default_prefix}"
else
   VBOX_PREFIX="${prefix}"
fi

AC_MSG_RESULT(${VBOX_PREFIX})

AC_SUBST(VBOX_PREFIX)

   dnl #=================#
   dnl # --with-spooldir #
   dnl #=================#

AC_MSG_CHECKING(where the messages are stored)

VBOX_SPOOLDIR="/var/spool/vbox"

AC_ARG_WITH(spooldir,
	[  --with-spooldir=DIR     vbox's stores messages in DIR [/var/spool/vbox]],
	VBOX_SPOOLDIR=${withval}
)

AC_MSG_RESULT(${VBOX_SPOOLDIR})

AC_DEFINE_UNQUOTED(SPOOLDIR, "${VBOX_SPOOLDIR}")
AC_SUBST(VBOX_SPOOLDIR)

   dnl #===============#
   dnl # --with-logdir #
   dnl #===============#

AC_MSG_CHECKING(where the logs are stored)

VBOX_LOGDIR="/var/log/vbox"

AC_ARG_WITH(logdir,
	[  --with-logdir=DIR       logs are stored in DIR [/var/log/vbox]],
	VBOX_LOGDIR=${withval}
)

AC_MSG_RESULT(${VBOX_LOGDIR})

AC_DEFINE_UNQUOTED(LOGFILEDIR, "${VBOX_LOGDIR}")
AC_SUBST(VBOX_LOGDIR)

   dnl #===============#
   dnl # --with-piddir #
   dnl #===============#

AC_MSG_CHECKING(where the pids are stored)

VBOX_PIDDIR="/var/run"

AC_ARG_WITH(piddir,
	[  --with-piddir=DIR       pids are stored in DIR [/var/run]],
	VBOX_PIDDIR=${withval}
)

AC_MSG_RESULT(${VBOX_PIDDIR})

AC_DEFINE_UNQUOTED(PIDFILEDIR, "${VBOX_PIDDIR}")
AC_SUBST(VBOX_PIDDIR)

   dnl #================#
   dnl # --with-lockdir #
   dnl #================#

AC_MSG_CHECKING(where the locks are made)

VBOX_LCKDIR="/var/lock"

AC_ARG_WITH(lockdir,
	[  --with-lockdir=DIR      locks are made in DIR [/var/lock]],
	VBOX_LCKDIR=${withval}
)

AC_MSG_RESULT(${VBOX_LCKDIR})

AC_DEFINE_UNQUOTED(LCKFILEDIR, "${VBOX_LCKDIR}")
AC_SUBST(VBOX_LCKDIR)

   dnl #===================#
   dnl # --with-i4lconfdir #
   dnl #===================#

AC_MSG_CHECKING(where the isdn configuration is stored)

if (test "$I4LCONFDIR" = "")
then
   ISDN_GLOBAL_CONFIG="/etc/isdn"
else
   ISDN_GLOBAL_CONFIG="${I4LCONFDIR}"
fi

AC_ARG_WITH(confdir,
	[  --with-i4lconfdir=DIR   global isdn configuration directory [\$I4LCONFDIR] ],
	ISDN_GLOBAL_CONFIG=${withval}
)

AC_MSG_RESULT(${ISDN_GLOBAL_CONFIG})

AC_DEFINE_UNQUOTED(I4LCONFDIR, "${ISDN_GLOBAL_CONFIG}")

dnl #------------------------------------------------------------------------#
dnl # Check and optimize compiler flags:                                     #
dnl #------------------------------------------------------------------------#

if (test "${ac_cv_prog_CC}" = "gcc")
then
   if (test "${CFLAGS}" != "")
   then
      FLAGOPMZ="no"
      FLAGWARN="no"

      for i in ${CFLAGS}
      do
         case "$i" in

            -O*) FLAGOPMZ="yes"
                 ;;
            -W*) FLAGWARN="yes"
                 ;;
         esac
      done

      if (test "${FLAGOPMZ}" = "no")
      then
         CFLAGS="-O2 ${CFLAGS}"
      fi

      if (test "${FLAGWARN}" = "no")
      then
         CFLAGS="-Wall ${CFLAGS}"
      fi
   else
      CFLAGS="-Wall -O2 ${CFLAGS}"
   fi
fi

dnl #------------------------------------------------------------------------#
dnl # Creates output files:                                                  #
dnl #------------------------------------------------------------------------#

AC_OUTPUT(Makefile src/Makefile)
