blob: 1401af53531246fb6d63d4b9718bd7cc39b5af2a [file] [log] [blame]
Daniel Veillard46057e12000-09-24 18:49:59 +00001dnl Code shamelessly stolen from glib-config by Sebastian Rittau
2dnl AM_PATH_XML([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
3AC_DEFUN(AM_PATH_XML,[
4AC_ARG_WITH(xml-prefix,
5 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
6 xml_config_prefix="$withval", xml_config_prefix="")
7AC_ARG_ENABLE(xmltest,
8 [ --disable-xmltest Do not try to compile and run a test XML program],,
9 enable_xmltest=yes)
10
11 if test x$xml_config_prefix != x ; then
12 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
13 if test x${XML_CONFIG+set} != xset ; then
14 XML_CONFIG=$xml_config_prefix/bin/xml-config
15 fi
16 fi
17
18 AC_PATH_PROG(XML_CONFIG, xml-config, no)
19 min_xml_version=ifelse([$1], ,2.0.0, [$1])
20 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
21 no_xml=""
22 if test "$XML_CONFIG" = "no" ; then
23 no_xml=yes
24 else
25 XML_CFLAGS=`$XML_CONFIG $xml_config_args --cflags`
26 XML_LIBS=`$XML_CONFIG $xml_config_args --libs`
27 xml_config_major_version=`$XML_CONFIG $xml_config_args --version | \
28 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
29 xml_config_minor_version=`$XML_CONFIG $xml_config_args --version | \
30 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
31 xml_config_micro_version=`$XML_CONFIG $xml_config_args --version | \
32 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
33 if test "x$enable_xmltest" = "xyes" ; then
34 ac_save_CFLAGS="$CFLAGS"
35 ac_save_LIBS="$LIBS"
36 CFLAGS="$CFLAGS $XML_CFLAGS"
37 LIBS="$XML_LIBS $LIBS"
38dnl
39dnl Now check if the installed libxml is sufficiently new.
40dnl
41 rm -f conf.xmltest
42 AC_TRY_RUN([
43#include <stdlib.h>
44#include <stdio.h>
Daniel Veillarda4964b72000-10-31 18:23:44 +000045#include <xmlversion.h>
Daniel Veillard46057e12000-09-24 18:49:59 +000046#include <parser.h>
47
48int
49main()
50{
Daniel Veillarda4964b72000-10-31 18:23:44 +000051 int xml_major_version, xml_minor_version, xml_micro_version;
Daniel Veillard46057e12000-09-24 18:49:59 +000052 int major, minor, micro;
53 char *tmp_version;
54
55 system("touch conf.xmltest");
56
Daniel Veillarda4964b72000-10-31 18:23:44 +000057 tmp_version = xmlStrdup("$min_xml_version");
Daniel Veillard46057e12000-09-24 18:49:59 +000058 if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
59 printf("%s, bad version string\n", "$min_xml_version");
60 exit(1);
61 }
62
Daniel Veillarda4964b72000-10-31 18:23:44 +000063 tmp_version = xmlStrdup(LIBXML_DOTTED_VERSION);
64 if(sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
65 printf("%s, bad version string\n", "$min_xml_version");
66 exit(1);
67 }
68
Daniel Veillard46057e12000-09-24 18:49:59 +000069 if((xml_major_version != $xml_config_major_version) ||
70 (xml_minor_version != $xml_config_minor_version) ||
71 (xml_micro_version != $xml_config_micro_version))
72 {
73 printf("\n*** 'xml-config --version' returned %d.%d.%d, but libxml (%d.%d.%d)\n",
74 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version,
75 xml_major_version, xml_minor_version, xml_micro_version);
76 printf("*** was found! If xml-config was correct, then it is best\n");
77 printf("*** to remove the old version of libxml. You may also be able to fix the error\n");
78 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
79 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
80 printf("*** required on your system.\n");
81 printf("*** If xml-config was wrong, set the environment variable XML_CONFIG\n");
82 printf("*** to point to the correct copy of xml-config, and remove the file config.cache\n");
83 printf("*** before re-running configure\n");
84 }
85 else
86 {
87 if ((xml_major_version > major) ||
88 ((xml_major_version == major) && (xml_minor_version > minor)) ||
89 ((xml_major_version == major) && (xml_minor_version == minor) &&
90 (xml_micro_version >= micro)))
91 {
92 return 0;
93 }
94 else
95 {
96 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
97 xml_major_version, xml_minor_version, xml_micro_version);
98 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
99 major, minor, micro);
100 printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
101 printf("***\n");
102 printf("*** If you have already installed a sufficiently new version, this error\n");
103 printf("*** probably means that the wrong copy of the xml-config shell script is\n");
104 printf("*** being found. The easiest way to fix this is to remove the old version\n");
105 printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
106 printf("*** correct copy of xml-config. (In this case, you will have to\n");
107 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
108 printf("*** so that the correct libraries are found at run-time))\n");
109 }
110 }
Daniel Veillard46057e12000-09-24 18:49:59 +0000111 return 1;
112}
113],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
114
115 CFLAGS="$ac_save_CFLAGS"
116 LIBS="$ac_save_LIBS"
117 fi
118 fi
119
120 if test "x$no_xml" = x ; then
121 AC_MSG_RESULT(yes)
122 ifelse([$2], , :, [$2])
123 else
124 AC_MSG_RESULT(no)
125 if test "$XML_CONFIG" = "no" ; then
126 echo "*** The xml-config script installed by libxml could not be found"
127 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
128 echo "*** your path, or set the XML_CONFIG environment variable to the"
129 echo "*** full path to xml-config."
130 else
131 if test -f conf.xmltest ; then
132 :
133 else
134 echo "*** Could not run libxml test program, checking why..."
135 CFLAGS="$CFLAGS $XML_CFLAGS"
136 LIBS="$LIBS $XML_LIBS"
137 dnl FIXME: AC_TRY_LINK
138 fi
139 fi
140
141 XML_CFLAGS=""
142 XML_LIBS=""
143 ifelse([$3], , :, [$3])
144 fi
145 AC_SUBST(XML_CFLAGS)
146 AC_SUBST(XML_LIBS)
147 rm -f conf.xmltest
148])