#MIN_CONFIG

#AM_INIT_AUTOMAKE(kuickshow,0.8.2)
 
# my own additions to KDE's version
#
# checking for Imlib...

AC_DEFUN([KDE_FIND_IMLIB_CONFIG],
   [AC_MSG_CHECKING([for imlib-config])

imlib_config_given=NO
ac_imlib_config=""

AC_ARG_WITH(imlib-config,
AC_HELP_STRING([--with-imlib-config=DIR],[directory where "imlib-config" is located]),
[  ac_imlib_config="$withval/imlib-config"
   imlib_config_given=yes
])

if test "$imlib_config_given" = "yes"; then
  if test ! -r $ac_imlib_config; then
    AC_MSG_RESULT(wrong file specified)
    ac_imlib_config=""
  else
    AC_MSG_RESULT($ac_imlib_config)
    LIB_IMLIB=`$ac_imlib_config --libs`
    AC_SUBST(LIB_IMLIB)
  fi
else
  ac_imlib_config=`which imlib-config 2>/dev/null`
  if test -z "$ac_imlib_config"; then
    AC_MSG_RESULT(no)
  else
    dummy=`echo "$ac_imlib_config" | grep '/imlib-config'`
    if test -z "$dummy"; then
      AC_MSG_RESULT(no)
      ac_imlib_config=""
    else
      LIB_IMLIB=`$ac_imlib_config --libs`
      IMLIB_CFLAGS=`$ac_imlib_config --cflags`
      imlib_config=`echo "$LIB_IMLIB" | grep lImlib`
      if test -z "$imlib_config"; then
        AC_MSG_RESULT(no)
        ac_imlib_config=""
      else
        AC_SUBST(LIB_IMLIB)
        AC_SUBST(IMLIB_CFLAGS)
        AC_MSG_RESULT($ac_imlib_config)
      fi
    fi
  fi
fi

])

dnl #### now some kuickshow stuff ###
dnl Check if Imlib is installed properly
KDE_PKG_CHECK_MODULES(IMLIB, imlib >= 1.9.10, 
  LIB_IMLIB=$IMLIB_LIBS
  AC_SUBST(LIB_IMLIB)
,
KDE_FIND_IMLIB_CONFIG
)
 
if test -z "$LIB_IMLIB"; then
dnl  AC_MSG_ERROR([You need to install Imlib 1.x, e.g. http://freshmeat.net/redir/imlib/4385/url_tgz/imlib-1.9.10.tar.gz if your distributor doesn't have a package])
  DO_NOT_COMPILE="$DO_NOT_COMPILE kuickshow"
fi
