# Process this file with autoconf to produce a configure script.
AC_INIT(glogger.c)
AC_CONFIG_SRCDIR(glogger.c)

top_objdir=`pwd`
AC_SUBST(top_objdir)

AC_PROG_CC
AC_PROG_INSTALL

# Checks for libraries.
AC_CHECK_LIB(m, main,,
[exit 1
])
AC_CHECK_LIB(crypto, main,,
[exit 1
])

# Checks for header files.
AC_CHECK_HEADER([net-snmp/net-snmp-config.h],
[useucd=
 AC_CHECK_LIB(netsnmp, main)
],
[
  AC_CHECK_HEADER([ucd-snmp/ucd-snmp-config.h],
  [useucd=-DUSE_UCDHEADER
   AC_CHECK_LIB(snmp, main)
  ],
  [echo "Please install the net-snmp or ucd-snmp package."
   exit 1
  ])
])
AC_SUBST(useucd)

AC_ARG_WITH(confdir,
[  --with-confdir=DIR  glogger configuration file directory (sysconfdir/glogger)],
[confdir=${withval}
],
[confdir=${sysconfdir}/glogger
])
AC_SUBST(confdir)

AC_ARG_ENABLE(printtime,
[  --enable-printtime       use -DPRINTTIME],
[printtime=-DPRINTTIME
],
[printtime=
])
AC_SUBST(printtime)

AC_ARG_ENABLE(hook_snmp_free_pdu,
[  --enable-hook_snmp_free_pdu],
[hook_snmp_free_pdu=-DHOOK_snmp_free_pdu
],
[hook_snmp_free_pdu=
])
AC_SUBST(hook_snmp_free_pdu)

AC_ARG_WITH(dlopen,
[  --with-dlopen=<libsnmp.so path>   when using --enable-hook_snmp_free_pdu],
[snmpdlopen="-DUSE_DLOPEN=\\\"${withval}\\\""
 AC_CHECK_LIB(dl, dlopen)
],
[snmpdlopen=
])
AC_SUBST(snmpdlopen)

AC_CONFIG_FILES(Makefile config.mk glogd docbook/ja/Makefile)
AC_OUTPUT
