# Process this file with autoconf to produce a configure script.
AC_INIT([ldapdiff])
AM_INIT_AUTOMAKE([ldapdiff],[0.9.2],[Thomas.Reith@rhoen.de])
AC_CONFIG_SRCDIR([ldapdiff.c])

# Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S

# Checks for libraries.
AC_CHECK_LIB(lber, main)
AC_CHECK_LIB(ldap, main)
AC_CHECK_LIB(nsl, main)
AC_CHECK_LIB(resolv, main)
AC_CHECK_LIB(socket, main)
AC_CHECK_LIB(dl, main)

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([getopt.h errno.h stdlib.h string.h time.h syslog.h types.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([memset strchr strdup strerror])

AC_ARG_WITH(ldap-dir, [  --with-ldap-dir=DIR     base directory of ldap SDK])
AC_ARG_WITH(iconv-dir,[  --with-iconv-dir=DIR    base directory of libiconv])

if test -n "$with_ldap_dir"; then
  CPPFLAGS="$CPPFLAGS -I$with_ldap_dir/include"
  LDFLAGS="$LDFLAGS -L$with_ldap_dir/lib"
  LIBS="-lldap -llber $LIBS"
fi

if test -n "$with_iconv_dir"; then
  CPPFLAGS="$CPPFLAGS -I$with_iconv_dir/include"
  LDFLAGS="$LDFLAGS -L$with_iconv_dir/lib"
  LIBS="-liconv $LIBS"
fi

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
