[SSSD] [PATCHES] Improve portability of autoconf and automake

Lukas Slebodnik lslebodn at redhat.com
Mon Sep 2 17:04:22 UTC 2013


ehlo

Patches are attached.

LS
-------------- next part --------------
>From 6e3b789f4b24198b2ec4b40fb09e8b97e578044a Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 01:12:01 +0200
Subject: [PATCH 2/9] AUTOTOOLS: add check for type intptr_t

We check whether HAVE_INTPTR_T is defined in definition of macro
discard_const_p, but autootols macro AC_CHECK_TYPE did not generate it.
---
 src/external/sizes.m4 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/external/sizes.m4 b/src/external/sizes.m4
index 53df61dedc3ae748c50ca9a3935632087834155d..1018d846016541043d81fb2a53609ad9c562071a 100644
--- a/src/external/sizes.m4
+++ b/src/external/sizes.m4
@@ -37,8 +37,7 @@ AC_CHECK_SIZEOF(off_t)
 AC_CHECK_SIZEOF(size_t)
 AC_CHECK_SIZEOF(ssize_t)
 
+AC_CHECK_TYPES([intptr_t])
 AC_CHECK_TYPE(intptr_t, long long)
 AC_CHECK_TYPE(uintptr_t, unsigned long long)
 AC_CHECK_TYPE(ptrdiff_t, unsigned long long)
-
-
-- 
1.8.3.1

-------------- next part --------------
>From e5d01ae5690d52b83dbdb621bf4e4077fc65abf4 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 05:16:58 +0200
Subject: [PATCH 3/9] AUTOTOOLS: Add -LLIBDIR to PYTHON_LIBS

Detect directory with python libraries and add this
directory to the list of directories to be searched for linker.
---
 src/external/python.m4 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/external/python.m4 b/src/external/python.m4
index 00487a746a44a945e7bcd92a8f1f2ddd2b4eba80..5f48bc92618b2fbc23610f67f86e38f659977c5a 100644
--- a/src/external/python.m4
+++ b/src/external/python.m4
@@ -19,7 +19,8 @@ dnl versions of python
         PYTHON_LIBS="`$PYTHON -c \"from distutils import sysconfig; \
             print \\\" \\\".join(sysconfig.get_config_var('LIBS').split() + \
             sysconfig.get_config_var('SYSLIBS').split()) + \
-            ' -lpython' + sysconfig.get_config_var('VERSION')\"`"
+            ' -lpython' + sysconfig.get_config_var('VERSION') + \
+            ' -L' + sysconfig.get_config_var('LIBDIR')\"`"
             AC_MSG_RESULT([yes])
     else
         AC_MSG_ERROR([no. Please install python devel package])
-- 
1.8.3.1

-------------- next part --------------
>From af2721b0120e9b48e09a9372362a57b8de5f1bf2 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 05:36:49 +0200
Subject: [PATCH 4/9] AUTOTOOLS: Add missing AC_MSG_RESULT

AC_MSG_RESULT was not used everywhere after AC_MSG_CHECKING.
Therefore two lines from configure output was mixed in some cases.
---
 src/external/krb5.m4          | 3 ++-
 src/external/nsupdate.m4      | 6 ++++--
 src/external/pac_responder.m4 | 1 +
 src/external/python.m4        | 3 ++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/external/krb5.m4 b/src/external/krb5.m4
index bdbd71ba1f395eb4f78047f75841729e0289ae81..9cb161d7208c108f744eb34b8e08eb6b3a0fc267 100644
--- a/src/external/krb5.m4
+++ b/src/external/krb5.m4
@@ -16,8 +16,9 @@ if test -x "$KRB5_CONFIG"; then
   KRB5_LIBS="`$KRB5_CONFIG --libs`"
   AC_MSG_RESULT(yes)
 else
+    AC_MSG_RESULT([no])
     if test x$KRB5_PASSED_LIBS = x; then
-        AC_MSG_ERROR(no. Please install MIT kerberos devel package)
+        AC_MSG_ERROR(Please install MIT kerberos devel package)
     fi
 fi
 
diff --git a/src/external/nsupdate.m4 b/src/external/nsupdate.m4
index 9ccff615927664afd7d9a6412159791ff79c5485..b7048d58a3f50dfd25c20754f71386646e2e3dce 100644
--- a/src/external/nsupdate.m4
+++ b/src/external/nsupdate.m4
@@ -9,9 +9,11 @@ if test -x "$NSUPDATE"; then
     AC_MSG_RESULT([yes])
     AC_DEFINE_UNQUOTED([HAVE_NSUPDATE_REALM], 1, [Whether to use the 'realm' directive with nsupdate])
   else
-    AC_MSG_WARN([no. Will build without the 'realm' directive])
+    AC_MSG_RESULT([no])
+    AC_MSG_WARN([Will build without the 'realm' directive])
   fi
 
 else
-  AC_MSG_ERROR([no. nsupdate is not available])
+  AC_MSG_RESULT([no])
+  AC_MSG_ERROR([nsupdate is not available])
 fi
diff --git a/src/external/pac_responder.m4 b/src/external/pac_responder.m4
index 733241a1322f4338be0345b2bb969b7a7c5c35ce..f4f4a34e3256d18dc6387e388a1fbebb223f3566 100644
--- a/src/external/pac_responder.m4
+++ b/src/external/pac_responder.m4
@@ -25,6 +25,7 @@ then
             AC_MSG_RESULT(yes)
             ;;
         *)
+            AC_MSG_RESULT(no)
             AC_MSG_WARN([Cannot build authdata plugin with this version of
                          MIT Kerberos, please use 1.9.x or later])
     esac
diff --git a/src/external/python.m4 b/src/external/python.m4
index 5f48bc92618b2fbc23610f67f86e38f659977c5a..cfe9961c75bbd191b78c8cdc21008b11b179548f 100644
--- a/src/external/python.m4
+++ b/src/external/python.m4
@@ -23,7 +23,8 @@ dnl versions of python
             ' -L' + sysconfig.get_config_var('LIBDIR')\"`"
             AC_MSG_RESULT([yes])
     else
-        AC_MSG_ERROR([no. Please install python devel package])
+        AC_MSG_RESULT([no])
+        AC_MSG_ERROR([Please install python devel package])
     fi
 ])
 
-- 
1.8.3.1

-------------- next part --------------
>From c338c7d721d6bef4fda6ad84321dd3096a14612a Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 07:08:32 +0200
Subject: [PATCH 5/9] AUTOMAKE: Use portable way to link with dlopen

---
 Makefile.am  | 4 ++--
 configure.ac | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 9e68ad9b3a16c9106311eb833a97b01714656a61..1d08dd08b19a56017fbff908811e6a58ab0f7a74 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -719,7 +719,7 @@ sssd_be_SOURCES = \
     src/providers/dp_refresh.c \
     $(SSSD_FAILOVER_OBJ)
 sssd_be_LDADD = \
-    -ldl \
+    $(LIBADD_DL) \
     $(SSSD_LIBS) \
     $(CARES_LIBS) \
     $(SSSD_INTERNAL_LTLIBS)
@@ -1096,7 +1096,7 @@ simple_access_tests_CFLAGS = \
     $(CHECK_CFLAGS) \
     -DUNIT_TESTING
 simple_access_tests_LDADD = \
-    -ldl \
+    $(LIBADD_DL) \
     $(SSSD_LIBS) \
     $(CARES_LIBS) \
     $(CHECK_LIBS) \
diff --git a/configure.ac b/configure.ac
index 19bd1928f8a2149d3bf8e8f7a8d46ab7343a0bd6..d16054efae73e8844ac236d0220f274684c5ce8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,7 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 AC_DISABLE_STATIC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
+LT_LIB_DLLOAD
 AC_CONFIG_MACRO_DIR([m4])
 AM_GNU_GETTEXT([external])
 AM_GNU_GETTEXT_VERSION([0.14])
-- 
1.8.3.1

-------------- next part --------------
>From a98852a669c5df89a0c611cc9324be32e6d05c0e Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 08:50:47 +0200
Subject: [PATCH 6/9] AUTOMAKE: Use portable way to link with gettext

Function gettext needn't be included in libc, it can be part of another
library. Autotools macro AM_GNU_GETTEXT generate makefile variables
(LIBINTL, LTLIBINTL), which contain necessary linker flags.

checking for GNU gettext in libc... no
checking for iconv... yes
checking for GNU gettext in libintl... yes
checking whether to use NLS... yes
checking where the gettext function comes from... external libintl
---
 Makefile.am | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 1d08dd08b19a56017fbff908811e6a58ab0f7a74..e43518ed538abef60f4a644ae4458c2f3c939fa1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -357,6 +357,7 @@ PYTHON_BINDINGS_LIBS = \
     $(TDB_LIBS)
 
 TOOLS_LIBS = \
+    $(LTLIBINTL) \
     $(TALLOC_LIBS) \
     $(TEVENT_LIBS) \
     $(POPT_LIBS) \
@@ -507,8 +508,10 @@ if BUILD_SUDO
     SSSD_DOCS += libsss_sudo_doc
 endif
 
+CLIENT_LIBS = $(LTLIBINTL)
+
 if HAVE_PTHREAD
-CLIENT_LIBS = -lpthread
+CLIENT_LIBS += -lpthread
 endif
 
 #####################
-- 
1.8.3.1

-------------- next part --------------
>From beb84b3339a79de8f0f4a57b2e61642542b0e4ef Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 11:15:03 +0200
Subject: [PATCH 7/9] AUTOTOOLS: Add directories for searching ldap headers and
 libs

---
 src/external/ldap.m4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/external/ldap.m4 b/src/external/ldap.m4
index 8899df9d7c73dae25b97347022651d768986333e..3a99ddfcc7e7ebee94272d382e2876ec8649770a 100644
--- a/src/external/ldap.m4
+++ b/src/external/ldap.m4
@@ -9,14 +9,14 @@ dnl ---------------------------------------------------------------------------
 dnl - Check for Mozilla LDAP or OpenLDAP SDK
 dnl ---------------------------------------------------------------------------
 
-for p in /usr/include/openldap24; do
+for p in /usr/include/openldap24 /usr/local/include; do
     if test -f "${p}/ldap.h"; then
         OPENLDAP_CFLAGS="${OPENLDAP_CFLAGS} -I${p}"
         break;
     fi
 done
 
-for p in /usr/lib64/openldap24 /usr/lib/openldap24; do
+for p in /usr/lib64/openldap24 /usr/lib/openldap24 /usr/local/lib ; do
     if test -f "${p}/libldap.so"; then
         OPENLDAP_LIBS="${OPENLDAP_LIBS} -L${p}"
         break;
-- 
1.8.3.1

-------------- next part --------------
>From 2e939d50ce4837a76bb4850e6fb6b1c1435c27c1 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 12:17:38 +0200
Subject: [PATCH 8/9] AUTOTOOLS: Use pkg-config to detect libraries.

We used pkg-config only as a fallback if header files was not found,
but detection of library failed in case of available header file and
linking problem (missing -Ldir).

This patch prefers pkg-config.
---
 src/external/libcares.m4  | 17 +++++++++++------
 src/external/libpcre.m4   | 12 +++++++++---
 src/external/libpopt.m4   | 12 +++++++++---
 src/external/libtalloc.m4 | 13 ++++++++++---
 src/external/libtdb.m4    | 12 +++++++++---
 src/external/libtevent.m4 | 20 +++++++++++---------
 6 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/src/external/libcares.m4 b/src/external/libcares.m4
index 5b8a3587537a552eec97377cc808afbbebcde860..94b8fffe9daa4c4202b41e4c9e134996a5144b05 100644
--- a/src/external/libcares.m4
+++ b/src/external/libcares.m4
@@ -2,9 +2,15 @@ AC_SUBST(CARES_OBJ)
 AC_SUBST(CARES_LIBS)
 AC_SUBST(CARES_CFLAGS)
 
-AC_CHECK_HEADERS(ares.h,
-    [AC_CHECK_LIB([cares], [ares_init], [ CARES_LIBS="-lcares" ], [AC_MSG_ERROR([No usable c-ares library found])])],
-    [AC_MSG_ERROR([c-ares header files are not installed])]
+PKG_CHECK_MODULES([CARES], [libcares], [found_libcares=yes], [found_libcares=no])
+
+AS_IF([test x"$found_libcares" != xyes],
+    [AC_CHECK_HEADERS([ares.h],
+        [AC_CHECK_LIB([cares],
+                      [ares_init],
+                      [CARES_LIBS="-lcares"],
+                      [AC_MSG_ERROR([No usable c-ares library found])])],
+        [AC_MSG_ERROR([c-ares header files are not installed])])]
 )
 
 dnl Check if this particular version of c-ares supports the generic ares_free_data function
@@ -12,9 +18,8 @@ AC_CHECK_LIB([cares],
              [ares_free_data],
              [AC_DEFINE([HAVE_ARES_DATA], 1, [Does c-ares have ares_free_data()?])
              ],
-             [
-                ares_data=1
-             ]
+             [ares_data=1],
+             [$CARES_LIBS]
 )
 
 AM_CONDITIONAL(BUILD_ARES_DATA, test x$ares_data = x1)
diff --git a/src/external/libpcre.m4 b/src/external/libpcre.m4
index 5917c8cfdc4e7fa76657a727eca30d067b4affcd..3893d3e1436cb5bb7edd597662f596ef64702360 100644
--- a/src/external/libpcre.m4
+++ b/src/external/libpcre.m4
@@ -3,7 +3,7 @@ AC_SUBST(PCRE_OBJ)
 AC_SUBST(PCRE_LIBS)
 AC_SUBST(PCRE_CFLAGS)
 
-PKG_CHECK_MODULES(PCRE, libpcre)
+PKG_CHECK_MODULES([PCRE], [libpcre], [found_libpcre=yes], [found_libpcre=no])
 PKG_CHECK_EXISTS(libpcre >= 7,
                  [AC_MSG_NOTICE([PCRE version is 7 or higher])],
                  [AC_MSG_NOTICE([PCRE version is below 7])
@@ -11,5 +11,11 @@ PKG_CHECK_EXISTS(libpcre >= 7,
                             1,
                             [Define if libpcre version is less than 7])])
 
-AC_CHECK_HEADERS(pcre.h)
-AC_CHECK_LIB(pcre, pcre_compile, [ PCRE_LIBS="-lpcre" ], [AC_MSG_ERROR([PCRE is required])])
+AS_IF([test x"$found_libpcre" != xyes],
+    [AC_CHECK_HEADERS([pcre.h],
+        [AC_CHECK_LIB([pcre],
+                      [pcre_compile],
+                      [PCRE_LIBS="-lpcre"],
+                      [AC_MSG_ERROR([No usable PCRE library found])])],
+        [AC_MSG_ERROR([pcre header files are not installed])])]
+)
diff --git a/src/external/libpopt.m4 b/src/external/libpopt.m4
index e59b2610e8fae007e2fd3b92e8b6270385957f1b..b494d5cc0d2ee3324b60c0a6b1671676013808c5 100644
--- a/src/external/libpopt.m4
+++ b/src/external/libpopt.m4
@@ -3,7 +3,13 @@ AC_SUBST(POPT_OBJ)
 AC_SUBST(POPT_LIBS)
 AC_SUBST(POPT_CFLAGS)
 
-AC_CHECK_HEADERS([popt.h],
-    [AC_CHECK_LIB(popt, poptGetContext, [ POPT_LIBS="-lpopt" ], [AC_MSG_ERROR([POPT must support poptGetContext])])],
-    [AC_MSG_ERROR([POPT development libraries not installed])]
+PKG_CHECK_MODULES([POPT], [popt], [found_popt=yes], [found_popt=no])
+
+AS_IF([test x"$found_popt" != xyes],
+    [AC_CHECK_HEADERS([popt.h],
+        [AC_CHECK_LIB([popt],
+                      [poptGetContext],
+                      [POPT_LIBS="-lpopt"],
+                      [AC_MSG_ERROR([POPT library must support poptGetContext])])],
+        [AC_MSG_ERROR([POPT header files are not installed])])]
 )
diff --git a/src/external/libtalloc.m4 b/src/external/libtalloc.m4
index a4c5b8a9d9e506af88f8e8fad601ef1459793825..dcd916cfc6d16ca835a65993df7e53d966f64943 100644
--- a/src/external/libtalloc.m4
+++ b/src/external/libtalloc.m4
@@ -2,6 +2,13 @@ AC_SUBST(TALLOC_OBJ)
 AC_SUBST(TALLOC_CFLAGS)
 AC_SUBST(TALLOC_LIBS)
 
-AC_CHECK_HEADER(talloc.h,
-   [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ],
-   [PKG_CHECK_MODULES(TALLOC, talloc)])
+PKG_CHECK_MODULES([TALLOC], [talloc], [found_talloc=yes], [found_talloc=no])
+
+AS_IF([test x"$found_talloc" != xyes],
+    [AC_CHECK_HEADER([talloc.h],
+        [AC_CHECK_LIB([talloc],
+                      [talloc_init],
+                      [TALLOC_LIBS="-ltalloc"],
+                      [AC_MSG_ERROR([libtalloc missing talloc_init])])],
+        [AC_MSG_ERROR([libtalloc header files are not installed])])]
+)
diff --git a/src/external/libtdb.m4 b/src/external/libtdb.m4
index 196bc5ccb5361cb2d6ebc70dc231a5ef2d673c1c..5294a662192b706022a787708a43c5dd52789a2b 100644
--- a/src/external/libtdb.m4
+++ b/src/external/libtdb.m4
@@ -2,7 +2,13 @@ AC_SUBST(TDB_OBJ)
 AC_SUBST(TDB_CFLAGS)
 AC_SUBST(TDB_LIBS)
 
-AC_CHECK_HEADERS([tdb.h],
-   [AC_CHECK_LIB(tdb, tdb_repack, [TDB_LIBS="-ltdb"], [AC_MSG_ERROR([TDB must support tdb_repack])]) ],
-   [PKG_CHECK_MODULES(TDB, tdb >= 1.1.3)]
+PKG_CHECK_MODULES([TDB], [tdb >= 1.1.3], [found_tdb=yes], [found_tdb=no])
+
+AS_IF([test x"$found_tdb" != xyes],
+    [AC_CHECK_HEADERS([tdb.h],
+        [AC_CHECK_LIB([tdb],
+                      [tdb_repack],
+                      [TDB_LIBS="-ltdb"],
+                      [AC_MSG_ERROR([library TDB must support tdb_repack])])],
+        [AC_MSG_ERROR([tdb header files are not installed])])]
 )
diff --git a/src/external/libtevent.m4 b/src/external/libtevent.m4
index f19f27bf2e70e71065a7d4d96b4b2714869bd039..b7b10d061fd5ad5114a5000d72f0e784ad220d9e 100644
--- a/src/external/libtevent.m4
+++ b/src/external/libtevent.m4
@@ -2,12 +2,14 @@ AC_SUBST(TEVENT_OBJ)
 AC_SUBST(TEVENT_CFLAGS)
 AC_SUBST(TEVENT_LIBS)
 
-AC_CHECK_HEADER(tevent.h,
-   [AC_CHECK_LIB(
-       tevent,
-       tevent_context_init,
-       [TEVENT_LIBS="-ltevent -ltalloc"],
-       [AC_MSG_ERROR([libtevent missing tevent_context_init])],
-       [-ltalloc]) ],
-   [PKG_CHECK_MODULES(TEVENT, tevent)],
-   )
+PKG_CHECK_MODULES([TEVENT], [tevent], [found_tevent=yes], [found_tevent=no])
+
+AS_IF([test x"$found_tevent" != xyes],
+    [AC_CHECK_HEADER([tevent.h],
+        [AC_CHECK_LIB([tevent],
+                      [tevent_context_init],
+                      [TEVENT_LIBS="-ltevent -ltalloc"],
+                      [AC_MSG_ERROR([libtevent missing tevent_context_init])],
+                      [-ltalloc])],
+        [AC_MSG_ERROR([tevent header files are not installed])])]
+)
-- 
1.8.3.1

-------------- next part --------------
>From faa431369b66684024272392da507d374695aaea Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 31 Aug 2013 15:32:39 +0200
Subject: [PATCH 9/9] AUTOTOOLS: Refactor unicode library detection

If $libdir is not in default library path libunistring cannot be
found. (pkg-config can not be used in this case).
This patch helps to search libunistring in "$libdir" directory.

In refactoring part, indentation was updated to be more readable
and some duplicated parts were removed.
---
 configure.ac                 | 15 +++++++--------
 src/build_macros.m4          | 13 +++++++++++++
 src/external/libunistring.m4 | 31 ++++++++++++++++++++++++-------
 3 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index d16054efae73e8844ac236d0220f274684c5ce8d..c8803b16bc8bf95c6902a18fd5a9be3965d9c59e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,16 +158,15 @@ m4_include([src/external/libndr_nbt.m4])
 
 WITH_UNICODE_LIB
 if test x$unicode_lib = xlibunistring; then
-	m4_include([src/external/libunistring.m4])
-	        AC_DEFINE_UNQUOTED(HAVE_LIBUNISTRING, 1, [Using libunistring for unicode])
-	        UNICODE_LIBS=-lunistring
-	        AC_SUBST(UNICODE_LIBS)
+    m4_include([src/external/libunistring.m4])
+    AC_DEFINE_UNQUOTED(HAVE_LIBUNISTRING, 1, [Using libunistring for unicode])
+    UNICODE_LIBS=$UNISTRING_LIBS
 else
-	m4_include([src/external/glib.m4])
-	        AC_DEFINE_UNQUOTED(HAVE_GLIB2, 1, [Using libunistring for unicode])
-	        UNICODE_LIBS=$GLIB2_LIBS
-	        AC_SUBST(UNICODE_LIBS)
+    m4_include([src/external/glib.m4])
+    AC_DEFINE_UNQUOTED(HAVE_GLIB2, 1, [Using libunistring for unicode])
+    UNICODE_LIBS=$GLIB2_LIBS
 fi
+AC_SUBST(UNICODE_LIBS)
 
 WITH_LIBNL
 
diff --git a/src/build_macros.m4 b/src/build_macros.m4
index 8cd2d3cdeb1294d241852d11cde337e795948884..9e08d2ddfe2bb92c10b58d6a2a890f092d16cc9e 100644
--- a/src/build_macros.m4
+++ b/src/build_macros.m4
@@ -34,3 +34,16 @@ $3
 ])dnl
 fi[]dnl
 ])])
+
+dnl SSS_AC_EXPAND_LIB_DIR() prepare variable sss_extra_libdir,
+dnl variable will contain expanded version of string "-L$libdir"
+dnl therefore this variable can be added to LDFLAGS.
+AC_DEFUN([SSS_AC_EXPAND_LIB_DIR],
+[
+    AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+    dnl By default, look in $includedir and $libdir.
+    AC_LIB_WITH_FINAL_PREFIX([
+        eval additional_libdir=\"$libdir\"
+    ])
+    sss_extra_libdir="-L$additional_libdir"
+])
diff --git a/src/external/libunistring.m4 b/src/external/libunistring.m4
index 18ea3e62a727032a86d248318b5a2a19011ee8ac..61f1a9361ec786c098a03c9d48c698799c3f8f7e 100644
--- a/src/external/libunistring.m4
+++ b/src/external/libunistring.m4
@@ -1,14 +1,31 @@
-AC_CHECK_HEADERS(unistr.h,
-    [AC_CHECK_LIB([unistring], [u8_strlen], [ UNISTRING_LIBS="-lunistring" ], [AC_MSG_ERROR([No usable libunistring library found])])],
+SSS_AC_EXPAND_LIB_DIR()
+
+AC_CHECK_HEADERS([unistr.h],
+    [AC_CHECK_LIB([unistring],
+                  [u8_strlen],
+                  [UNISTRING_LIBS="-lunistring"],
+                  [AC_MSG_ERROR([No usable libunistring library found])],
+                  [$sss_extra_libdir])],
     [AC_MSG_ERROR([libunistring header files are not installed])]
 )
 
-AC_CHECK_HEADERS(unicase.h,
-    [AC_CHECK_LIB([unistring], [u8_casecmp], [ UNISTRING_LIBS="-lunistring" ], [AC_MSG_ERROR([No usable libunistring library found])])],
+AC_CHECK_HEADERS([unicase.h],
+    [AC_CHECK_LIB([unistring],
+                  [u8_casecmp],
+                  [UNISTRING_LIBS="-lunistring"],
+                  [AC_MSG_ERROR([No usable libunistring library found])],
+                  [$sss_extra_libdir])],
     [AC_MSG_ERROR([libunistring header files are not installed])]
 )
 
-AC_CHECK_HEADERS(unistr.h,
-    [AC_CHECK_LIB([unistring], [u8_check], [ UNISTRING_LIBS="-lunistring" ], [AC_MSG_ERROR([No usable libunistring library found])])],
+AC_CHECK_HEADERS([unistr.h],
+    [AC_CHECK_LIB([unistring],
+                  [u8_check],
+                  [UNISTRING_LIBS="-lunistring"],
+                  [AC_MSG_ERROR([No usable libunistring library found])],
+                  [$sss_extra_libdir])],
     [AC_MSG_ERROR([libunistring header files are not installed])]
-)
\ No newline at end of file
+)
+
+
+UNISTRING_LIBS="$sss_extra_libdir $UNISTRING_LIBS "
-- 
1.8.3.1



More information about the sssd-devel mailing list