gst-libxml2.m4 1.43 KB
Newer Older
1
dnl call this macro with the minimum required version as an argument
2 3 4
dnl this macro sets and AC_SUBSTs XML_CFLAGS and XML_LIBS
dnl it also sets LIBXML_PKG, used for the pkg-config file

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
5
AC_DEFUN([AG_GST_LIBXML2_CHECK],
6 7
[
  dnl Minimum required version of libxml2
8 9
  dnl default to 2.4.9 if not specified
  LIBXML2_REQ=ifelse([$1],,2.4.9,[$1])
10
  AC_SUBST(LIBXML2_REQ)
11

12 13
  dnl check for libxml2
  PKG_CHECK_MODULES(XML, libxml-2.0 >= $LIBXML2_REQ, 
14 15 16 17
                    HAVE_LIBXML2=yes, [
                      AC_MSG_RESULT(no)
                      HAVE_LIBXML2=no
                    ])
18 19 20 21 22
  if test "x$HAVE_LIBXML2" = "xyes"; then
    AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 is available])
  else
    AC_MSG_ERROR([Need libxml2 for glib2 builds -- you should be able to do without it -- this needs fixing])
  fi
23 24
  dnl this is for the .pc file
  LIBXML_PKG=', libxml-2.0' 
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
  AC_SUBST(LIBXML_PKG)
  AC_SUBST(XML_LIBS)
  AC_SUBST(XML_CFLAGS)

  dnl XML_LIBS might pull in -lz without zlib actually being on the system, so
  dnl try linking with these LIBS and CFLAGS
  ac_save_CFLAGS=$CFLAGS
  ac_save_LIBS=$LIBS
  CFLAGS="$CFLAGS $XML_CFLAGS"
  LIBS="$LIBS $XML_LIBS"
  AC_TRY_LINK([
#include <libxml/tree.h>
#include <stdio.h>
],[ 
/* function body */
],
    AC_MSG_NOTICE([Test xml2 program linked]),
    AC_MSG_ERROR([Could not link libxml2 test program.  Check if you have the necessary dependencies.])
  )
  CFLAGS="$ac_save_CFLAGS"
  LIBS="$ac_save_LIBS"
46
])