AC_PREREQ(2.52)
AC_INIT(liblivejournal,0.1.0,evan@livejournal.com)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION, [dist-bzip2])
AC_CONFIG_SRCDIR(livejournal/livejournal.h)
AM_CONFIG_HEADER(config.h)

AC_PROG_CC
AC_PROG_INSTALL
AC_DISABLE_SHARED
AC_PROG_LIBTOOL
AC_CACHE_SAVE

AC_CHECK_FUNCS(timegm)

MODULES="glib-2.0 gobject-2.0 libxml-2.0"
PKG_CHECK_MODULES(LIVEJOURNAL, $MODULES)
AC_SUBST(LIVEJOURNAL_CFLAGS)
AC_SUBST(LIVEJOURNAL_LIBS)

dnl *** tests.
AC_ARG_ENABLE(tests,
  AC_HELP_STRING([--enable-tests],
                 [enable tests]),
  , [enable_tests=no])
if test "$enable_tests" = "yes"; then
	AC_PATH_PROG(CURL_CONFIG, curl-config, no)
	if test "$CURL_CONFIG" = "no" ; then
		AC_MSG_ERROR([the curl-config script installed by libcurl could not be found.  libcurl is required for tests.])
	fi
	CURL_CFLAGS=`curl-config --cflags`
	CURL_LIBS=`curl-config --libs`
fi
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)
AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" = "yes")

dnl *** docs.
AC_ARG_WITH(html-dir, [  --with-html-dir=PATH path to installed docs ])
 
if test "x$with_html_dir" = "x" ; then
  HTML_DIR='${datadir}/gtk-doc/html'
else
  HTML_DIR=$with_html_dir
fi
 
AC_SUBST(HTML_DIR)
 
gtk_doc_min_version=1.0
AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version])
if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then
  AC_MSG_RESULT(yes)
  GTKDOC=true
else
  AC_MSG_RESULT(no)
  GTKDOC=false
fi
 
dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, AC_HELP_STRING([--enable-gtk-doc],[Use gtk-doc to build documentation [default=no]]), enable_gtk_doc="$enableval", enable_gtk_doc=auto)
 
if test x$enable_gtk_doc = xauto ; then
  if test x$GTKDOC = xtrue ; then
    enable_gtk_doc=yes
  else
    enable_gtk_doc=no
  fi
fi
 
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)

AC_CONFIG_FILES(livejournal/Makefile tests/Makefile docs/Makefile Makefile)
AC_OUTPUT

