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

dnl
dnl Starting operations.
dnl
AC_INIT(src/gcal_def.h)dnl
AC_CONFIG_HEADER(config.h:config.hin)dnl
AC_PREREQ(2.9)dnl
AC_REVISION($Id: configure.in 2.12 1996/06/26 02:12:00 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 Actually supported native languages.
dnl
ALL_LINGUAS="de"

dnl
dnl Emit some text.
dnl
AC_MSG_RESULT()
AC_MSG_RESULT(this is the automatic configuration step of $PACKAGE-$VERSION)
AC_MSG_RESULT()
AC_MSG_RESULT(please wait...)
AC_MSG_RESULT()

dnl
dnl Checks for Gcal specific package options.
dnl
AC_CHECKING(for $PACKAGE specific package options)
dnl
AC_MSG_CHECKING(for language used in documentation files)
AC_ARG_ENABLE(ger,
  [  --enable-ger            create and install German documentation files],
  doclang=German,
  doclang=English)
AC_MSG_RESULT($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 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 warnings feature is required)
AC_ARG_ENABLE(rc,
  [  --disable-rc            do not use fixed date warning 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 libtermcap/libtermlib],
  gcal_cv_use_term=$enableval,
  gcal_cv_use_term=yes)
AC_MSG_RESULT($gcal_cv_use_term)

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 makeinfo.
dnl
AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo)
if test -z "$ac_cv_prog_MAKEINFO"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic recreation of text documentation/info files!)
  AC_MSG_WARN(Makefile targets *txt* and *info* will never be executed.)
  AC_MSG_RESULT()
else
  AC_MSG_CHECKING(for $ac_cv_prog_MAKEINFO version)
  changequote(<<, >>)dnl
  AC_CACHE_VAL(gcal_cv_prog_MAKEINFO_VERSION,
    gcal_cv_prog_MAKEINFO_VERSION=`$ac_cv_prog_MAKEINFO --version 2>&1 | sed -e 's/[^0-9]//g'`)
  changequote([, ])dnl
  gcal_makeinfo_error=no
  if test -n "$gcal_cv_prog_MAKEINFO_VERSION"; then
    AC_MSG_RESULT($gcal_cv_prog_MAKEINFO_VERSION)
    if test "$gcal_cv_prog_MAKEINFO_VERSION" -lt "120"; then
      gcal_makeinfo_error=yes
    fi
  else
    gcal_makeinfo_error=yes
    AC_MSG_RESULT(unknown)
  fi
  if test "$gcal_makeinfo_error" = "yes"; then
    gcal_cv_prog_MAKEINFO_VERSION=
    AC_MSG_RESULT()
    AC_MSG_WARN(no automatic recreation of text documentation files!)
    AC_MSG_WARN(the makeinfo program is out of date.)
    AC_MSG_WARN(Makefile target *txt* will never be executed.)
    AC_MSG_RESULT()
  fi
  MAKEINFOVERSION=$gcal_cv_prog_MAKEINFO_VERSION
  AC_SUBST(MAKEINFOVERSION)dnl
fi
dnl
dnl Checks for texi2dvi.
dnl
AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi)
if test -z "$ac_cv_prog_TEXI2DVI"; then
  AC_MSG_RESULT()
  AC_MSG_WARN(no automatic creation of dvi files!)
  AC_MSG_WARN(Makefile target *dvi* will never be executed.)
  AC_MSG_RESULT()
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/interpeters (perl, awk).
dnl
AC_CHECK_PROG(PERL, perl, perl)
if test -z "$ac_cv_prog_PERL"; then
  AC_PROG_AWK
  if test -z "$ac_cv_prog_AWK"; then
    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_RESULT()
    fi
  fi
fi
dnl
dnl Checks for 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")
dnl
dnl Checks for install program/script.
dnl
fp_PROG_INSTALL
AC_PROG_LN_S

dnl
dnl Checks for C compiler.
dnl
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 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
if test "$gcal_cv_use_term" = "yes"; then
  gcal_termcap_ok=no
  gcal_termlib_ok=no
  TERMLIBS=
  AC_CHECK_LIB(termcap,
    tgetent,
    [AC_DEFINE(HAVE_LIBTERMCAP)
     TERMLIBS="-ltermcap"])
  AC_CHECK_LIB(termlib,
    tgetent,
    [have_termlib=yes],
    [have_termlib=no])
  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 $TERMLIBS"
  AC_TRY_LINK(,
    [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
    [gcal_termcap_ok=yes])
  if test "$gcal_termcap_ok" = "yes"; then
    AC_MSG_RESULT(using $TERMLIBS)
  else
    TERMLIBS="-ltermlib"
    LIBS="$SAVE_LIBS"
    LIBS="$LIBS $TERMLIBS"
    if test "$have_termlib" = "yes"; then
      AC_TRY_LINK(,
        [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
        [gcal_termlib_ok=yes])
      if test "$gcal_termlib_ok" = "yes"; then
        AC_DEFINE(HAVE_LIBTERMLIB)
        AC_MSG_RESULT(using $TERMLIBS)
      fi
    fi
  fi
  if test "$gcal_termcap_ok" = "no" && test "$gcal_termlib_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)
    AC_MSG_WARN(libtermcap.a and/or libtermlib.a are installed.)
    AC_MSG_RESULT()
  fi
fi #Using termlibs

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 fcntl.h termio.h termios.h sgtty.h)
if test "$gcal_cv_use_term" = "yes"; then
  if test "$gcal_termcap_ok" = "yes" || test "$gcal_termlib_ok" = "yes"; then
    AC_CHECK_HEADERS(termcap.h)
  fi
fi #Using termlibs
AC_CHECK_HEADERS(sys/ioctl.h sys/stream.h sys/ptem.h sys/stat.h sys/types.h sys/time.h)
AC_HEADER_SYS_WAIT

dnl
dnl Checks for typedefs.
dnl
AC_MSG_RESULT()
AC_CHECKING(for typedefs)
dnl
AC_TYPE_PID_T
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 structures.
dnl
AC_MSG_RESULT()
AC_CHECKING(for structures)
dnl
AC_HEADER_TIME

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
AC_CHECK_FUNCS([dup dup2 strtol strstr strchr strrchr])
dnl
dnl Some systems have termios.h but not the corresponding functions.
dnl
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
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 termcap/termlib library.
dnl
AC_MSG_RESULT()
AC_CHECKING(for external variables)
dnl
if test "$gcal_cv_use_term" = "yes"; then
  if test "$gcal_termcap_ok" = "yes" || test "$gcal_termlib_ok" = "yes"; then
    if test "$gcal_termcap_ok" = "yes"; then
      AC_MSG_CHECKING(termcap for ospeed)
    else
      AC_MSG_CHECKING(termlib for ospeed)
    fi
    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 #Using termlibs

dnl
dnl Checks for system services.
dnl
AC_MSG_RESULT()
AC_CHECKING(for system services)
dnl
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)
ud_GNU_GETTEXT

dnl
dnl Checks for obtaining some libintl.h header files
dnl
if test "$nls_cv_use_nls" = "yes"; then
  AC_MSG_RESULT()
  AC_CHECKING(for obtaining some libintl.h header files)
  AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
fi # NLS enabled

dnl
dnl Ending operations.
dnl
AC_MSG_RESULT()
AC_SUBST(CFLAGS)dnl
AC_OUTPUT([Makefile install-inf data/Makefile doc/Makefile \
           intl/Makefile misc/Makefile po/Makefile.in src/Makefile],
          [if test -s install-inf
           then
             mv install-inf install-info
             chmod u+x install-info
           fi
           sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
           echo timestamp > stamp-h])dnl

dnl
dnl Emit some 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()
