source: filezilla/trunk/fuentes/m4/fz_check_pugixml.m4 @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 3.0 KB
Line 
1dnl Checks whether system's pugixml library exists and is usable.
2
3AC_DEFUN([FZ_CHECK_PUGIXML], [
4  AC_ARG_WITH(pugixml, AC_HELP_STRING([--with-pugixml=type], [Selects which version of pugixml to use. Type has to be either system or builtin]),
5    [
6      if test "x$with_pugixml" != "xbuiltin"; then
7        if test "x$with_pugixml" != "xsystem"; then
8          if test "x$with_pugixml" != "xauto"; then
9            AC_MSG_ERROR([--with-pugixml has to be set to either system (the default), builtin or auto])
10          fi
11        fi
12      fi
13    ],
14    [
15      if echo $host_os | grep -i "cygwin\|mingw\|mac\|apple" > /dev/null 2>&1 ; then
16        with_pugixml=auto
17      else
18        with_pugixml=system
19      fi
20    ])
21
22  if test "x$with_pugixml" != "xbuiltin"; then
23
24    AC_LANG_PUSH(C++)
25
26    dnl Check pugixml.hpp header
27    AC_CHECK_HEADER(
28      [pugixml.hpp],
29      [],
30      [
31        if test "x$with_pugixml" = "xsystem"; then
32          AC_MSG_ERROR([pugixml.hpp not found. If you do not have pugixml installed as system library, you can use the copy of pugixml distributed with FileZilla by passing --with-pugixml=builtin as argument to configure.])
33        else
34          with_pugixml=builtin
35        fi
36      ])
37
38    dnl Check for shared library
39    dnl Oddity: in AC_CHECK_HEADER I can leave the true case empty, but not in AC_HAVE_LIBRARY
40    AC_HAVE_LIBRARY(pugixml,
41      [true],
42      [
43        if test "x$with_pugixml" = "xsystem"; then
44          AC_MSG_ERROR([pugixml sytem library not found but requested. If you do not have pugixml installed as system library, you can use the copy of pugixml distributed with FileZilla by passing --with-pugixml=builtin as argument to configure.])
45        else
46          with_pugixml=builtin
47        fi
48      ])
49
50    dnl Check for at least version 1.5
51    AC_MSG_CHECKING([for pugixml >= 1.5])
52    AC_COMPILE_IFELSE([
53      AC_LANG_PROGRAM([
54        #include <pugixml.hpp>
55      ],[
56          static_assert(PUGIXML_VERSION >= 150, "Need at least pugixml 1.5");
57      ])
58    ],[
59      AC_MSG_RESULT([yes])
60    ],[
61      AC_MSG_RESULT([no])
62      AC_MSG_ERROR([pugixml system library is too old, you need at least version 1.5])
63    ])
64
65    AC_MSG_CHECKING([whether pugixml has been compiled with long long support])
66    old_libs="$LIBS"
67    LIBS="$LIBS -lpugixml"
68    AC_LINK_IFELSE([
69      AC_LANG_PROGRAM([
70        #include <pugixml.hpp>
71      ],[
72        long long v{};
73        pugi::xml_text t;
74        t.set(v);
75        v = t.as_llong();
76        return v;
77      ])
78    ],[
79      AC_MSG_RESULT([yes])
80    ],[
81      AC_MSG_RESULT([no])
82      AC_MSG_ERROR([pugixml system library has been compiled without long long support])
83    ])
84    LIBS="$old_libs"
85
86    AC_LANG_POP
87 
88    AC_MSG_NOTICE([Using system pugixml])
89    AC_DEFINE(HAVE_LIBPUGIXML, 1, [Define to 1 if your system has the `pugixml' library (-lpugixml).])
90    PUGIXML_LIBS="-lpugixml"
91  else
92    AC_MSG_NOTICE([Using builtin pugixml])
93    PUGIXML_LIBS="../pugixml/libpugixml.a"
94  fi
95
96  AC_SUBST(PUGIXML_LIBS)
97])
Note: See TracBrowser for help on using the repository browser.