source: m4/ax_check_xmlsec1.m4

Last change on this file was d6439d4, checked in by Mei <mei@…>, 11 years ago

1) tweak m4s more for bsd

  • Property mode set to 100644
File size: 4.2 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            # if pkg-config is installed and xmlsec1 has installed a .pc file,
41            # then use that information and don't search ssldirs
42            AC_PATH_PROG([PKG_CONFIG], [pkg-config])
43            if test x"$PKG_CONFIG" != x""; then
44                XMLSEC1_LDFLAGS=`$PKG_CONFIG xmlsec1 --libs --define-variable=crypto-default 2>/dev/null`
45                if test $? = 0; then
46                    XMLSEC1_LIBS=`$PKG_CONFIG xmlsec1 --libs --define-variable=crypto=default  2>/dev/null`
47                    XMLSEC1_INCLUDES=`$PKG_CONFIG xmlsec1 --cflags --define-variable=crypto=default  2>/dev/null`
48                    found=true
49                fi
50            fi
51
52            # no such luck; use some default ssldirs
53            if ! $found; then
54                xmlsec1dirs="/usr/local /usr"
55            fi
56        ]
57        )
58
59
60    # XMLSEC1 headers have to be in libxml and xmlsec subdirectories
61    # CFLAGS =-g -Wall `xmlsec1-config --cflags --crypto=default` `xml2-config --cflags`
62    # LDFLAGS += `xml2-config --libs` `xmlsec1-config --libs --crypto=default`
63
64    if ! $found; then
65        AC_PATH_PROG([XMLSEC1_CONFIG], [xmlsec1-config])
66        if test x"$XMLSEC1_CONFIG" != x""; then
67            for xmlsec1dir in $xmlsec1dirs; do
68                AC_MSG_CHECKING([for xmlsec/xmlsec.h in $xmlsec1dir])
69                if test -f "$xmlsec1dir/include/xmlsec1/xmlsec/xmlsec.h"; then
70                    XMLSEC1_INCLUDES=`$XMLSEC1_CONFIG --cflags --crypto=default 2>/dev/null`
71                    XMLSEC1_LDFLAGS=`$XMLSEC1_CONFIG --libs --crypto=default 2>/dev/null`
72                    XMLSEC1_LIBS=`$XMLSEC1_CONFIG --libs --crypto=default 2>/dev/null`
73                    found=true
74                    AC_MSG_RESULT([yes])
75                    break;
76                else
77                    AC_MSG_RESULT([no])
78                fi
79            done
80        else
81            # cannot even find the xmlsec-config
82            AC_MSG_ERROR([Cannot find xmlsec-config in your system path])
83        fi
84
85        # if the file wasn't found, well, go ahead and try the link anyway -- maybe
86        # it will just work!
87    fi
88
89    # try the preprocessor and linker with our new flags,
90    # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
91
92    AC_MSG_CHECKING([whether compiling and linking against XMLSEC1 works])
93    echo "Trying link with XMLSEC1_LDFLAGS=$XMLSEC1_LDFLAGS;" \
94        "XMLSEC1_LIBS=$XMLSEC1_LIBS; XMLSEC1_INCLUDES=$XMLSEC1_INCLUDES" >&AS_MESSAGE_LOG_FD
95
96    save_LIBS="$LIBS"
97    save_LDFLAGS="$LDFLAGS"
98    save_CPPFLAGS="$CPPFLAGS"
99    LDFLAGS="$LDFLAGS $XMLSEC1_LDFLAGS"
100    LIBS="$XMLSEC1_LIBS $LIBS"
101    CPPFLAGS="$XMLSEC1_INCLUDES $CPPFLAGS"
102    AC_LINK_IFELSE(
103        [AC_LANG_PROGRAM([#include <xmlsec/xmlsec.h>], [xmlSecInit()])],
104        [
105            AC_MSG_RESULT([yes])
106            $1
107        ], [
108            AC_MSG_RESULT([no])
109            $2
110        ])
111    CPPFLAGS="$save_CPPFLAGS"
112    LDFLAGS="$save_LDFLAGS"
113    LIBS="$save_LIBS"
114
115    AC_SUBST([XMLSEC1_INCLUDES])
116    AC_SUBST([XMLSEC1_LIBS])
117    AC_SUBST([XMLSEC1_LDFLAGS])
118])
119
Note: See TracBrowser for help on using the repository browser.