1
dnl Code shamelessly stolen from glib-config by Sebastian Rittau
2
dnl AM_PATH_XML([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
4
AC_ARG_WITH(xml-prefix,
5
[ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
6
xml_config_prefix="$withval", xml_config_prefix="")
8
[ --disable-xmltest Do not try to compile and run a test XML program],,
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
18
AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
19
if test "$XML2_CONFIG" = "no" ; then
20
AC_PATH_PROG(XML_CONFIG, xml-config, no)
22
XML_CONFIG=$XML2_CONFIG
24
min_xml_version=ifelse([$1], ,2.0.0, [$1])
25
AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
27
if test "$XML_CONFIG" = "no" ; then
31
ac_save_CFLAGS="$CFLAGS"
33
CFLAGS="$CFLAGS $XML_CFLAGS"
34
LIBS="$XML_LIBS $LIBS"
36
dnl Now check if the installed libxml is sufficiently new.
42
#include <libxml/xmlversion.h>
43
#include <libxml/parser.h>
48
int xml_major_version, xml_minor_version, xml_micro_version;
49
int major, minor, micro;
52
system("touch conf.xmltest");
54
tmp_version = xmlStrdup("$min_xml_version");
55
if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
56
printf("%s, bad version string\n", "$min_xml_version");
60
tmp_version = xmlStrdup(LIBXML_DOTTED_VERSION);
61
if(sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
62
printf("%s, bad version string\n", "$min_xml_version");
66
if ((xml_major_version > major) ||
67
((xml_major_version == major) && (xml_minor_version > minor)) ||
68
((xml_major_version == major) && (xml_minor_version == minor) &&
69
(xml_micro_version >= micro)))
75
printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
76
xml_major_version, xml_minor_version, xml_micro_version);
77
printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
79
printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
81
printf("*** If you have already installed a sufficiently new version, this error\n");
82
printf("*** probably means that the wrong copy of the xml-config shell script is\n");
83
printf("*** being found. The easiest way to fix this is to remove the old version\n");
84
printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
85
printf("*** correct copy of xml-config. (In this case, you will have to\n");
86
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
87
printf("*** so that the correct libraries are found at run-time))\n");
91
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
93
CFLAGS="$ac_save_CFLAGS"
96
XML_CFLAGS=`$XML_CONFIG $xml_config_args --cflags`
97
XML_LIBS=`$XML_CONFIG $xml_config_args --libs`
98
xml_config_major_version=`$XML_CONFIG $xml_config_args --version | \
99
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
100
xml_config_minor_version=`$XML_CONFIG $xml_config_args --version | \
101
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
102
xml_config_micro_version=`$XML_CONFIG $xml_config_args --version | \
103
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
104
# Strip '-L/usr/lib' off since this is always in the link path.
105
XML_LIBS=`echo $XML_LIBS | sed -e 's|-L/usr/lib||'`
107
if test "x$enable_xmltest" = "xyes" ; then
108
ac_save_CFLAGS="$CFLAGS"
110
CFLAGS="$CFLAGS $XML_CFLAGS"
111
LIBS="$XML_LIBS $LIBS"
113
dnl Now check if the installed libxml is sufficiently new.
119
#include <libxml/xmlversion.h>
120
#include <libxml/parser.h>
125
int xml_major_version, xml_minor_version, xml_micro_version;
126
int major, minor, micro;
129
system("touch conf.xmltest");
131
tmp_version = xmlStrdup("$min_xml_version");
132
if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
133
printf("%s, bad version string\n", "$min_xml_version");
137
tmp_version = xmlStrdup(LIBXML_DOTTED_VERSION);
138
if(sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
139
printf("%s, bad version string\n", "$min_xml_version");
143
if((xml_major_version != $xml_config_major_version) ||
144
(xml_minor_version != $xml_config_minor_version) ||
145
(xml_micro_version != $xml_config_micro_version))
147
printf("\n*** 'xml-config --version' returned %d.%d.%d, but libxml (%d.%d.%d)\n",
148
$xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version,
149
xml_major_version, xml_minor_version, xml_micro_version);
150
printf("*** was found! If xml-config was correct, then it is best\n");
151
printf("*** to remove the old version of libxml. You may also be able to fix the error\n");
152
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
153
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
154
printf("*** required on your system.\n");
155
printf("*** If xml-config was wrong, set the environment variable XML_CONFIG\n");
156
printf("*** to point to the correct copy of xml-config, and remove the file config.cache\n");
157
printf("*** before re-running configure\n");
161
if ((xml_major_version > major) ||
162
((xml_major_version == major) && (xml_minor_version > minor)) ||
163
((xml_major_version == major) && (xml_minor_version == minor) &&
164
(xml_micro_version >= micro)))
170
printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
171
xml_major_version, xml_minor_version, xml_micro_version);
172
printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
173
major, minor, micro);
174
printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
176
printf("*** If you have already installed a sufficiently new version, this error\n");
177
printf("*** probably means that the wrong copy of the xml-config shell script is\n");
178
printf("*** being found. The easiest way to fix this is to remove the old version\n");
179
printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
180
printf("*** correct copy of xml-config. (In this case, you will have to\n");
181
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
182
printf("*** so that the correct libraries are found at run-time))\n");
187
],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
189
CFLAGS="$ac_save_CFLAGS"
194
if test "x$no_xml" = x ; then
196
ifelse([$2], , :, [$2])
199
if test "$XML_CONFIG" = "no" ; then
200
echo "*** The xml-config script installed by libxml could not be found"
201
echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
202
echo "*** your path, or set the XML_CONFIG environment variable to the"
203
echo "*** full path to xml-config."
205
if test -f conf.xmltest ; then
208
echo "*** Could not run libxml test program, checking why..."
209
CFLAGS="$CFLAGS $XML_CFLAGS"
210
LIBS="$LIBS $XML_LIBS"
211
dnl FIXME: AC_TRY_LINK
217
ifelse([$3], , :, [$3])