build: Support (and prefer) libboost_thread-mt
authorMathias Hasselmann <mathias@openismus.com>
Tue, 26 Feb 2013 15:06:56 +0000 (16:06 +0100)
committerMathias Hasselmann <mathias@openismus.com>
Wed, 27 Feb 2013 13:55:22 +0000 (14:55 +0100)
Google's libphonenumber uses the Boost Thread library but somehow fails
to let its shared library express that dependency. Therefore we must
manually link that library. Now Fedora only installs libboost_thread-mt,
but not libboost_thread. This patch checks for both build variants of
the threads library and prefers libboost_thread-mt.

The change in preference is because it doesn't make much sense to use
a thread support library that isn't thread-safe, does it?

https://bugzilla.gnome.org/show_bug.cgi?id=694749

m4/evo_phonenumber.m4

index 357b6af..0cc493f 100644 (file)
@@ -47,7 +47,7 @@ AC_DEFUN([EVO_PHONENUMBER_SUPPORT],[
        AS_VAR_IF([with_phonenumber], [no],, [
                AC_LANG_PUSH(C++)
 
-               PHONENUMBER_LIBS="-lphonenumber -lboost_thread"
+               PHONENUMBER_LIBS="-lphonenumber"
 
                AS_VAR_IF([evo_phonenumber_prefix],,,[
                        PHONENUMBER_INCLUDES="-I$evo_phonenumber_prefix/include"
@@ -58,18 +58,28 @@ AC_DEFUN([EVO_PHONENUMBER_SUPPORT],[
                CXXFLAGS="$CXXFLAGS $PHONENUMBER_INCLUDES"
 
                evo_libs_saved="$LIBS"
-               LIBS="$LIBS $PHONENUMBER_LIBS"
+               evo_libphonenumber_usable=no
 
                AC_MSG_CHECKING([if libphonenumber is usable])
-               AC_LINK_IFELSE(
-                       [AC_LANG_PROGRAM(
-                               [[#include <phonenumbers/phonenumberutil.h>]],
-                               [[i18n::phonenumbers::PhoneNumberUtil::GetInstance();]])],
-                       [with_phonenumber=yes],
-                       [AS_VAR_IF([with_phonenumber], [check], [with_phonenumber=no], [
-                               AC_MSG_ERROR([libphonenumber cannot be used. Use --with-phonenumber to specify the library prefix.])])
-                       ])
 
+               for lib in boost_thread-mt boost_thread; do
+                       LIBS="$evo_libs_saved $PHONENUMBER_LIBS -l$lib"
+
+                       AC_LINK_IFELSE(
+                               [AC_LANG_PROGRAM(
+                                       [[#include <phonenumbers/phonenumberutil.h>]],
+                                       [[i18n::phonenumbers::PhoneNumberUtil::GetInstance();]])],
+                               [with_phonenumber=yes
+                                evo_libphonenumber_usable=yes
+                                PHONENUMBER_LIBS="$PHONENUMBER_LIBS -l$lib"
+                                break])
+               done
+
+               AS_VAR_IF([evo_libphonenumber_usable], [no],
+                       [AS_VAR_IF(
+                               [with_phonenumber], [check], [with_phonenumber=no],
+                               [AC_MSG_ERROR([libphonenumber cannot be used. Use --with-phonenumber to specify the library prefix.])])
+                       ])
 
                AS_VAR_IF([evo_phonenumber_prefix],,
                          [msg_phonenumber=$with_phonenumber],