REQUIRED_KDE_VERSION=3.2.0
#MIN_CONFIG($REQUIRED_KDE_VERSION)
##AC_CONFIG_SRCDIR(src/main.cpp)
AM_INIT_AUTOMAKE(skim-scim-tables, 0.5.9)

REQUIRED_SCIM_VERSION=1.3.0

PKG_CHECK_MODULES(SCIM, [scim >= $REQUIRED_SCIM_VERSION],
			[HAS_SCIM=yes],
			[HAS_SCIM=no])

AC_SUBST(REQUIRED_KDE_VERSION)
AC_SUBST(REQUIRED_SCIM_VERSION)

if test "x$HAS_SCIM" != "xyes"; then
  AC_MSG_ERROR([SCIM library is not available or the version is too old!])
else
  SCIM_VERSION=`$PKG_CONFIG --modversion scim`
fi

##AM_INIT_AUTOMAKE(gettext, 0.12.1)
AM_GNU_GETTEXT([external])

###########################################################
##             Definiation of compile args.              ##
###########################################################
AC_ARG_ENABLE(debug,
              [  --enable-debug            Turn on debugging],
              scim_debug=yes,
              scim_debug=no)

if test "$scim_debug" = "yes"; then
  AC_DEFINE(ENABLE_DEBUG,1,[Define this to enable the debug facility in scim-panel-lib])
  CFLAGS="$CFLAGS -g"
  CXXFLAGS="$CXXFLAGS -g"
else
  AC_DEFINE(ENABLE_DEBUG,0)
fi

#AC_CHECK_HEAD
AC_C_BIGENDIAN
AC_CHECK_KDEMAXPATHLEN

##AC_OUTPUT
REQUIRED_SKIM_VERSION=1.3.0
dnl skim probably has been installed under prefix=$KDEDIR, so add it to search path of pkgconfig
kde_libsuffix=`kde-config --libsuffix`
test -z "$KDEDIR" && KDEDIR=`kde-config --prefix`
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$KDEDIR/lib${kde_libsuffix}/pkgconfig
PKG_CHECK_MODULES(SKIM, [skim >= $REQUIRED_SKIM_VERSION],
                        [HAS_SKIM=yes],
                        [HAS_SKIM=no])

if test "x$HAS_SKIM" = "xyes"; then

PKG_CHECK_MODULES(SCIM_KDEUTILS,[scim_kdeutils >= $REQUIRED_SKIM_VERSION],
                                [HAS_KDEUTILS=yes],
                                [HAS_KDEUTILS=no])

  if test "x$HAS_KDEUTILS" = "xyes"; then
        SKIM_VERSION=`$PKG_CONFIG --modversion skim`
        SCIM_PINYIN_ENABLE_SKIM_SUPPORT=1
        skim_prefix=`$PKG_CONFIG --variable=prefix skim`
        skim_libdir=`$PKG_CONFIG --variable=libdir skim`
        AC_SUBST(skim_prefix)
        AC_SUBST(skim_libdir)
	##we need to overwrite prefix with the same prefix of which skim was installed to
	prefix=$skim_prefix
	libdir=$skim_libdir
        ##this is to get rid of the last warning
        given_prefix=$skim_prefix
  fi
else
  AC_MSG_ERROR([skim library is not available or the version is too old!])
fi
