>From faa431369b66684024272392da507d374695aaea Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik 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