AC_INIT(acinclude.m4) dnl a source file from your sub dir

dnl This is so we can use kde-common
AC_CONFIG_AUX_DIR(admin)

dnl This ksh/zsh feature conflicts with `cd blah ; pwd`
unset CDPATH

dnl Checking host/target/build systems, for make, install etc.
AC_CANONICAL_SYSTEM
dnl Perform program name transformation
AC_ARG_PROGRAM

dnl Automake doc recommends to do this only here. (Janos)
AM_INIT_AUTOMAKE(bibletime, 1.6.6.0) dnl searches for some needed programs

KDE_SET_PREFIX
KDE_USE_QT(3.0)

dnl generate the config header
AC_CONFIG_HEADER([config.h]) dnl at the distribution this done

dnl Checks for programs.
AC_CHECK_COMPILERS
CXXFLAGS="$CXXFLAGS $USE_EXCEPTIONS"
AC_ENABLE_SHARED(no)
AC_ENABLE_STATIC(yes)
KDE_PROG_LIBTOOL

AM_MAINTAINER_MODE

dnl for NLS support. Call them in this order!
dnl WITH_NLS is for the po files
AM_KDE_WITH_NLS

AC_PATH_KDE

dnl in this space add everything you want to check for;
dnl examples are specific headers, libraries, etc.
dnl everything to compile and run a KDE program is already checked

CPPFLAGS="$CPPFLAGS -DQT_NO_ASCII_CAST -DQT_NO_COMPAT -DQT_CLEAN_NAMESPACE -Wall -I\$(top_srcdir)/ -I\$(top_srcdir)/bibletime -I\$(top_builddir)/bibletime"
AC_CHECK_STATIC_LINKING(ac_use_static)
AC_CHECK_SWORD(1.5.9, [$ac_use_static])
AC_CHECK_CLUCENE([$ac_use_static])

AC_ARG_ENABLE(howto,
        AC_HELP_STRING([--enable-howto],
	[install Bible Study Howto (default=yes)]),
	,
	enable_howto=yes
)
HOWTODIR=""
if test "x$enable_howto" = xyes; then
	HOWTODIR="howto"
fi
AC_SUBST(HOWTODIR)

dnl Check for the used distribution
AC_CHECK_DISTRIBUTION

dnl Check bibletime API version
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
cxx_flags_safe="$CXXFLAGS"
cflags_safe="$CFLAGS"
CXXFLAGS="$CXXFLAGS -I$ac_cv_sword_incdir"
CFLAGS="$CFLAGS -I$ac_cv_sword_incdir"
AC_MSG_CHECKING([if Sword provides the old API])
AC_TRY_COMPILE([#include <versekey.h>
static sword::VerseKey staticKey;
sword::sbook current_book;
],[current_book = staticKey.books[1][1];],
AC_MSG_RESULT(yes),
[AC_MSG_RESULT(no)
AC_DEFINE(SWORD_MULTIVERSE,1,[no])])
CXXFLAGS="$cxx_flags_safe"
CFLAGS="$cflags_safe"
AC_LANG_RESTORE

dnl add here all your Makefiles. They are created by configure

AC_CONFIG_FILES([ README ])
AC_CONFIG_FILES([ INSTALL ])
AC_CONFIG_FILES([ bibletime.lsm ])
AC_CONFIG_FILES([ bibletime.spec ])
AC_CONFIG_FILES([ bibletime.desktop ])
