dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/hotkeys.c)
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(hotkeys, 0.5.7.1)
AM_MAINTAINER_MODE

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_ARG_WITH(xml-prefix,
            AC_HELP_STRING([--with-xml-prefix=PFX],
                           [Prefix where GNOME XML library is installed]),
            xml_config_prefix="$withval", xml_config_prefix="")

AC_ARG_ENABLE(xmltest,
              AC_HELP_STRING([--disable-xmltest],
                             [Do not try to compile and run a test XML program]),
              , enable_xmltest=yes)

AC_ARG_WITH(db3-inc,
            AC_HELP_STRING([--with-db3-inc=DIR],
                           [Set the include directory of Berkeley DB3]),
            db3_incdir="$withval", db3_incdir="")
 
AC_ARG_WITH(db3-lib,
            AC_HELP_STRING([--with-db3-lib=DIR],
                           [Set the library directory of Berkeley DB3]),
            db3_libdir="$withval", db3_libdir="")

AC_ARG_ENABLE(db3test,
              AC_HELP_STRING([--disable-db3test],
                             [Do not try to test for libdb3, assume it's present]),
              , enable_db3test=yes)

AC_ARG_WITH(gtk,
            AC_HELP_STRING([--with-gtk],
                           [Use GTK interface (incl. splash screen, default is NO)]),
            use_gtk=yes, )

AC_ARG_WITH(xosd,
            AC_HELP_STRING([--with-xosd], [Use XOSD library (default is NO)]),
            use_xosd=yes, )

dnl --- Not use any more, as libxosd-dev provides its own m4
dnl AC_ARG_WITH(xosd-inc,
dnl     [  --with-xosd-inc=DIR     Set the include directory of XOSD],
dnl     xosd_incdir="$withval", xosd_incdir="")
dnl 
dnl AC_ARG_WITH(xosd-lib,
dnl     [  --with-xosd-lib=DIR     Set the library directory of XOSD],
dnl     xosd_libdir="$withval", xosd_libdir="")

dnl-----------------------------------------------------------------------
dnl Checks for X
dnl-----------------------------------------------------------------------
AC_PATH_XTRA
if test "x$no_x" = "xyes"
then
    AC_MSG_ERROR("You must have X installed")
else
    X_LIBS="$X_LIBS -lX11 -lXmu"
fi

dnl-----------------------------------------------------------------------
dnl Checks for LIBXML2
dnl-----------------------------------------------------------------------
if test "x$enable_xmltest" = "xyes"; then
    AM_PATH_XML2(2.2.8)
else
#    AC_MSG_NOTICE([Skipping libxml2 test])
echo
fi

dnl-----------------------------------------------------------------------
dnl Checks for LIBPTHREAD
dnl-----------------------------------------------------------------------
AC_CHECK_LIB(pthread, pthread_create)

dnl Checks for libraries.
dnl Replace `main' with a function in -lX11:
dnl AC_CHECK_LIB(X11, XNextEvent)
dnl Replace `main' with a function in -lxkbfile:
dnl AC_CHECK_LIB(xkbfile, main)
dnl Replace `main' with a function in -lxml:
dnl Replace `main' with a function in -lz:
dnl AC_CHECK_LIB(z, main)

dnl AM_PATH_GTK()
dnl AM_PATH_GLIB(1.2.0, ,[AC_MSG_ERROR(Missing gthread module in GLib!)], gthread)
dnl AC_SUBST(GLIB_LIBS)
dnl AC_SUBST(GLIB_CFLAGS)

dnl-----------------------------------------------------------------------
dnl Checks for DB3
dnl-----------------------------------------------------------------------
if test "x$enable_db3test" = "xyes"; then
    AM_CHECK_DB3
else
#    AC_MSG_NOTICE([Skipping libdb3 test])
echo
fi

dnl-----------------------------------------------------------------------
dnl Checks for GTK+
dnl-----------------------------------------------------------------------
if test "x$use_gtk" = "xyes"; then
    AM_PATH_GTK_2_0(2.0.0,
                    AC_DEFINE(HAVE_GTK,1,[Define if you have the gtk+ libraries.]))
fi

dnl-----------------------------------------------------------------------
dnl Checks for XOSD
dnl-----------------------------------------------------------------------
if test "x$use_xosd" = "xyes"; then
    AM_PATH_LIBXOSD(AC_DEFINE(HAVE_LIBXOSD,1,[Define if you have the xosd library (-lxosd).]))
fi

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_MAJOR
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h string.h strings.h syslog.h sys/file.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_VPRINTF
AC_FUNC_CLOSEDIR_VOID
AC_CHECK_FUNCS(select strdup strerror getopt_long)

AC_OUTPUT(Makefile src/Makefile def/Makefile)
