[461541a] | 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 | # |
---|
| 24 | AU_ALIAS([CHECK_XML2], [AX_CHECK_XML2]) |
---|
| 25 | AC_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 | ], [ |
---|
[c75b2c2] | 39 | xml2dirs="/usr/local /usr" |
---|
[461541a] | 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` |
---|
[ecb1628] | 56 | XML2_LIBS=`$XML2_CONFIG --libs 2>/dev/null` |
---|
[461541a] | 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 xml2-config |
---|
| 66 | AC_MSG_ERROR([Cannot find xml2-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 XML2 works]) |
---|
| 77 | echo "Trying link with XML2_LDFLAGS=$XML2_LDFLAGS;" \ |
---|
| 78 | "XML2_LIBS=$XML2_LIBS; XML2_INCLUDES=$XML2_INCLUDES" >&AS_MESSAGE_LOG_FD |
---|
| 79 | |
---|
| 80 | save_LIBS="$LIBS" |
---|
| 81 | save_LDFLAGS="$LDFLAGS" |
---|
| 82 | save_CPPFLAGS="$CPPFLAGS" |
---|
| 83 | LDFLAGS="$LDFLAGS $XML2_LDFLAGS" |
---|
| 84 | LIBS="$XML2_LIBS $LIBS" |
---|
| 85 | CPPFLAGS="$XML2_INCLUDES $CPPFLAGS" |
---|
| 86 | AC_LINK_IFELSE( |
---|
| 87 | [AC_LANG_PROGRAM([#include <libxml/tree.h>], [xmlMalloc(1)])], |
---|
| 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([XML2_INCLUDES]) |
---|
| 100 | AC_SUBST([XML2_LIBS]) |
---|
| 101 | AC_SUBST([XML2_LDFLAGS]) |
---|
| 102 | ]) |
---|
| 103 | |
---|