On 6/7/21 10:47 pm, Tom Lane wrote:
> Looking at the Autoconf docs, what AC_SEARCH_LIBS is specified to do is
> "Prepend `-lLIBRARY' to `LIBS' for the first library found to contain
> FUNCTION". So I'd suggest
>
> * Save contents of LIBS and set it to empty
> * Run AC_SEARCH_LIBS
> * LDAP_LIBS_FE="$LIBS $EXTRA_LDAP_LIBS"
> * Restore LIBS
>
> I think we have some instances of that pattern already.
Thanks, Tom, that turned out to only require one additional line, since
$LIBS is already being saved and restored around that block:
diff --git a/configure.in b/configure.in
index 14a6be6..842d61b 100644
--- a/configure.in
+++ b/configure.in
@@ -1241,17 +1241,20 @@ fi
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
- AC_CHECK_LIB(ldap, ldap_bind, [],
- [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
- [$EXTRA_LDAP_LIBS])
- LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
if test "$enable_thread_safety" = yes; then
# on some platforms ldap_r fails to link without PTHREAD_LIBS
- AC_CHECK_LIB(ldap_r, ldap_simple_bind, [],
- [AC_MSG_ERROR([library 'ldap_r' is required for LDAP])],
+ # OpenLDAP 2.5 merged ldap_r with ldap
+ LIBS=""
+ AC_SEARCH_LIBS(ldap_simple_bind, [ldap_r ldap], [],
+ [AC_MSG_ERROR([not found in any LDAP library])],
[$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
- LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
+ LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
+ LDAP_LIBS_FE="$LIBS $EXTRA_LDAP_LIBS"
else
+ AC_CHECK_LIB(ldap, ldap_bind, [],
+ [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
+ [$EXTRA_LDAP_LIBS])
+ LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
fi
AC_CHECK_FUNCS([ldap_initialize])
--
Best Regards,
Adrian