AC_INIT(src/main.c)
AC_CONFIG_HEADER(config.h)

AM_INIT_AUTOMAKE(geeqie, 1.0alpha1)

AM_MAINTAINER_MODE

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CXX
AC_STDC_HEADERS
AC_ARG_PROGRAM

dnl reasonable guesses for where stuff is installed
if test "x$prefix" = "xNONE"; then
  prefix="/usr/local"
else
  prefix=$prefix
fi

AM_PATH_GTK_2_0(2.4.0,,AC_MSG_ERROR(GTK+ >= 2.4.0 not installed.))
AC_PATH_PROGS(GDK_PIXBUF_CSOURCE, "gdk-pixbuf-csource")

AC_ARG_WITH(readmedir, [  --with-readmedir=DIR    install path for readme files],
            readmedir=$withval, readmedir="$prefix/share/doc/geeqie-$VERSION")
AC_ARG_WITH(htmldir, [  --with-htmldir=DIR      install path for html files],
            htmldir=$withval, htmldir="$readmedir/html")

AC_DEFINE_UNQUOTED(GQ_HELPDIR, "$readmedir", [Location of documentation files])
AC_DEFINE_UNQUOTED(GQ_HTMLDIR, "$htmldir", [Location of html documentation])

AC_SUBST(readmedir)
AC_SUBST(htmldir)

dnl Check for LIRC client support
AC_ARG_ENABLE(lirc,  AC_HELP_STRING([--disable-lirc], [do not use lirc support (auto)]),
[
if test x"${enableval}" = x"yes" -a x"$GCC" = x"yes"; then
  AC_MSG_RESULT(yes)
  lirc=yes
else
  AC_MSG_RESULT(no)
  lirc=no
fi], AC_MSG_RESULT(no))
		

AC_ARG_WITH(lirc-prefix,
[  --with-lirc-prefix=PATH Prefix where LIRC is installed],
[
for dir in `echo "$withval" | tr : ' '`; do
  if test -d $dir/lib; then CPPFLAGS="$CPPFLAGS -L$dir/lib"; fi
  if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
  done
])

if test x$lirc != x"no" ; then
  AC_CHECK_HEADER(lirc/lirc_client.h,
    [AC_CHECK_LIB(lirc_client,lirc_init,[LIBS=-llirc_client $LIBS;AC_DEFINE([HAVE_LIRC],[],[Define to 1 if LIRC must be used])],,)],)
fi

dnl checks for functions
AC_CHECK_FUNCS(strverscmp access fsync fflush)

dnl check for little cms (lcms, this test pulled from gimp)
AC_ARG_WITH(lcms, [  --without-lcms          build without lcms support])

have_lcms=no
if test "x$with_lcms" != "xno"; then
  AC_CHECK_LIB(lcms, cmsCreate_sRGBProfile, [
    AC_CHECK_HEADER(lcms.h,
      have_lcms=yes, [
      AC_CHECK_HEADER(lcms/lcms.h,
        have_lcms=yes
        AC_DEFINE(HAVE_LCMS_LCMS_H, 1,
          [Define to 1 if the lcms header must be included as lcms/lcms.h]))
      ])
  ])
  if test "$have_lcms" = "yes"; then
    LCMS_LIBS="-llcms"
    AC_DEFINE(HAVE_LCMS, 1, [define to enable use of color profiles with lcms])
  else
    have_lcms="no (lcms not found or unusable)"
  fi
else
  have_lcms="no (lcms support disabled)"
fi
AC_SUBST(LCMS_LIBS)
AM_CONDITIONAL(HAVE_LCMS, test "$have_lcms" = "yes")

AC_ARG_WITH(exiv2, [  --without-exiv2          build without exiv2 support])

have_exiv2=no

if test "x$with_exiv2" != "xno"; then
  PKG_CHECK_MODULES(EXIV2, exiv2 >= 0.11,
    [ have_exiv2=yes
      AC_DEFINE(HAVE_EXIV2, 1, have exiv2) ],
    [ AC_MSG_RESULT($EXIV2_PKG_ERRORS) ] )
fi


ALL_LINGUAS="ar be bg ca cs da de eo es et eu fi fr hu id it ja ko nl nb pl pt_BR ro ru sk sl sv th tr uk vi zh_CN.GB2312 zh_TW"
GETTEXT_PACKAGE=$PACKAGE
AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
AM_GLIB_DEFINE_LOCALEDIR(GQ_LOCALEDIR)

#Always use -Wall with gcc
if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
	CFLAGS="$CFLAGS -Wall"
	CPPFLAGS="$CPPFLAGS -Wall"
fi

AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)

AC_OUTPUT([
Makefile
src/Makefile
src/icons/Makefile
src/icons/svg/Makefile
po/Makefile.in
doc/Makefile
geeqie.spec
])

