Initial import
[platform/upstream/gst-rtsp-server.git] / common / m4 / gst-libxml2.m4
1 dnl call this macro with the minimum required version as an argument
2 dnl this macro sets and AC_SUBSTs XML_CFLAGS and XML_LIBS
3 dnl it also sets LIBXML_PKG, used for the pkg-config file
4
5 AC_DEFUN([AG_GST_LIBXML2_CHECK],
6 [
7   dnl Minimum required version of libxml2
8   dnl default to 2.4.9 if not specified
9   LIBXML2_REQ=ifelse([$1],,2.4.9,[$1])
10   AC_SUBST(LIBXML2_REQ)
11
12   dnl check for libxml2
13   PKG_CHECK_MODULES(XML, libxml-2.0 >= $LIBXML2_REQ, 
14                     HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
15   if test "x$HAVE_LIBXML2" = "xyes"; then
16     AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 is available])
17   else
18     AC_MSG_ERROR([Need libxml2 for glib2 builds -- you should be able to do without it -- this needs fixing])
19   fi
20   dnl this is for the .pc file
21   LIBXML_PKG=', libxml-2.0' 
22   AC_SUBST(LIBXML_PKG)
23   AC_SUBST(XML_LIBS)
24   AC_SUBST(XML_CFLAGS)
25
26   dnl XML_LIBS might pull in -lz without zlib actually being on the system, so
27   dnl try linking with these LIBS and CFLAGS
28   ac_save_CFLAGS=$CFLAGS
29   ac_save_LIBS=$LIBS
30   CFLAGS="$CFLAGS $XML_CFLAGS"
31   LIBS="$LIBS $XML_LIBS"
32   AC_TRY_LINK([
33 #include <libxml/tree.h>
34 #include <stdio.h>
35 ],[ 
36 /* function body */
37 ],
38     AC_MSG_NOTICE([Test xml2 program linked]),
39     AC_MSG_ERROR([Could not link libxml2 test program.  Check if you have the necessary dependencies.])
40   )
41   CFLAGS="$ac_save_CFLAGS"
42   LIBS="$ac_save_LIBS"
43 ])