1 dnl EVO_PHONENUMBER_ARGS([default])
3 dnl Checks configure script options for requesting libphonenumber support.
4 dnl Adds a --with-phonenumber option to explicitly enable and disable
5 dnl phonenumber support, but also for pointing to libphonenumber's install
8 dnl Must be called before any other macro that might use the C++ compiler.
9 AC_DEFUN([EVO_PHONENUMBER_ARGS],[
10 AC_BEFORE([$0], [AC_COMPILE_IFELSE])
11 AC_BEFORE([$0], [AC_LINK_IFELSE])
12 AC_BEFORE([$0], [AC_PROG_CXX])
13 AC_BEFORE([$0], [AC_RUN_IFELSE])
14 AC_BEFORE([$0], [LT_INIT])
16 evo_phonenumber_prefix=
18 AC_MSG_CHECKING([whether to enable phonenumber support])
20 AC_ARG_WITH([phonenumber],
21 [AS_HELP_STRING([--with-phonenumber@<:@=PREFIX@:>@],
22 [use libphonenumber at PREFIX])],
23 [evo_phonenumber_prefix=$withval],
24 [with_phonenumber=m4_default([$1],[check])])
26 AC_MSG_RESULT([$with_phonenumber])
28 AS_VAR_IF([with_phonenumber],[no],,[evo_with_cxx=yes])
31 dnl EVO_PHONENUMBER_SUPPORT
33 dnl Check for Google's libphonenumber. Adds a --with-phonenumber option
34 dnl to explicitly enable and disable phonenumber support, but also for
35 dnl pointing to libphonenumber's install prefix.
37 dnl You most probably want to place a call to EVO_PHONENUMBER_ARGS near
38 dnl to the top of your configure script.
39 AC_DEFUN([EVO_PHONENUMBER_SUPPORT],[
40 AC_REQUIRE([EVO_PHONENUMBER_ARGS])
47 AS_VAR_IF([with_phonenumber], [no],, [
50 PHONENUMBER_INCLUDES="-DI18N_PHONENUMBERS_USE_BOOST"
51 PHONENUMBER_LIBS="-lphonenumber"
53 AS_VAR_IF([evo_phonenumber_prefix],,,[
54 PHONENUMBER_INCLUDES="-I$evo_phonenumber_prefix/include $PHONENUMBER_INCLUDES"
55 PHONENUMBER_LIBS="-L$evo_phonenumber_prefix/lib $PHONENUMBER_LIBS"
58 evo_cxxflags_saved="$CXXFLAGS"
59 CXXFLAGS="$CXXFLAGS $PHONENUMBER_INCLUDES"
61 evo_libs_saved="$LIBS"
62 evo_libphonenumber_usable=no
64 AC_MSG_CHECKING([if libphonenumber is usable])
66 for lib in boost_thread-mt boost_thread; do
67 LIBS="$evo_libs_saved $PHONENUMBER_LIBS -l$lib"
71 [[#include <phonenumbers/phonenumberutil.h>]],
72 [[i18n::phonenumbers::PhoneNumberUtil::GetInstance();]])],
74 evo_libphonenumber_usable=yes
75 PHONENUMBER_LIBS="$PHONENUMBER_LIBS -l$lib"
79 AS_VAR_IF([evo_libphonenumber_usable], [no],
81 [with_phonenumber], [check], [with_phonenumber=no],
82 [AC_MSG_ERROR([libphonenumber cannot be used. Use --with-phonenumber to specify the library prefix.])])
85 AS_VAR_IF([evo_phonenumber_prefix],,
86 [msg_phonenumber=$with_phonenumber],
87 [msg_phonenumber=$evo_phonenumber_prefix])
89 AC_MSG_RESULT([$with_phonenumber])
92 [with_phonenumber],[yes],
93 [AC_MSG_CHECKING([whether ParseAndKeepRawInput() is needed])
96 [[#include <phonenumbers/phonenumberutil.h>]],
97 [[namespace pn = i18n::phonenumbers;
101 if (pn::PhoneNumberUtil::GetInstance ()->
102 Parse("049(800)46663", "DE", &n) == pn::PhoneNumberUtil::NO_PARSING_ERROR
103 && n.has_country_code_source ()
104 && n.country_code_source () == 49)
107 return EXIT_FAILURE;]]
110 [AC_MSG_RESULT([no])],
111 [AC_MSG_RESULT([yes])
114 [PHONENUMBER_RAW_INPUT_NEEDED], 1,
115 [Whether Parse() or ParseAndKeepRawInput() must be used to get the country-code source])
120 CXXFLAGS="$evo_cxxflags_saved"
121 LIBS="$evo_libs_saved"
126 AM_CONDITIONAL([ENABLE_PHONENUMBER],
127 [test "x$with_phonenumber" != "xno"])
129 AS_VAR_IF([with_phonenumber], [yes],
130 [AC_DEFINE([ENABLE_PHONENUMBER], 1, [Enable phonenumber parsing])])
132 AC_SUBST([PHONENUMBER_INCLUDES])
133 AC_SUBST([PHONENUMBER_LIBS])