source: m4/ax_check_xmlsec1.m4 @ bc7133b

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

1) tweak xmlsec1's m4

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