source: m4/ax_check_xml2.m4 @ ff71d24

abac0-leakabac0-meimei-idmei-rt0-nmei_rt0tvf-new-xml
Last change on this file since ff71d24 was c75b2c2, checked in by Mei <mei@…>, 11 years ago

1) added couple of new m4 for setting up configure for xmlsec1 and xml2 and openssl

  • Property mode set to 100644
File size: 3.2 KB
Line 
1# ===========================================================================
2#     ax_check_xml2.m4
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_CHECK_XML2([action-if-found[, action-if-not-found]])
8#
9# DESCRIPTION
10#
11#   Look for xml2in a number of default spots, or in a user-selected
12#   spot (via --with-xml2).  Sets
13#
14#     XML2_INCLUDES to the include directives required
15#     XML2_LIBS to the -l directives required
16#     XML2_LDFLAGS to the -L or -R flags required
17#
18#   and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
19#
20#   This macro sets XML2_INCLUDES such that source files should use the
21#   libxml2/ directory in include directives:
22#    ... <libxml/tree.h>
23#
24AU_ALIAS([CHECK_XML2], [AX_CHECK_XML2])
25AC_DEFUN([AX_CHECK_XML2], [
26    found=false
27    AC_ARG_WITH([xml2],
28        [AS_HELP_STRING([--with-xml2=DIR],
29            [root of the XML2 directory])],
30        [
31            case "$withval" in
32            "" | y | ye | yes | n | no)
33            AC_MSG_ERROR([Invalid --with-xml2 value])
34              ;;
35            *) xml2dirs="$withval"
36              ;;
37            esac
38        ], [
39            xml2dirs="/usr/local /usr"
40        ]
41        )
42
43
44    # XML2 headers have to be in libxml and xml2dir subdirectories
45    # CFLAGS =-g -Wall `xmlsec1-config --cflags --crypto=default` `xml2-config --cflags`
46    # LDFLAGS += `xml2-config --libs` `xmlsec1-config --libs --crypto=default`
47
48    if ! $found; then
49        AC_PATH_PROG([XML2_CONFIG], [xml2-config])
50        if test x"$XML2_CONFIG" != x""; then
51            for xml2dir in $xml2dirs; do
52                AC_MSG_CHECKING([for libxml/tree.h in $xml2dir])
53                if test -f "$xml2dir/include/libxml2/libxml/tree.h"; then
54                    XML2_INCLUDES=`$XML2_CONFIG --cflags 2>/dev/null`
55                    XML2_LDFLAGS=`$XML2_CONFIG --libs 2>/dev/null`
56                    found=true
57                    AC_MSG_RESULT([yes])
58                    break
59                else
60                    AC_MSG_RESULT([no])
61                fi
62            done
63        else
64            # cannot even find the xml2-config
65            AC_MSG_ERROR([Cannot find xml2-config in your system path])
66        fi
67
68        # if the file wasn't found, well, go ahead and try the link anyway -- maybe
69        # it will just work!
70    fi
71
72    # try the preprocessor and linker with our new flags,
73    # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
74
75    AC_MSG_CHECKING([whether compiling and linking against XML2 works])
76    echo "Trying link with XML2_LDFLAGS=$XML2_LDFLAGS;" \
77        "XML2_LIBS=$XML2_LIBS; XML2_INCLUDES=$XML2_INCLUDES" >&AS_MESSAGE_LOG_FD
78
79    save_LIBS="$LIBS"
80    save_LDFLAGS="$LDFLAGS"
81    save_CPPFLAGS="$CPPFLAGS"
82    LDFLAGS="$LDFLAGS $XML2_LDFLAGS"
83    LIBS="$XML2_LIBS $LIBS"
84    CPPFLAGS="$XML2_INCLUDES $CPPFLAGS"
85    AC_LINK_IFELSE(
86        [AC_LANG_PROGRAM([#include <libxml/tree.h>], [xmlMalloc(1)])],
87        [
88            AC_MSG_RESULT([yes])
89            $1
90        ], [
91            AC_MSG_RESULT([no])
92            $2
93        ])
94    CPPFLAGS="$save_CPPFLAGS"
95    LDFLAGS="$save_LDFLAGS"
96    LIBS="$save_LIBS"
97
98    AC_SUBST([XML2_INCLUDES])
99    AC_SUBST([XML2_LIBS])
100    AC_SUBST([XML2_LDFLAGS])
101])
102
Note: See TracBrowser for help on using the repository browser.