[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#3982) libldap compile settings



Full_Name: Nicolas Baradakis
Version: CVS head
OS: Debian GNU/Linux
URL: 
Submission from: (NULL) (213.223.184.201)


When building a client program against the libldap, it's difficult to guess the
variables $(CFLAGS) and $(LDFLAGS) according to the local system's setup.
Although dynamic linkage is ok with "-lldap" only, static linkage needs all the
dependancies.

I didn't find an autoconf test for the libldap, and it's a colossal work to
check for all the dependancies for every version and every set of options. It'd
be a lot better if OpenLDAP had a smal script "ldap-config" like many other
librairies provide. (for example gtk-config, mysql_config, sdl-config, etc.)

The following patch is a sample "ldap-config" script. I analyzed the Makefile
which builds "ldapsearch", and stole the needed variables from there.

diff -ruN -x CVS openldap-src.orig/configure.in openldap-src/configure.in
--- openldap-src.orig/configure.in	2005-08-29 17:34:30.343951128 +0200
+++ openldap-src/configure.in	2005-08-29 17:38:26.604034136 +0200
@@ -3259,4 +3259,4 @@
 
 echo Please run \"make depend\" to build dependencies
 ]],[[STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS"]])
-AC_OUTPUT
+AC_OUTPUT(ldap-config)
diff -ruN -x CVS openldap-src.orig/ldap-config.in openldap-src/ldap-config.in
--- openldap-src.orig/ldap-config.in	1970-01-01 01:00:00.000000000 +0100
+++ openldap-src/ldap-config.in	2005-08-29 16:27:58.271838336 +0200
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+ldap_version='@VERSION@'
+
+prefix='@prefix@'
+includedir="@includedir@"
+ldap_cflags="-I$includedir"
+
+exec_prefix="@exec_prefix@"
+libdir="@libdir@"
+LDAP_L="-L$libdir -lldap -llber"
+LDAP_R_L="-L$libdir -lldap_r -llber"
+KRB_LIBS='@KRB4_LIBS@ @KRB5_LIBS@'
+SASL_LIBS='@SASL_LIBS@'
+TLS_LIBS='@TLS_LIBS@'
+AUTH_LIBS='@AUTH_LIBS@'
+SECURITY_LIBS="$SASL_LIBS $KRB_LIBS $TLS_LIBS $AUTH_LIBS"
+LUTIL_LIBS='@LUTIL_LIBS@'
+AC_LIBS='@LIBS@'
+LTHREAD_LIBS='@LTHREAD_LIBS@'
+ldap_libs="$LDAP_L $SECURITY_LIBS $LUTIL_LIBS $AC_LIBS"
+ldap_libs_r="$LDAP_R_L $SECURITY_LIBS $LUTIL_LIBS $AC_LIBS $LTHREAD_LIBS"
+
+usage()
+{
+	cat <<EOF
+Usage: gtk-config [OPTIONS]
+Options:
+	[--version]
+	[--libs]
+	[--libs_r]
+	[--cflags]
+EOF
+	exit $1
+}
+
+if test $# -eq 0; then
+	usage 1 1>&2
+fi
+
+while test $# -gt 0; do
+  case $1 in
+    --version)
+      echo $ldap_version
+      ;;
+    --cflags)
+      echo $ldap_cflags
+      ;;
+    --libs)
+      echo $ldap_libs
+      ;;
+    --libs_r)
+      echo $ldap_libs_r
+      ;;
+    *)
+      usage 1 1>&2
+      ;;
+  esac
+  shift
+done
diff -ruN -x CVS openldap-src.orig/Makefile.in openldap-src/Makefile.in
--- openldap-src.orig/Makefile.in	2005-08-29 17:34:21.782252704 +0200
+++ openldap-src/Makefile.in	2005-08-29 16:15:13.784058144 +0200
@@ -24,11 +24,14 @@
 #	only done at the top-level
 install-common: all FORCE
 
+install-local: FORCE
+	$(INSTALL) -m 755 ldap-config $(bindir)
+
 clean-local: FORCE
 	$(RM) config.log
 
 veryclean-local: FORCE
-	$(RM) config.cache config.status libtool stamp-h stamp-h.in
+	$(RM) config.cache config.status ldap-config libtool stamp-h stamp-h.in
 
 distclean: veryclean FORCE
 

PS: You need to regenerate configure, too.