
# $Id: configure.in,v 1.2 1998/07/13 02:15:58 leonard Exp $

AC_INIT(LDAPObject.c)

#
# Options
#

#-- Listen to the user if they know where the LDAP libraries are installed
AC_ARG_WITH(ldap, 
        [  --with-ldap=DIR               Where ldap library is installed; or], 
[
        with_ldap_lib=$with_ldap/lib
        with_ldap_inc=$with_ldap/include
])
AC_ARG_WITH(ldap-lib, 
        [    --with-ldap-lib=DIR/lib     Where libldap.a can be found])
AC_ARG_WITH(ldap-inc,
        [    --with-ldap-inc=DIR/include Where ldap.h can be found])
AC_ARG_WITH(python,
	[  --with-python=PROGRAM         Location of python interpreter])


#
# Programs
#

AC_PROG_CC
#-- look for python
if test -n "$with_python"; then ac_cv_prog_python="$with_python"; fi
AC_CACHE_VAL(ac_cv_prog_python, [AC_PATH_PROG(ac_cv_prog_python,python)])
AC_CACHE_CHECK(python version, ac_cv_ver_python, [
 ac_cv_ver_python=`$ac_cv_prog_python -c 'import sys;print sys.version[[:3]]'`])
AC_CACHE_CHECK(python install prefix, ac_cv_path_python, [
 ac_cv_path_python=`$ac_cv_prog_python -c 'import sys;print sys.prefix'`])

#
# Libraries
#

#-- check for the networking libraries (derived from PLATFORMLIBS)
for fn in socket gethostbyname inet_addr inet_ntoa connect; do
    AC_CHECK_FUNCS($fn)
    if eval test \$ac_cv_func_$fn = no; then
	for lib in  nsl net socket V3 nsl_s gen; do
	  AC_CHECK_LIB($lib, $fn, [LIBS="$LIBS -l$lib"; break])
	done
    fi
done

#-- function gets called to suggest how to remedy UM ldap errors
no_ldap () {
  AC_MSG_ERROR([$1
  Please specify the location of the LDAP library using the --with-ldap=PATH, 
  --with-ldap-lib=PATH/lib, or --with-ldap-inc=PATH/include options. 

  You can download the LDAP library software from
  ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z])
}

if test -n "$with_ldap_lib"; then
  AC_MSG_RESULT([Using LDAP libraries from $with_ldap_lib])
  LDFLAGS="-L$with_ldap_lib $LDFLAGS"
fi
if test -n "$with_ldap_inc"; then
  AC_MSG_RESULT([Using LDAP includes from $with_ldap_inc])
  CPPFLAGS="-I$with_ldap_inc $CPPFLAGS"
fi
AC_CHECK_LIB(umich_lber, ber_free,,  [no_ldap "Couldn't find libumich_lber.a"])
AC_CHECK_LIB(umich_ldap, ldap_bind,, [no_ldap "Couldn't find libumich_ldap.a"])
AC_CHECK_HEADER(ldap.h,, [no_ldap "Couldn't find ldap.h"])

#
# Makefiles
#

#-- grab the Makefile.pre.in from python's config directory if it is there,
#   otherwise we have to use the one we copied from 1.4's source.
AC_MSG_CHECKING(python makefile)
pymf="$ac_cv_path_python/lib/python$ac_cv_ver_python/config/Makefile.pre.in"
if test -f "$pymf"; then
	: we will use that one
else
	pymf="./Makefile.python-1.4"
fi
AC_MSG_RESULT($pymf)
cp "$pymf" Makefile.pre.in
AC_OUTPUT_COMMANDS([echo bootstrapping makefile; make -f Makefile.pre.in boot])

AC_OUTPUT(Setup.in)

