Submitted By: Mario Fetka (mario-fetka at gmx dot at)
Date: 2007-10-05
Initial Package Version: 1.2.10
Origin: me
Upstream Status: unknown
Description: apr-util dont want to find mozldap60 this patch corrects it 
also check if ber_init is present in libldap60
 
--- apr-util-1.2.10.orig/build/apu-conf.m4	2007-06-07 11:38:53.000000000 +0200
+++ apr-util-1.2.10/build/apu-conf.m4	2007-10-05 22:37:42.000000000 +0200
@@ -198,6 +198,44 @@
 ])
 
 
+dnl 
+dnl Find a particular LBER library
+dnl
+AC_DEFUN([APU_FIND_LBERLIB], [
+  if test ${apu_has_lber} != "1"; then
+    lberlib=$1
+    extralib=$2
+    unset ac_cv_lib_${lberlib}_ber_init
+    unset ac_cv_lib_${lberlib}___ber_init
+    AC_CHECK_LIB(${lberlib}, ber_init, 
+      [
+        APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l${lberlib} ${extralib}])
+        APR_ADDTO(APRUTIL_LIBS,[-l${lberlib} ${extralib}])
+        apu_has_lber="1";
+      ], , ${extralib})
+  fi
+])
+
+
+dnl 
+dnl Find a particular LBER library
+dnl
+AC_DEFUN([APU_FIND_LBERLIB], [
+  if test ${apu_has_lber} != "1"; then
+    lberlib=$1
+    extralib=$2
+    unset ac_cv_lib_${lberlib}_ber_init
+    unset ac_cv_lib_${lberlib}___ber_init
+    AC_CHECK_LIB(${lberlib}, ber_init, 
+      [
+        APR_ADDTO(APRUTIL_EXPORT_LIBS,[-l${lberlib} ${extralib}])
+        APR_ADDTO(APRUTIL_LIBS,[-l${lberlib} ${extralib}])
+        apu_has_lber="1";
+      ], , ${extralib})
+  fi
+])
+
+
 dnl
 dnl APU_FIND_LDAP: figure out where LDAP is located
 dnl
@@ -206,6 +244,7 @@
 echo $ac_n "${nl}checking for ldap support..."
 
 apu_has_ldap="0";
+apu_has_lber="0";
 apu_has_ldapssl_client_init="0"
 apu_has_ldapssl_client_deinit="0"
 apu_has_ldapssl_add_trusted_cert="0"
@@ -221,6 +260,8 @@
 apu_has_ldap_mozilla="0"
 apu_has_ldap_other="0"
 
+AC_ARG_WITH(nss-lib,[  --with-nss-lib=path    path to Mozilla nss lib file])
+AC_ARG_WITH(nspr-lib,[  --with-nspr-lib=path    path to Moilla nspr lib file])
 AC_ARG_WITH(ldap-include,[  --with-ldap-include=path  path to ldap include files with trailing slash])
 AC_ARG_WITH(ldap-lib,[  --with-ldap-lib=path    path to ldap lib file])
 AC_ARG_WITH(ldap,[  --with-ldap=library     ldap library to use],
@@ -237,9 +278,20 @@
       APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_ldap_lib])
     fi
 
+    if test -n "$with_nss_lib"; then
+      LDFLAGS="$LDFLAGS -L$with_nss_lib"
+      APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_nss_lib])
+    fi
+
+    if test -n "$with_nspr_lib"; then
+      LDFLAGS="$LDFLAGS -L$with_nspr_lib"
+      APR_ADDTO(APRUTIL_LDFLAGS, [-L$with_nspr_lib])
+    fi
+
     LIBLDAP="$withval"
     if test "$LIBLDAP" = "yes"; then
 dnl The iPlanet C SDK 5.0 is as yet untested... 
+      APU_FIND_LDAPLIB("ldap60", "-lnspr4 -lplc4 -lplds4 -liutil60 -llber60 -lldif60 -lnss3 -lprldap60 -lssl3 -lssldap60")
       APU_FIND_LDAPLIB("ldap50", "-lnspr4 -lplc4 -lplds4 -liutil50 -llber50 -lldif50 -lnss3 -lprldap50 -lssl3 -lssldap50")
       APU_FIND_LDAPLIB("ldapssl41", "-lnspr3 -lplc3 -lplds3")
       APU_FIND_LDAPLIB("ldapssl40")
@@ -259,7 +311,11 @@
     fi
 
     test ${apu_has_ldap} != "1" && AC_MSG_ERROR(could not find an LDAP library)
-    AC_CHECK_LIB(lber, ber_init)
+    
+    echo $ac_n "${nl}checking for lber support..."
+
+    APU_FIND_LBERLIB("ldap60", "-lnspr4 -lplc4 -lplds4 -liutil60 -llber60 -lldif60 -lnss3 -lprldap60 -lssl3 -lssldap60")
+    APU_FIND_LBERLIB("lber")
 
     AC_CHECK_HEADERS(lber.h, lber_h=["#include <lber.h>"])
 
@@ -278,7 +334,20 @@
       AC_DEFINE([HAVE_LDAP_H], 1, [Defined if ldap.h is present])
     fi
 
-    AC_CHECK_HEADERS(ldap_ssl.h, ldap_ssl_h=["#include <ldap_ssl.h>"])
+    # Mozilla has a problem in <ldap_ssl.h> which prevents it from
+    # being included by itself.  Check for <ldap_ssl.h> manually,
+    # including ldap.h first.
+    AC_CACHE_CHECK([for ldap_ssl.h], [apr_cv_hdr_ldap_ssl_h],
+    [AC_TRY_CPP(
+    [#ifdef HAVE_LDAP_H
+    #include <ldap.h>
+    #endif
+    #include <ldap_ssl.h>
+    ], [apr_cv_hdr_ldap_ssl_h=yes], [apr_cv_hdr_ldap_ssl_h=no])])
+    if test "$apr_cv_hdr_ldap_ssl_h" = "yes"; then
+      ldap_ssl_h=["#include <ldap_ssl.h>"]
+      AC_DEFINE([HAVE_LDAP_SSL_H], 1, [Defined if ldap_ssl.h is present])
+    fi
 
     if test "$apr_cv_hdr_ldap_h" = "yes"; then
       AC_CACHE_CHECK([for LDAP toolkit],