Subject: Apache2 and LDAP support
To: None <tech-pkg@netbsd.org>
From: Daniel Eggert <danieleggert@mac.com>
List: tech-pkg
Date: 03/30/2003 19:18:08
I'm having trouble getting Apache 2.0.44 to compile with LDAP support. 
As you will see below configure fails with 'ld: cannot find -lldap', 
but shouldn't. Here's the story:

I've added the following to pkgsrc/www/apache/Makefile:

*** Makefile.org        Sat Mar 22 10:37:32 2003
--- Makefile    Mon Mar 24 10:44:38 2003
***************
*** 40,47 ****
***************
*** 49,54 ****
--- 50,66 ----

   APACHE_USER?= www
   APACHE_GROUP?=        www
+
+ .if defined(APACHE_AUTH_LDAP) && ${APACHE_AUTH_LDAP} == YES
+ .include "../../databases/openldap/buildlink2.mk"
+ APACHE_MODULES+=      auth_ldap ldap
+ CONFIGURE_ARGS+=      --with-ldap
+ CONFIGURE_ARGS+=      
--with-ldap-include=${BUILDLINK_PREFIX.openldap}/include
+ CONFIGURE_ARGS+=      --with-ldap-lib=${BUILDLINK_PREFIX.openldap}/lib
+ AUXLIBS+=       -L${BUILDLINK_PREFIX.openldap}/lib      \
+                 -Wl,-R${BUILDLINK_PREFIX.openldap}/lib  \
+                 -lldap -llber
+ .endif

   SUEXEC_COMMENT?=      "@comment "
   .if defined(APACHE_SUEXEC) && ${APACHE_SUEXEC} == YES


Now I try to make:
	[kelvin] /usr/pkgsrc/www/apache2# make APACHE_AUTH_LDAP=YES
and I get:

checking for ldap support...
   setting APRUTIL_INCLUDES to "-I/usr/pkg/include"
   setting APRUTIL_LDFLAGS to "-L/usr/pkg/lib"
checking for ldap_init in -lldap50... no
checking for ldap_init in -lldapssl41... no
checking for ldap_init in -lldapssl40... no
checking for ldap_init in -lldapssl30... no
checking for ldap_init in -lldapssl20... no
checking for ldap_init in -lldap... no
checking for ldap_init in -lldap... (cached) no
checking for ldap_init in -lldap... (cached) no
configure: error: could not find an LDAP library
configure failed for srclib/apr-util
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/www/apache2

But if I check the config log 
(work/httpd-2.0.44/srclib/apr-util/config.log), I see (N.B.: Note the 
error 'ld: cannot find -lldap'):

configure:4290: checking for ldap_init in -lldap
configure:4317: cc -o conftest -O2 -I/usr/pkg/include  
-I/usr/pkg/include -I/usr
/pkg/include  -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -L/usr/pkg/lib 
conftest.c -lldap
  -llber  >&5
ld: cannot find -lldap
configure:4321: $? = 0
configure:4324: test -s conftest
configure:4327: $? = 1
configure: failed program was:
#line 4298 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char ldap_init ();
int
main ()
{
ldap_init ();
   ;
   return 0;
}
configure:4338: result: no
configure:4504: checking for ldap_init in -lldap
configure:4551: result: no
configure:4717: checking for ldap_init in -lldap
configure:4764: result: no
configure:5140: error: could not find an LDAP library

This doesn't make any sense. If I create the file 'conftest.c' with the 
content

char ldap_init ();
int
main ()
{
ldap_init ();
   ;
   return 0;
}

and execute the 'cc'-command as above:

[kelvin] /usr/pkgsrc/www/apache2/work/httpd-2.0.44/srclib/apr-util# cc 
-o conftest -O2 -I/usr/pkg/include -I/usr/pkg/include 
-I/usr/pkg/include -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -L/usr/pkg/lib 
conftest.c -lldap -llber

I don't get any error. Why? Why did configure fail with 'ld: cannot 
find -lldap'?

All help appreciated. Thanks in advance,

Daniel