dnl Process this file with autoconf to produce a configure script.

AC_INIT(src/glabels.c)
AM_INIT_AUTOMAKE(glabels, 0.2.1)
AM_CONFIG_HEADER(config.h)

dnl Pick up the Gnome macros.
AM_ACLOCAL_INCLUDE(macros)

GNOME_INIT
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC

GNOME_COMPILE_WARNINGS
GNOME_X_CHECKS



dnl *******************************************************************
dnl * Check for required package and version (borrowed from Evolution)
dnl *******************************************************************
AC_DEFUN(GLABELS_CHECK_LIB, [
        dispname="$1"
        dispvers="$2"
        pkgname="$3"

        AC_MSG_CHECKING(for $dispname >= $dispvers)
        cmpvers=`echo $dispvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
        if gnome-config --libs $pkgname > /dev/null 2>&1; then
                pkgvers=`gnome-config --modversion $pkgname | sed -e 's/^[[^0-9]]*//'`
        else
                pkgvers=not
        fi
        AC_MSG_RESULT($pkgvers found)

        pkgvers=`echo $pkgvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
        if test "$pkgvers" -lt $cmpvers; then
        AC_MSG_ERROR([
""
"You need $dispname $dispvers or later to build gLabels"
"If you think you already have this installed, consult the README."])
        fi
])

dnl ****************************************
dnl * LIBXML
dnl ****************************************
GLABELS_CHECK_LIB(LIBXML, 1.8.10, xml)
GNOME_XML_CFLAGS=`gnome-config --cflags xml`
GNOME_XML_LIBS=`gnome-config --libs xml`
AC_SUBST(GNOME_XML_CFLAGS)
AC_SUBST(GNOME_XML_LIBS)

dnl ****************************************
dnl * GNOME-PRINT
dnl ****************************************
GLABELS_CHECK_LIB(GNOME-PRINT, 0.25, print)
GNOME_PRINT_CFLAGS=`gnome-config --cflags print`
GNOME_PRINT_LIBS=`gnome-config --libs print`
AC_SUBST(GNOME_PRINT_CFLAGS)
AC_SUBST(GNOME_PRINT_LIBS)

dnl ****************************************
dnl * GDK-PIXBUF
dnl ****************************************
GLABELS_CHECK_LIB(GDK-PIXBUF, 0.11.0, gdk_pixbuf)
GDK_PIXBUF_CFLAGS=`gnome-config --cflags gdk_pixbuf`
GDK_PIXBUF_LIBS=`gnome-config --libs gdk_pixbuf`
AC_SUBST(GDK_PIXBUF_CFLAGS)
AC_SUBST(GDK_PIXBUF_LIBS)

dnl ****************************************
dnl * GNOME-CANVAS-PIXBUF
dnl ****************************************
GLABELS_CHECK_LIB(GNOME-CANVAS-PIXBUF, 0.11.0, gnomecanvaspixbuf)
GNOME_CANVAS_PIXBUF_CFLAGS=`gnome-config --cflags gnomecanvaspixbuf`
GNOME_CANVAS_PIXBUF_LIBS=`gnome-config --libs gnomecanvaspixbuf`
AC_SUBST(GNOME_CANVAS_PIXBUF_CFLAGS)
AC_SUBST(GNOME_CANVAS_PIXBUF_LIBS)


dnl ****************************************
dnl * Supported languages
dnl ****************************************
dnl Add the languages which your application supports here.
ALL_LINGUAS="fr de"
AM_GNU_GETTEXT

dnl ****************************************
dnl * Set PACKAGE_LOCALE_DIR in config.h.
dnl ****************************************
if test "x${prefix}" = "xNONE"; then
  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale")
  AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/${DATADIRNAME}")
else
  AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${prefix}/${DATADIRNAME}/locale")
  AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/${DATADIRNAME}")
fi


dnl ****************************************
dnl * Configure barcode library
dnl ****************************************
AC_CONFIG_SUBDIRS(barcode-0.96)



dnl ****************************************
dnl * Disable use of hacktext canvas item
dnl ****************************************
AC_ARG_ENABLE(hacktext,
[--disable-hacktext         don't use hacktext canvas item for AA text],
enable_hacktext=$enableval,
enable_hacktext=yes)
if test "x$enable_hacktext" = "xyes"; then
  AC_DEFINE(HACKTEXT)
fi



dnl ****************************************
dnl * Makefiles
dnl ****************************************
AC_OUTPUT([
Makefile
macros/Makefile
src/Makefile
src/pixmaps/Makefile
intl/Makefile
po/Makefile.in
doc/Makefile
doc/C/Makefile
glabels.spec
])

