dnl Template file for GNU Autoconf
dnl
dnl Copyright (c) 1995-1997, 2000 Thomas Esken
dnl
dnl This software doesn't claim completeness, correctness or usability.
dnl On principle I will not be liable for ANY damages or losses (implicit
dnl or explicit), which result from using or handling my software.
dnl If you use this software, you agree without any exception to this
dnl agreement, which binds you LEGALLY !!
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the `GNU General Public License' as published by
dnl the `Free Software Foundation'; either version 2, or (at your option)
dnl any later version.
dnl
dnl You should have received a copy of the `GNU General Public License'
dnl along with this program; if not, write to the:
dnl
dnl   Free Software Foundation, Inc.
dnl   59 Temple Place - Suite 330
dnl   Boston, MA 02111-1307,  USA
dnl

dnl
dnl Process this file with autoconf to produce a configure script for Gcal.
dnl

dnl
dnl Starting operations.
dnl
AC_INIT(src/defines.h)dnl
AC_PREREQ(2.13)dnl
AM_CONFIG_HEADER(config.h:config.hin)dnl
AC_REVISION($Id: configure.in 2.29 2000/04/05 02:02:09 tom Exp $)dnl

dnl
dnl Declare package name and version number.
dnl
PACKAGE=`sed -e '/PRGR_NAME/!d' -e 's/^.*"\(.*\)".*$/\1/' $srcdir/$ac_unique_file`
VERSION=`sed -e '/VERSION_NO/!d' -e 's/^.*"\(.*\)".*$/\1/' $srcdir/$ac_unique_file`
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

dnl
dnl Emit some text.  (I know that some people dislike a talkative `configure'
dnl script, but those persons should really use the `--quiet' option instead
dnl of writing me that I have to remove this behaviour, because I like it!)
dnl
AC_MSG_RESULT()
AC_MSG_RESULT(this is the automatical configuration step of $PACKAGE-$VERSION)
AC_MSG_RESULT()
AC_MSG_RESULT(please wait...)
AC_MSG_RESULT()

dnl
dnl Support transforming of program names.
dnl
AC_ARG_PROGRAM

dnl
dnl Check if the build environment is sane.
dnl
AM_SANITY_CHECK

dnl
dnl Checks for Gcal specific package options.
dnl
AC_MSG_RESULT()
AC_CHECKING(for $PACKAGE specific package options)
dnl
AC_MSG_CHECKING(for language used in documentation files)
AC_ARG_ENABLE(de,
  [  --enable-de             create and install German documentation files],
  doclang=de,
  doclang=en)
AC_MSG_RESULT(LANG=$doclang)
AC_SUBST(doclang)dnl
dnl
AC_MSG_CHECKING(whether extended ASCII character set is required)
AC_ARG_ENABLE(easc,
  [  --enable-easc           use extended ASCII character set],
  gcal_cv_use_easc=$enableval,
  gcal_cv_use_easc=no)
AC_MSG_RESULT($gcal_cv_use_easc)
if test "$gcal_cv_use_easc" = yes; then
  AC_DEFINE(USE_EASC)
fi
dnl
AC_MSG_CHECKING(whether all available country specific holidays are required)
AC_ARG_ENABLE(cc-holidays,
  [  --disable-cc-holidays   do not use all available country specific holidays],
  gcal_cv_use_cc_holidays=$enableval,
  gcal_cv_use_cc_holidays=yes)
AC_MSG_RESULT($gcal_cv_use_cc_holidays)
if test "$gcal_cv_use_cc_holidays" = yes; then
  GCAL_HD_OBJS="\$(GCAL_HD_OBJS)"
else
  AC_DEFINE(HD_TOP20CC)
fi
AC_SUBST(GCAL_HD_OBJS)
dnl
AC_MSG_CHECKING(whether highlighting sequences are required)
AC_ARG_ENABLE(hls,
  [  --disable-hls           do not use highlighting sequences],
  gcal_cv_use_hls=$enableval,
  gcal_cv_use_hls=yes)
AC_MSG_RESULT($gcal_cv_use_hls)
if test "$gcal_cv_use_hls" = yes; then
  AC_DEFINE(USE_HLS)
fi
dnl
AC_MSG_CHECKING(whether pager feature is required)
AC_ARG_ENABLE(pager,
  [  --disable-pager         do not use external or simple internal pager feature],
  gcal_cv_use_pager=$enableval,
  gcal_cv_use_pager=yes)
AC_MSG_RESULT($gcal_cv_use_pager)
if test "$gcal_cv_use_pager" = yes; then
  AC_DEFINE(USE_PAGER)
fi
dnl
AC_MSG_CHECKING(whether fixed date feature is required)
AC_ARG_ENABLE(rc,
  [  --disable-rc            do not use fixed date feature],
  gcal_cv_use_rc=$enableval,
  gcal_cv_use_rc=yes)
AC_MSG_RESULT($gcal_cv_use_rc)
if test "$gcal_cv_use_rc" = yes; then
  GCAL_RC_OBJS="\$(GCAL_RC_OBJS)"
  AC_DEFINE(USE_RC)
fi
AC_SUBST(GCAL_RC_OBJS)
dnl
AC_MSG_CHECKING(whether terminal libraries are required)
AC_ARG_ENABLE(term,
  [  --disable-term          do not use libncurses/libtermcap/libtermlib],
  gcal_cv_use_term=$enableval,
  gcal_cv_use_term=yes)
AC_MSG_RESULT($gcal_cv_use_term)
dnl
AC_MSG_CHECKING(whether included V8 regexps are requested)
AC_ARG_WITH(included-regexps,
  [  --with-included-regexps use the V8 regexps included here],
  gcal_cv_use_included_regexps=$withval,
  gcal_cv_use_included_regexps=no)
AC_MSG_RESULT($gcal_cv_use_included_regexps)
if test "$gcal_cv_use_included_regexps" = yes; then
  if test -f "${srcdir}/src/regexp.c"; then
    AC_DEFINE(HAVE_V8_REGCOMP)
    REGEX_O='regexp$(O)'
    AC_SUBST(REGEX_O)
  else
    gcal_cv_use_included_regexps=no
    AC_MSG_RESULT()
    AC_MSG_WARN(cannot find the included V8 regexps as requested!)
    AC_MSG_RESULT()
  fi
fi

dnl
dnl Checks for programs.
dnl
AC_MSG_RESULT()
AC_CHECKING(for programs)
dnl
dnl Checks for make.
dnl
AC_PROG_MAKE_SET
dnl
dnl Checks for strip.
dnl
AC_CHECK_PROGS(STRIP, gstrip gnustrip strip)
if test -z "$ac_cv_prog_STRIP"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no installation of stripped executable files!)
  AC_MSG_WARN(Makefile target *install-strip* will never be executed.)
  AC_MSG_RESULT()
fi
dnl
dnl Checks for makeinfo.
dnl
AC_CHECK_PROGS(MAKEINFO, gmakeinfo gnumakeinfo makeinfo)
if test -z "$ac_cv_prog_MAKEINFO"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic recreation of HTML and Info documentation files!)
  AC_MSG_WARN(Makefile targets *html* and *info* will never be executed.)
  AC_MSG_RESULT()
else
  AC_MSG_CHECKING(for $ac_cv_prog_MAKEINFO version)
  changequote(<<, >>)dnl
  dnl
  dnl Gcal needs `makeinfo' from GNU Texinfo 3.12t minimum,
  dnl so check the version number `makeinfo' emits.
  dnl
  makeinfo_version=`$ac_cv_prog_MAKEINFO --version 2>&1 | \
                      sed -e '/[Mm]akeinfo/!d' \
                          -e 's,\ ,@,' \
                          -e 's,.*@,,' \
                          -e 's,^[a-zA-Z\ \(\)]*,,g' \
                          -e 's,).*,,'`
  makeinfo_version_prefix=`echo "$makeinfo_version" | \
                             sed -e 's,\..*,,'`
  makeinfo_version_suffix=`echo "$makeinfo_version" | \
                             sed -e 's,[a-zA-Z\-].*,,' \
                                 -e 's,\.,@,' \
                                 -e 's,.*@,,' \
                                 -e 's,\..*,,'`
  makeinfo_version_subsuffix=`echo "$makeinfo_version" | \
                                sed -e 's,[0-9\.\-]*,,'`
  if test -z "$makeinfo_version_prefix";
  then
    makeinfo_version_prefix=nil
    makeinfo_version="$makeinfo_version_prefix"
  else
    if test -z "$makeinfo_version_suffix";
    then
      makeinfo_version_suffix=nil
      makeinfo_version="$makeinfo_version_prefix.$makeinfo_version_suffix"
    else
      if test -z "$makeinfo_version_subsuffix";
      then
        makeinfo_version_subsuffix="nil"
      fi
    fi
  fi
  makeinfo_error=no
  case "$makeinfo_version_prefix" in
    nil | [0-2]) makeinfo_error=yes ;;
    3) case "$makeinfo_version_suffix" in
         nil | [0-9] | 10 | 11) makeinfo_error=yes ;;
         12) case "$makeinfo_version_subsuffix" in
               nil | [a-s] ) makeinfo_error=yes ;;
             esac
       esac
  esac
  gcal_cv_prog_MAKEINFO_VERSION="$makeinfo_version"
  changequote([, ])dnl
  AC_MSG_RESULT($gcal_cv_prog_MAKEINFO_VERSION)
  if test "$makeinfo_error" = yes; then
    gcal_cv_prog_MAKEINFO_VERSION=""
    AC_MSG_RESULT()
    AC_MSG_WARN(no automatic recreation of HTML and Info documentation files!)
    AC_MSG_WARN(the makeinfo program is out of date.)
    AC_MSG_WARN(install *GNU Texinfo-3.12t* or later in order to)
    AC_MSG_WARN(recreate the distribution *.html and *.info files.)
    AC_MSG_WARN(Makefile targets *html* and *info* will never be executed.)
    AC_MSG_RESULT()
  fi
  MAKEINFO_VERSION=$gcal_cv_prog_MAKEINFO_VERSION
  AC_SUBST(MAKEINFO_VERSION)dnl
fi
dnl
dnl Checks for texi2dvi.
dnl
AC_CHECK_PROGS(TEXI2DVI, gtexi2dvi gnutexi2dvi texi2dvi)
if test -z "$ac_cv_prog_TEXI2DVI"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of DVI file!)
  AC_MSG_WARN(Makefile target *dvi* will never be executed.)
  AC_MSG_RESULT()
else
  AC_MSG_CHECKING(for $ac_cv_prog_TEXI2DVI version)
  changequote(<<, >>)dnl
  dnl
  dnl Gcal needs `texi2dvi' from GNU Texinfo 3.12p minimum,
  dnl so check the version number `texi2dvi' emits.
  dnl
  texi2dvi_version=`$ac_cv_prog_TEXI2DVI --version 2>&1 | \
                      sed -e '/[Tt]exi2dvi/!d' \
                          -e 's,\ ,@,' \
                          -e 's,.*@,,' \
                          -e 's,^[a-zA-Z\ \(\)]*,,g' \
                          -e 's,).*,,'`
  texi2dvi_version_prefix=`echo "$texi2dvi_version" | \
                             sed -e 's,\..*,,'`
  texi2dvi_version_suffix=`echo "$texi2dvi_version" | \
                             sed -e 's,[a-zA-Z\-].*,,' \
                                 -e 's,\.,@,' \
                                 -e 's,.*@,,' \
                                 -e 's,\..*,,'`
  texi2dvi_version_subsuffix=`echo "$texi2dvi_version" | \
                                sed -e 's,[0-9\.\-]*,,'`
  if test -z "$texi2dvi_version_prefix";
  then
    texi2dvi_version_prefix=nil
    texi2dvi_version="$texi2dvi_version_prefix"
  else
    if test -z "$texi2dvi_version_suffix";
    then
      texi2dvi_version_suffix=nil
      texi2dvi_version="$texi2dvi_version_prefix.$texi2dvi_version_suffix"
    else
      if test -z "$texi2dvi_version_subsuffix";
      then
        texi2dvi_version_subsuffix="nil"
      fi
    fi
  fi
  texi2dvi_error=no
  case "$texi2dvi_version_prefix" in
    nil | [0-2]) texi2dvi_error=yes ;;
    3) case "$texi2dvi_version_suffix" in
         nil | [0-9] | 10 | 11) texi2dvi_error=yes ;;
         12) case "$texi2dvi_version_subsuffix" in
               nil | [a-o] ) texi2dvi_error=yes ;;
             esac
       esac
  esac
  gcal_cv_prog_TEXI2DVI_VERSION="$texi2dvi_version"
  changequote([, ])dnl
  AC_MSG_RESULT($gcal_cv_prog_TEXI2DVI_VERSION)
  if test "$texi2dvi_error" = yes; then
    gcal_cv_prog_TEXI2DVI_VERSION=""
    AC_MSG_RESULT()
    AC_MSG_WARN(no automatic creation of DVI file!)
    AC_MSG_WARN(the texi2dvi program is out of date.)
    AC_MSG_WARN(install *GNU Texinfo-3.12p* or later in order to)
    AC_MSG_WARN(create the DVI file.)
    AC_MSG_WARN(Makefile target *dvi* will never be executed.)
    AC_MSG_RESULT()
  fi
  TEXI2DVI_VERSION=$gcal_cv_prog_TEXI2DVI_VERSION
  AC_SUBST(TEXI2DVI_VERSION)dnl
fi
dnl
dnl Checks for shar.
dnl
AC_CHECK_PROGS(SHAR, gshar gnushar shar)
if test -z "$ac_cv_prog_SHAR"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of shared distribution!)
  AC_MSG_WARN(Makefile target *distshar* will never be executed.)
  AC_MSG_RESULT()
fi
dnl
dnl Checks for zip.
dnl
AC_CHECK_PROG(ZIP, zip, zip)
if test -z "$ac_cv_prog_ZIP"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of zipped distribution!)
  AC_MSG_WARN(Makefile target *distzip* will never be executed.)
  AC_MSG_RESULT()
fi
dnl
dnl Checks for zoo.
dnl
AC_CHECK_PROG(ZOO, zoo, zoo)
if test -z "$ac_cv_prog_ZOO"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of zooed distribution!)
  AC_MSG_WARN(Makefile target *distzoo* will never be executed.)
  AC_MSG_RESULT()
fi
dnl
dnl Checks for lha.
dnl
AC_CHECK_PROGS(LHA, lha lharc)
if test -z "$ac_cv_prog_LHA"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of lhaed distribution!)
  AC_MSG_WARN(Makefile target *distlha* will never be executed.)
  AC_MSG_RESULT()
fi
dnl
dnl Checks for archivers (gnutar gtar, tar) and compressors (gzip, compress).
dnl
AC_CHECK_PROGS(TAR, gtar gnutar tar)
if test -z "$ac_cv_prog_TAR"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of gzipped/compressed distribution!)
  AC_MSG_WARN(Makefile target *dist* will never be executed.)
  AC_MSG_RESULT()
else
  AC_CHECK_PROGS(GZIP, gzip gnuzip)
  if test -z "$ac_cv_prog_GZIP"; then
    AC_CHECK_PROG(COMPRESS, compress, compress)
  fi
  if test -z "$ac_cv_prog_GZIP" && test -z "$ac_cv_prog_COMPRESS"; then
    AC_MSG_RESULT()
    AC_MSG_WARN(no automatic creation of gzipped/compressed distribution!)
    AC_MSG_WARN(Makefile target *dist* will never be executed.)
    AC_MSG_RESULT()
  fi
fi
dnl
dnl Checks for text converters/interpreters (perl, awk).
dnl
AC_CHECK_PROG(PERL, perl, perl)
AC_PROG_AWK
if test -z "$ac_cv_prog_AWK"; then
  dnl
  dnl Previous AC_PROG_AWK has already checked for `gawk'.
  dnl
  AC_CHECK_PROG(AWK, gnuawk, gnuawk)
  if test -z "$ac_cv_prog_AWK"; then
    AC_MSG_RESULT()
    AC_MSG_WARN(no automatic installation of dates files!)
    AC_MSG_WARN(Makefile target *installdates* will never be executed)
    AC_MSG_WARN(and some other targets will create useless script files.)
    AC_MSG_RESULT()
  fi
fi
dnl
dnl Checks for zdump.
dnl
AC_PATH_PROG(ZDUMP, zdump, , $PATH:\
/sbin:\
/usr/sbin:\
/usr/local/sbin:\
/usr/etc:\
/usr/etc/zoneinfo:\
/usr/lib:\
/usr/lib/zoneinfo:\
/usr/share:\
/usr/share/zoneinfo:\
/usr/share/lib:\
/usr/share/lib/zoneinfo:\
/usr/share/etc:\
/usr/share/etc/zoneinfo:\
/usr/local/etc:\
/usr/local/etc/zoneinfo:\
/usr/local/lib:\
/usr/local/lib/zoneinfo:\
/usr/local/share:\
/usr/local/share/zoneinfo:\
/usr/local/share/lib:\
/usr/local/share/lib/zoneinfo:\
/usr/local/share/etc:\
/usr/local/share/etc/zoneinfo:\
/opt/gnu/sbin:\
/opt/gnu/usr/sbin:\
/opt/gnu/usr/local/sbin:\
/opt/gnu/etc:\
/opt/gnu/etc/zoneinfo:\
/opt/gnu/lib:\
/opt/gnu/lib/zoneinfo:\
/opt/gnu/share:\
/opt/gnu/share/zoneinfo:\
/opt/gnu/share/lib:\
/opt/gnu/share/lib/zoneinfo:\
/opt/gnu/share/etc:\
/opt/gnu/share/etc/zoneinfo)
if test -z "$ac_cv_path_ZDUMP"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(Ask your sysadmin for the ZONEINFO time zone dumping program!)
  AC_MSG_WARN(Makefile target *dst* will produce a useless script file.)
  AC_MSG_RESULT()
fi
if test "$gcal_cv_use_pager" = yes; then
  dnl
  dnl Checks for ``external'' pager programs (less, more, pg).
  dnl
  AC_CHECK_PROG(PAGER1, less, less)
  AC_DEFINE_UNQUOTED(PAGER1_PROG, "$PAGER1")
  AC_CHECK_PROG(PAGER2, more, more)
  AC_DEFINE_UNQUOTED(PAGER2_PROG, "$PAGER2")
  AC_CHECK_PROG(PAGER3, pg, pg)
  AC_DEFINE_UNQUOTED(PAGER3_PROG, "$PAGER3")
fi
dnl
dnl Checks for cp.
dnl
AC_CHECK_PROGS(CP, cp copy)
if test -n "$ac_cv_prog_CP"; then
  if test "$ac_cv_prog_CP" = cp; then
    CP="cp -p"
  else
    if test "$ac_cv_prog_CP" != "cp -p"; then
      if test "$ac_cv_prog_CP" != "copy -m"; then
        dnl
        dnl Assume `copy -m' on SCO 3.2v4 which does not have `cp -p'.
        dnl
        CP="copy -m"
      fi
    fi
  fi
  AC_SUBST(CP)
fi

dnl
dnl Checks for install program/script.
dnl
AM_PROG_INSTALL

dnl
dnl Checks whether `ln -s' works.
dnl
AC_PROG_LN_S

dnl
dnl Checks for C compiler.
dnl
if test -z "$CFLAGS"; then
  gcal_possibly_adjust_cflags=yes
fi
AC_MSG_RESULT()
AC_CHECKING(for C compiler)
dnl
AC_PROG_CC
if test -z "$ac_cv_prog_CC"; then
  AC_MSG_RESULT(hmm... whats this??)
  AC_MSG_RESULT()
  AC_MSG_ERROR(no C compiler found -- aborting...)
fi
dnl
AC_PROG_GCC_TRADITIONAL
dnl
dnl Set some warning flags in CFLAGS if this environment variable was either
dnl undefined or not set before previous COMPILER test, and `gcc' is found.
dnl
if test "$gcal_possibly_adjust_cflags" = yes && test -n "$GCC"; then
  CFLAGS="$CFLAGS -Wall"
fi

dnl
dnl Checks for operating system variants.
dnl
AC_MSG_RESULT()
AC_CHECKING(for operating system variants)
dnl
AC_AIX
AC_MINIX
AC_ISC_POSIX

dnl
dnl Checks for libraries.
dnl
AC_MSG_RESULT()
AC_CHECKING(for libraries)
dnl
dnl Checks for terminal libraries.
dnl
if test "$gcal_cv_use_term" = yes; then
  gcal_ttylibs_ok=no
  gcal_libtermlib_ok=no
  TTYLIBS=
  AC_CHECK_LIB(ncurses,
    initscr,
    [TTYLIBS="-lncurses"])
  if test -z "$TTYLIBS"; then
    AC_CHECK_LIB(termcap,
      tgetent,
      [TTYLIBS="-ltermcap"])
    AC_CHECK_LIB(termlib,
      tgetent,
      [have_libtermlib=yes],
      [have_libtermlib=no])
  fi
  dnl
  dnl Solaris has termcap, but it don't work without libucb
  dnl which is broken, so we use termlib.
  dnl
  AC_MSG_CHECKING(for working terminal libraries)
  SAVE_LIBS=$LIBS
  LIBS="$LIBS $TTYLIBS"
  AC_TRY_LINK(,
    [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
    [gcal_ttylibs_ok=yes])
  if test "$gcal_ttylibs_ok" = yes; then
    AC_DEFINE(HAVE_TTYLIBS)
    AC_MSG_RESULT(using $TTYLIBS)
  else
    if test "$TTYLIBS" = "-lncurses"; then
      AC_MSG_RESULT(using $TTYLIBS fails)
      LIBS="$SAVE_LIBS"
      AC_CHECK_LIB(termcap,
        tgetent,
        [TTYLIBS="-ltermcap"])
      AC_MSG_CHECKING(for working terminal libraries again)
      LIBS="$LIBS $TTYLIBS"
      AC_TRY_LINK(,
        [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
        [gcal_ttylibs_ok=yes])
      if test "$gcal_ttylibs_ok" = yes; then
        AC_DEFINE(HAVE_TTYLIBS)
        AC_MSG_RESULT(using $TTYLIBS)
      else
        AC_MSG_RESULT(using $TTYLIBS fails)
        LIBS="$SAVE_LIBS"
        AC_CHECK_LIB(termlib,
          tgetent,
          [have_libtermlib=yes],
          [have_libtermlib=no])
        TTYLIBS="-ltermlib"
        LIBS="$LIBS $TTYLIBS"
        if test "$have_libtermlib" = yes; then
          AC_MSG_CHECKING(for working terminal libraries again)
          AC_TRY_LINK(,
            [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
            [gcal_libtermlib_ok=yes])
          if test "$gcal_libtermlib_ok" = yes; then
            AC_DEFINE(HAVE_TTYLIBS)
            AC_MSG_RESULT(using $TTYLIBS)
          fi
        fi
      fi
    else
      if test "$have_libtermlib" = yes; then
        TTYLIBS="-ltermlib"
        LIBS="$SAVE_LIBS $TTYLIBS"
        AC_TRY_LINK(,
          [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
          [gcal_libtermlib_ok=yes])
        if test "$gcal_libtermlib_ok" = yes; then
          AC_DEFINE(HAVE_TTYLIBS)
          AC_MSG_RESULT(using $TTYLIBS)
        fi
      fi
    fi
  fi
  if test "$gcal_ttylibs_ok" = no && test "$gcal_libtermlib_ok" = no; then
    LIBS="$SAVE_LIBS"
    AC_MSG_RESULT(hmm... whats this??)
    AC_MSG_RESULT()
    AC_MSG_WARN(no terminal libraries available)
    AC_MSG_WARN()
    AC_MSG_WARN(this means $PACKAGE-$VERSION will use its defaults now)
    AC_MSG_WARN(and is unable to support several terminal types!)
    AC_MSG_WARN(note: $PACKAGE-$VERSION would work more flexible if libncurses.a)
    AC_MSG_WARN(libtermcap.a or libtermlib.a are installed.)
    AC_MSG_RESULT()
  fi
fi
if test "$gcal_cv_use_included_regexps" = no; then
  dnl
  dnl Check for regular expression libraries.  GNU regexp functions preferred!
  dnl
  AC_CHECK_LIB(regex, re_compile_pattern)
  dnl
  dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
  dnl and in -lintl on SCO Unix.
  dnl
  AC_CHECK_LIB(gen, regcmp)
  AC_CHECK_LIB(intl, regcmp)
  AC_CHECK_LIB(PW, regcmp)
  dnl
  dnl Store whether regcmp is stored in -lintl.
  dnl
  if test -n "`echo $LIBS | grep '\-lintl'`"; then
    need_sys_lintl_for_regcmp=yes
  fi
fi
dnl
dnl Check for mathematical library.
dnl
AC_CHECK_LIB(m,
  cos,
  [LIBM="-lm"
   AC_DEFINE(HAVE_LIBM)
   have_libm=yes],
  [have_libm=no])
AC_SUBST(LIBM)

dnl
dnl Checks for header files.
dnl
AC_MSG_RESULT()
AC_CHECKING(for header files)
dnl
AC_STDC_HEADERS
AC_CHECK_HEADERS(stdio.h stdlib.h string.h unistd.h ctype.h errno.h limits.h)
AC_CHECK_HEADERS(assert.h signal.h termio.h termios.h sgtty.h)
if test "$gcal_cv_use_term" = yes; then
  if test "$gcal_ttylibs_ok" = yes || test "$gcal_libtermlib_ok" = yes; then
    AC_CHECK_HEADERS(termcap.h)
  fi
fi
if test "$have_libm" = yes; then
  AC_CHECK_HEADERS(math.h)
fi
if test "$gcal_cv_use_included_regexps" = no; then
  AC_CHECK_HEADERS(regex.h)
fi
if test "$gcal_cv_use_pager" = yes; then
  AC_CHECK_HEADERS(fcntl.h)
  AC_HEADER_SYS_WAIT
fi
AC_CHECK_HEADERS(sys/ioctl.h sys/stream.h sys/ptem.h sys/stat.h sys/types.h sys/time.h)

dnl
dnl Checks for typedefs and structures.
dnl
AC_MSG_RESULT()
AC_CHECKING(for typedefs and structures)
dnl
if test "$gcal_cv_use_pager" = yes; then
  AC_TYPE_PID_T
fi
AC_TYPE_SIGNAL
AC_HEADER_TIME
AC_MSG_CHECKING(for time_t)
AC_CACHE_VAL(gcal_cv_type_time_t,
  AC_TRY_COMPILE([
#    if TIME_WITH_SYS_TIME
#      include <sys/time.h>
#      include <time.h>
#    else
#      if HAVE_SYS_TIME_H
#        include <sys/time.h>
#      else
#        include <time.h>
#      endif
#    endif],
    [time_t t = 0;],
    [gcal_cv_type_time_t=yes],
    [gcal_cv_type_time_t=no]))
if test "$gcal_cv_type_time_t" = yes; then
  AC_DEFINE(HAVE_TIME_T)
fi
AC_MSG_RESULT($gcal_cv_type_time_t)

dnl
dnl Checks for compiler characteristics.
dnl
AC_MSG_RESULT()
AC_CHECKING(for compiler characteristics)
dnl
AC_C_CONST
dnl
AC_MSG_CHECKING(for void)
AC_CACHE_VAL(gcal_cv_c_void,
  AC_TRY_COMPILE(,
    [void *foo = 0;],
    [gcal_cv_c_void=yes],
    [gcal_cv_c_void=no]))
if test "$gcal_cv_c_void" = yes; then
  AC_DEFINE(HAVE_VOID)
fi
AC_MSG_RESULT($gcal_cv_c_void)

dnl
dnl Checks for library functions.
dnl
AC_MSG_RESULT()
AC_CHECKING(for library functions)
dnl
if test "$gcal_cv_use_pager" = yes; then
  AC_CHECK_FUNCS([dup dup2])
fi
AC_CHECK_FUNCS([signal strtol strstr strchr strrchr strcspn strcasecmp strncasecmp])
dnl
dnl Some systems have termios.h but not the corresponding functions.
dnl
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
dnl
dnl Check for working system() function.
dnl
AC_MSG_CHECKING(for working system function)
AC_CACHE_VAL(gcal_cv_func_system_ok,
  AC_TRY_RUN([
#    if STDC_HEADERS
#      include <stdlib.h>
#    endif
    int main()
    {
      int i;
      i = system(NULL);
      if (!i)
        exit(1);
      exit(0);
    }],
    gcal_cv_func_system_ok=yes,
    gcal_cv_func_system_ok=no,
    gcal_cv_func_system_ok=no))
AC_MSG_RESULT($gcal_cv_func_system_ok)
if test "$gcal_cv_func_system_ok" = yes; then
  AC_DEFINE(HAVE_SYSTEM)
fi
if test "$gcal_cv_use_included_regexps" = no; then
  dnl
  dnl Checks for regular expression functions.
  dnl
  have_regexp=no
  AC_MSG_RESULT()
  AC_CHECKING(for regular expression functions)
  dnl
  dnl Are the preferred GNU regexp functions available?
  dnl
  AC_CHECK_FUNC(re_compile_pattern,
    AC_MSG_RESULT(using GNU re_compile_pattern)
    AC_DEFINE(HAVE_GNU_RE_COMPILE_PATTERN)
    have_regexp=yes)
  if test "$have_regexp" = no; then
    have_posix_regexp=unknown
    dnl
    dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
    dnl So we run a test program.  If we're cross-compiling, do it the old way.
    dnl
    AC_TRY_RUN([
#      if HAVE_SYS_TYPES_H
#        include <sys/types.h>
#      endif
#      if HAVE_REGEX_H
#        include <regex.h>
#      endif
      int main()
      {
        regex_t r;
        regmatch_t rm;
        if (regcomp(&r, "abc", 0))
          exit(1);
        if (regexec(&r, "xabcy", 1, &rm, 0))
          exit(1);
        exit(0);
      }],
      have_posix_regexp=yes,
      have_posix_regexp=no,
      have_posix_regexp=unknown)
    if test "$have_posix_regexp" = yes; then
      AC_MSG_RESULT(using POSIX regcomp)
      AC_DEFINE(HAVE_POSIX_REGCOMP)
      have_regexp=yes
    else
      if test "$have_posix_regexp" = unknown; then
        AC_TRY_LINK([
#          if HAVE_SYS_TYPES_H
#            include <sys/types.h>
#          endif
#          if HAVE_REGEX_H
#            include <regex.h>
#          endif],
          [regex_t *r;
           regfree(r);],
          AC_MSG_RESULT(using POSIX regcomp)
          AC_DEFINE(HAVE_POSIX_REGCOMP)
          have_regexp=yes)
      fi
    fi
    if test "$have_regexp" = no; then
      AC_CHECK_FUNC(re_comp,
        AC_MSG_RESULT(using BSD re_comp)
        AC_DEFINE(HAVE_RE_COMP)
        have_regexp=yes)
    fi
    if test "$have_regexp" = no; then
      AC_CHECK_FUNC(regcmp,
        AC_MSG_RESULT(using SysV regcmp)
        AC_DEFINE(HAVE_REGCMP)
        have_regexp=yes)
    fi
    if test "$have_regexp" = no && test -f "${srcdir}/src/regexp.c"; then
      AC_MSG_RESULT(using V8 regcomp)
      AC_DEFINE(HAVE_V8_REGCOMP)
      REGEX_O='regexp$(O)'
      AC_SUBST(REGEX_O)
      have_regexp=yes
    fi
    if test "$have_regexp" = no; then
      AC_MSG_RESULT(cannot find any regular expression library)
      AC_DEFINE(NO_REGEX)
    fi
  fi
fi
dnl
dnl Checks for ctype functions.
dnl
AC_MSG_RESULT()
AC_CHECKING(for ctype library functions)
dnl
AC_MSG_CHECKING(for upper/lower)
AC_CACHE_VAL(gcal_cv_func_upper_lower,
  AC_TRY_LINK([
#    if HAVE_CTYPE_H
#      include <ctype.h>
#    endif],
    [static int x; x = tolower(x); x = toupper(x); x = islower(x); x = isupper(x);],
    [gcal_cv_func_upper_lower=yes],
    [gcal_cv_func_upper_lower=no]))
if test "$gcal_cv_func_upper_lower" = yes; then
  AC_DEFINE(HAVE_UPPER_LOWER)
fi
AC_MSG_RESULT($gcal_cv_func_upper_lower)
dnl
AC_MSG_CHECKING(for isdigit)
AC_CACHE_VAL(gcal_cv_func_isdigit,
  AC_TRY_LINK([
#    if HAVE_CTYPE_H
#      include <ctype.h>
#    endif],
    [static int x; x = isdigit(x);],
    [gcal_cv_func_isdigit=yes],
    [gcal_cv_func_isdigit=no]))
if test "$gcal_cv_func_isdigit" = yes; then
  AC_DEFINE(HAVE_ISDIGIT)
fi
AC_MSG_RESULT($gcal_cv_func_isdigit)
dnl
AC_MSG_CHECKING(for isalpha)
AC_CACHE_VAL(gcal_cv_func_isalpha,
  AC_TRY_LINK([
#    if HAVE_CTYPE_H
#      include <ctype.h>
#    endif],
    [static int x; x = isalpha(x);],
    [gcal_cv_func_isalpha=yes],
    [gcal_cv_func_isalpha=no]))
if test "$gcal_cv_func_isalpha" = yes; then
  AC_DEFINE(HAVE_ISALPHA)
fi
AC_MSG_RESULT($gcal_cv_func_isalpha)
dnl
AC_MSG_CHECKING(for isalnum)
AC_CACHE_VAL(gcal_cv_func_isalnum,
  AC_TRY_LINK([
#    if HAVE_CTYPE_H
#      include <ctype.h>
#    endif],
    [static int x; x = isalnum(x);],
    [gcal_cv_func_isalnum=yes],
    [gcal_cv_func_isalnum=no]))
if test "$gcal_cv_func_isalnum" = yes; then
  AC_DEFINE(HAVE_ISALNUM)
fi
AC_MSG_RESULT($gcal_cv_func_isalnum)
dnl
AC_MSG_CHECKING(for isspace)
AC_CACHE_VAL(gcal_cv_func_isspace,
  AC_TRY_LINK([
#    if HAVE_CTYPE_H
#      include <ctype.h>
#    endif],
    [static int x; x = isspace(x);],
    [gcal_cv_func_isspace=yes],
    [gcal_cv_func_isspace=no]))
if test "$gcal_cv_func_isspace" = yes; then
  AC_DEFINE(HAVE_ISSPACE)
fi
AC_MSG_RESULT($gcal_cv_func_isspace)

dnl
dnl Checks for external variable `ospeed' in the ncurses/termcap/termlib library.
dnl
if test "$gcal_cv_use_term" = yes; then
  if test "$gcal_ttylibs_ok" = yes || test "$gcal_libtermlib_ok" = yes; then
    AC_MSG_RESULT()
    AC_CHECKING(for external variables)
    dnl
    AC_MSG_CHECKING(terminal library for ospeed)
    AC_CACHE_VAL(gcal_cv_var_ospeed_test_1,
      AC_TRY_LINK([
#        if HAVE_SYS_TYPES_H
#          include <sys/types.h>
#        endif
#        if HAVE_TERMIOS_H
#          include <termios.h>
#        endif
#        if HAVE_TERMCAP_H
#          include <termcap.h>
#        endif],
        [ospeed = 0;],
        [gcal_cv_var_ospeed_test_1=yes],
        [gcal_cv_var_ospeed_test_1=no]))
    if test "$gcal_cv_var_ospeed_test_1" = no; then
      AC_CACHE_VAL(gcal_cv_var_ospeed_test_2,
        AC_TRY_LINK(,
          [extern short ospeed; ospeed = 0;],
          [gcal_cv_var_ospeed_test_2=yes],
          [gcal_cv_var_ospeed_test_2=no]))
    fi
    if test "$gcal_cv_var_ospeed_test_1" = yes || test "$gcal_cv_var_ospeed_test_2" = yes; then
      AC_DEFINE(HAVE_OSPEED)
      if test "$gcal_cv_var_ospeed_test_2" = yes; then
        AC_DEFINE(MUST_DCL_OSPEED)
      fi
      AC_MSG_RESULT(yes)
    else
      AC_MSG_RESULT(no)
    fi
  fi
fi

dnl
dnl Checks for system services.
dnl
AC_MSG_RESULT()
AC_CHECKING(for system services)
dnl
AC_EXEEXT
AC_OBJEXT
AC_SYS_INTERPRETER
if test "$ac_cv_sys_interpreter" = yes; then
  AC_DEFINE(HAVE_SYS_INTERPRETER)
fi

dnl
dnl Checks for internationalization support
dnl
AC_MSG_RESULT()
AC_CHECKING(for internationalization support)
dnl
dnl Actually supported native languages.
dnl
ALL_LINGUAS="de fr nl pl ru sv"
dnl
AM_GNU_GETTEXT

dnl
dnl Check whether regcmp function is stored in -lintl, if so, re-add '-lintl'
dnl to $LIBS because previous AM_GNU_GETTEXT macro possibly has removed it.
dnl
if test "$need_sys_lintl_for_regcmp" = yes; then
  if test -z "`echo $LIBS | grep '\-lintl'`"; then
    LIBS="$LIBS -lintl"
  fi
fi

dnl
dnl Ending operations.
dnl
AC_SUBST(CFLAGS)dnl
dnl
changequote(<<, >>)dnl
dnl
dnl Transform the `$srcdir/doc/mks?sed.in' SED scripts while copying
dnl because some dumb SEDs cannot handle comments.
dnl
if test -s "$srcdir/doc/mks1sed.in"; then
  sed -e '/^#.*[^\\]$/d' -e '/^#$/d' $srcdir/doc/mks1sed.in > $srcdir/doc/mksamp-1.sed
fi
if test -s "$srcdir/doc/mks2sed.in"; then
  sed -e '/^#.*[^\\]$/d' -e '/^#$/d' $srcdir/doc/mks2sed.in > $srcdir/doc/mksamp-2.sed
fi
dnl
changequote([, ])dnl
dnl
AC_MSG_RESULT()
AC_OUTPUT([Makefile \
           install-inf \
           data/Makefile \
           doc/Makefile \
           doc/mksamp \
           intl/Makefile \
           misc/Makefile \
           misc/daily/daily \
           misc/ddiff/ddiff \
           misc/ddiff/ddiffdrv \
           misc/dst/dst \
           misc/gcalltx/gcalltx \
           misc/gcalltx/gcalltxp \
           misc/moon/moon \
           misc/mrms/mrms \
           misc/srss/srss \
           misc/wloc/wlocdrv \
           po/Makefile.in \
           src/Makefile],
          [if test -s install-inf; then
             mv install-inf install-info
             chmod u+x install-info
           fi
           if test -s doc/mksamp; then
             chmod u+x doc/mksamp
           fi
           if test -s misc/daily/daily; then
             chmod u+x misc/daily/daily
           fi
           if test -s misc/ddiff/ddiff; then
             chmod u+x misc/ddiff/ddiff
           fi
           if test -s misc/ddiff/ddiffdrv; then
             chmod u+x misc/ddiff/ddiffdrv
           fi
           if test -s misc/dst/dst; then
             chmod u+x misc/dst/dst
           fi
           if test -s misc/gcalltx/gcalltx; then
             chmod u+x misc/gcalltx/gcalltx
           fi
           if test -s misc/gcalltx/gcalltxp; then
             mv misc/gcalltx/gcalltxp misc/gcalltx/gcalltx.pl
             chmod u+x misc/gcalltx/gcalltx.pl
           fi
           if test -s misc/moon/moon; then
             chmod u+x misc/moon/moon
           fi
           if test -s misc/mrms/mrms; then
             chmod u+x misc/mrms/mrms
           fi
           if test -s misc/srss/srss; then
             chmod u+x misc/srss/srss
           fi
           if test -s misc/wloc/wlocdrv; then
             chmod u+x misc/wloc/wlocdrv
           fi])dnl

dnl
dnl Emit some final text.
dnl
AC_MSG_RESULT()
AC_MSG_RESULT(Bored? Fallen asleep??   All checks done!)
AC_MSG_RESULT()
AC_MSG_RESULT(Perhaps you might want to inspect the created)
AC_MSG_RESULT(Makefiles now for tuning some settings...)
AC_MSG_RESULT()
AC_MSG_RESULT(Otherwise type   make help   for a list of supported targets)
AC_MSG_RESULT()
