From 4a3e43f2ff3fd8ed659cfc2c86e1cb1ee23b446f Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Thu, 23 Jan 2014 17:39:50 +0100 Subject: [PATCH] Use PKGCONFIG when possible for LDAP --- configure.ac | 40 ++++++++++++++++++++++++++++++---------- coreapi/Makefile.am | 5 +++-- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 218bc2784..fc5e5a52e 100644 --- a/configure.ac +++ b/configure.ac @@ -177,19 +177,39 @@ AC_ARG_ENABLE(ldap, ) if test "$enable_ldap" = "true"; then - AC_CHECK_LIB(sasl2, sasl_client_init , [foo=bar], - [AC_MSG_ERROR(You need SASL for LDAP support)] + PKG_CHECK_MODULES(LDAP, [openldap],[found_ldap=yes], [found_ldap=no]) + if test "$found_ldap" = "no"; then + AC_CHECK_LIB(ldap,ldap_initialize, [LDAP_LIBS="-lldap -llber"], + [AC_MSG_ERROR([You need libldap for LDAP support])] ) - - AC_CHECK_LIB(ldap,ldap_initialize, LDAP_LIBS="-lldap -llber -lsasl2", - [AC_MSG_ERROR(You need libldap for LDAP support)] - ) - - AC_CHECK_HEADERS(ldap.h) - AC_CHECK_HEADERS(sasl/sasl.h) + AC_CHECK_HEADERS(ldap.h, [foo=bar], [AC_MSG_ERROR( [ldap.h not found] ) ] ) + found_ldap=yes + fi + + PKG_CHECK_MODULES(SASL, [libsasl2],[found_sasl=yes],[found_sasl=no] ) + + if test "$found_sasl" = "no"; then + AC_CHECK_LIB(sasl2, sasl_client_init , [SASL_LIBS="-lsasl2"], + [AC_MSG_ERROR([You need SASL for LDAP support] ) ] + ) + AC_CHECK_HEADERS(sasl/sasl.h,foo=bar, [AC_MSG_ERROR([sasl/sasl.h not found])]) + found_sasl=yes + fi + + AC_SUBST(LDAP_CFLAGS) AC_SUBST(LDAP_LIBS) - AC_DEFINE(BUILD_LDAP,1,[Defined if LDAP build option enabled]) + + AC_SUBST(SASL_CFLAGS) + AC_SUBST(SASL_LIBS) + + if test "$found_ldap$found_sasl" = "yesyes"; then + AC_DEFINE(BUILD_LDAP,1,[Defined if LDAP build option enabled]) + else + AC_MSG_ERROR([Can't use LDAP due to previous errors]) + fi + fi + AM_CONDITIONAL(BUILD_LDAP, test x$enable_ldap != xfalse) dnl conditionnal build of console interface. diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 61d240464..9673552e5 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -109,7 +109,7 @@ liblinphone_la_LIBADD= \ $(LIBSOUP_LIBS) \ $(SQLITE3_LIBS) \ $(LIBXML2_LIBS) \ - $(LDAP_LIBS) + $(LDAP_LIBS) $(SASL_LIBS) if ENABLE_TESTS @@ -144,7 +144,8 @@ AM_CFLAGS=\ $(VIDEO_CFLAGS) \ $(TUNNEL_CFLAGS) \ $(SQLITE3_CFLAGS) \ - $(LIBXML2_CFLAGS) + $(LIBXML2_CFLAGS) \ + $(LDAP_CFLAGS) $(SASL_CFLAGS) if BUILD_WIZARD AM_CFLAGS+= -DBUILD_WIZARD