[evolution-data-server/openismus-phonenumber-work: 2/14] build: Check for Google's libphonenumber



commit 7743713136a491c1eead73641e32139efde91d6b
Author: Mathias Hasselmann <mathias openismus com>
Date:   Tue Dec 4 22:44:03 2012 +0100

    build: Check for Google's libphonenumber
    
    This adds the EVO_PHONENUMBER_SUPPORT autconf macro and uses it.

 configure.ac          |    7 +++++
 m4/evo_phonenumber.m4 |   68 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 992ebd1..1c97768 100644
--- a/configure.ac
+++ b/configure.ac
@@ -216,6 +216,7 @@ fi
 
 AC_PROG_CC
 AC_PROG_CPP
+AC_PROG_CXX
 AC_C_INLINE
 AM_PROG_CC_C_O
 AC_PROG_INSTALL
@@ -1232,6 +1233,11 @@ else
 fi
 
 dnl ******************************
+dnl libphonenumber support
+dnl ******************************
+EVO_PHONENUMBER_SUPPORT
+
+dnl ******************************
 dnl GObject marshalling
 dnl ******************************
 AM_PATH_GLIB_2_0
@@ -1647,6 +1653,7 @@ echo "
 	Kerberos 5:		$msg_krb5
 	SMIME support:		$msg_smime
 	IPv6 support:		$msg_ipv6
+	Phone number support:	$msg_phonenumber
 	Dot Locking:		$msg_dot
 	File Locking:		$msg_file
 	Large files:		$enable_largefile
diff --git a/m4/evo_phonenumber.m4 b/m4/evo_phonenumber.m4
new file mode 100644
index 0000000..395a3bc
--- /dev/null
+++ b/m4/evo_phonenumber.m4
@@ -0,0 +1,68 @@
+dnl EVO_PHONENUMBER_SUPPORT([default])
+dnl Check for Google's libphonenumber. Adds a --with-phonenumber option
+dnl to explicitly enable and disable phonenumber support, but also for
+dnl pointing to libphonenumber's install prefix.
+AC_DEFUN([EVO_PHONENUMBER_SUPPORT],[
+	AC_MSG_CHECKING([whether to enable phonenumber support])
+
+	evo_phonenumber_prefix=
+	msg_phonenumber=no
+
+	PHONENUMBER_INCLUDES=
+	PHONENUMBER_LIBS=
+
+	AC_ARG_WITH([phonenumber],
+		[AS_HELP_STRING([--with-phonenumber@<:@=PREFIX@:>@],
+		                [use libphonenumber at PREFIX])],
+		[evo_phonenumber_prefix=$withval],
+		[with_phonenumber=m4_default([$1],[check])])
+
+	AC_MSG_RESULT([$with_phonenumber])
+
+	AS_VAR_IF([with_phonenumber], [no],, [
+		AC_LANG_PUSH(C++)
+
+		PHONENUMBER_LIBS="-lphonenumber -lboost_thread"
+
+		AS_VAR_IF([evo_phonenumber_prefix],,,[
+			PHONENUMBER_INCLUDES="-I$evo_phonenumber_prefix/include"
+			PHONENUMBER_LIBS="-L$evo_phonenumber_prefix/lib $PHONENUMBER_LIBS"
+		])
+
+		evo_cxxflags_saved="$CXXFLAGS"
+		CXXFLAGS="$CXXFLAGS $PHONENUMBER_INCLUDES"
+
+		evo_libs_saved="$LIBS"
+		LIBS="$LIBS $PHONENUMBER_LIBS"
+
+		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.])])
+			])
+
+		CXXFLAGS="$evo_cxxflags_saved"
+		LDFLAGS="$evo_ldflags_saved"
+		LIBS="$evo_libs_saved"
+
+		AS_VAR_IF([evo_phonenumber_prefix],,
+		          [msg_phonenumber=$with_phonenumber],
+		          [msg_phonenumber=$evo_phonenumber_prefix])
+
+		AC_MSG_RESULT([$with_phonenumber])
+		AC_LANG_POP(C++)
+	])
+
+	AM_CONDITIONAL([ENABLE_PHONENUMBER],
+	               [test "x$with_phonenumber" != "xno"])
+
+	AS_VAR_IF([with_phonenumber], [yes],
+	          [AC_DEFINE([ENABLE_PHONENUMBER], 1, [Enable phonenumber parsing])])
+
+	AC_SUBST([PHONENUMBER_INCLUDES])
+	AC_SUBST([PHONENUMBER_LIBS])
+])



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]