dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/ppd.c)
AM_INIT_AUTOMAKE(libppd,0.10)
AC_LANG_C
AM_CONFIG_HEADER(config.h)

# -Wshadow doesn't work with glib
WARNS=""
AC_ARG_ENABLE(debug, [  --enable-debug turn on debugging (assumes gcc/gdb) [default=no]],WARNS="-W -Wall -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -O0 -ggdb3")
dnl AC_DEFINE(NDEBUG,[],[ debug stuff in libraries ]))
AC_SUBST(WARNS)

dnl Checks for programs.
AC_PROG_CC
AM_PROG_LIBTOOL

dnl *******+   choose glib type

dnl this was the old system
dnl AM_PATH_GLIB(1.2.0,[],[
dnl   AC_MSG_ERROR(You must have glib installed to compile libppd)
dnl ])

AC_ARG_WITH(glib,          [  --with-glib=1,2      use GLIB1 or 2 ])

if ! test "x$with_glib" = "x1" -o   "x$with_glib" = "x2" ; then
  AC_ERROR([--with-glib=$with_glib  is wrong; provide argument, use  =1 or =2])
fi

if test "x$with_glib" = "x2"   ; then
  pkg_modules="glib-2.0"
else
  pkg_modules="glib >= 1.2.0"
fi

PKG_CHECK_MODULES(GLIB, [$pkg_modules], :  ,
  [if test  "x$with_gtk" = "x2" ; then
   AC_ERROR([ glib is not available ])
   exit 1
  fi;])

AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)




dnl ****** Checks for libraries.
dnl AC_CHECK_LIB(efence,malloc)

dnl Checks for header files.
dnl AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
dnl AC_C_CONST

dnl Checks for library functions.
AC_CHECK_FUNCS(strdup)
AC_CHECK_FUNCS(strcasecmp)
AC_CHECK_FUNCS(strncasecmp)
AC_CHECK_FUNCS(snprintf)
AC_CHECK_FUNCS(vsnprintf)

dnl loads in the magic pixie dust for the m4 files
TESTSCRIPTS=`cd src/tests && echo *.m4 | sed "s/m4/sh/g"`
AC_SUBST(TESTSCRIPTS)

AC_OUTPUT(Makefile src/Makefile src/tests/Makefile doc/Makefile libppd.spec)

