1 # Configure paths for LIBXML2
2 # Toshio Kuratomi 2001-04-21
4 # Configure paths for GLIB
7 dnl AM_PATH_XML([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
8 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
10 AC_DEFUN([AM_PATH_XML],[
11 AC_ARG_WITH(xml-prefix,
12 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
13 xml_config_prefix="$withval", xml_config_prefix="")
14 AC_ARG_WITH(xml-exec-prefix,
15 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
16 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
17 AC_ARG_ENABLE(xmltest,
18 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
21 if test x$xml_config_exec_prefix != x ; then
22 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
23 if test x${XML_CONFIG+set} != xset ; then
24 XML_CONFIG=$xml_config_exec_prefix/bin/xml-config
27 if test x$xml_config_prefix != x ; then
28 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
29 if test x${XML_CONFIG+set} != xset ; then
30 XML_CONFIG=$xml_config_prefix/bin/xml-config
34 AC_PATH_PROG(XML_CONFIG, xml-config, no)
35 min_xml_version=ifelse([$1], ,1.0.0,[$1])
36 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
38 if test "$XML_CONFIG" = "no" ; then
41 XML_CFLAGS=`$XML_CONFIG $xml_config_args --cflags`
42 XML_LIBS=`$XML_CONFIG $xml_config_args --libs`
43 xml_config_major_version=`$XML_CONFIG $xml_config_args --version | \
44 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
45 xml_config_minor_version=`$XML_CONFIG $xml_config_args --version | \
46 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
47 xml_config_micro_version=`$XML_CONFIG $xml_config_args --version | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
49 if test "x$enable_xmltest" = "xyes" ; then
50 ac_save_CFLAGS="$CFLAGS"
52 CFLAGS="$CFLAGS $XML_CFLAGS"
53 LIBS="$XML_LIBS $LIBS"
55 dnl Now check if the installed libxml is sufficiently new.
56 dnl (Also sanity checks the results of xml-config to some extent)
63 #include <libxml/tree.h>
68 int xml_major_version, xml_minor_version, xml_micro_version;
69 int major, minor, micro;
73 system("touch conf.xmltest");
75 /* Capture xml-config output via autoconf/configure variables */
76 /* HP/UX 9 (%@#!) writes to sscanf strings */
77 tmp_version = (char *)strdup("$min_xml_version");
78 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
79 printf("%s, bad version string from xml-config\n", "$min_xml_version");
84 /* Capture the version information from the header files */
85 tmp_int_version = LIBXML_VERSION;
86 xml_major_version=tmp_int_version / 10000;
87 xml_minor_version=(tmp_int_version - xml_major_version * 10000) / 100;
88 xml_micro_version=(tmp_int_version - xml_minor_version * 100 - xml_major_version * 10000);
90 /* Compare xml-config output to the libxml headers */
91 if ((xml_major_version != $xml_config_major_version) ||
92 (xml_minor_version != $xml_config_minor_version)
95 /* The last released version of libxml-1.x has an incorrect micro version in
96 * the header file so neither the includes nor the library will match the
97 * micro_version to the output of xml-config
99 (xml_micro_version != $xml_config_micro_version)
104 printf("*** libxml header files (version %d.%d.%d) do not match\n",
105 xml_major_version, xml_minor_version, xml_micro_version);
106 printf("*** xml-config (version %d.%d.%d)\n",
107 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
110 /* Compare the headers to the library to make sure we match */
111 /* Less than ideal -- doesn't provide us with return value feedback,
112 * only exits if there's a serious mismatch between header and library.
116 /* Test that the library is greater than our minimum version */
117 if (($xml_config_major_version > major) ||
118 (($xml_config_major_version == major) && ($xml_config_minor_version > minor)) ||
119 (($xml_config_major_version == major) && ($xml_config_minor_version == minor) &&
120 ($xml_config_micro_version >= micro)))
126 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
127 xml_major_version, xml_minor_version, xml_micro_version);
128 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
129 major, minor, micro);
130 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
132 printf("*** If you have already installed a sufficiently new version, this error\n");
133 printf("*** probably means that the wrong copy of the xml-config shell script is\n");
134 printf("*** being found. The easiest way to fix this is to remove the old version\n");
135 printf("*** of LIBXML, but you can also set the XML_CONFIG environment to point to the\n");
136 printf("*** correct copy of xml-config. (In this case, you will have to\n");
137 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
138 printf("*** so that the correct libraries are found at run-time))\n");
142 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
143 CFLAGS="$ac_save_CFLAGS"
148 if test "x$no_xml" = x ; then
149 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
150 ifelse([$2], , :, [$2])
153 if test "$XML_CONFIG" = "no" ; then
154 echo "*** The xml-config script installed by LIBXML could not be found"
155 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
156 echo "*** your path, or set the XML_CONFIG environment variable to the"
157 echo "*** full path to xml-config."
159 if test -f conf.xmltest ; then
162 echo "*** Could not run libxml test program, checking why..."
163 CFLAGS="$CFLAGS $XML_CFLAGS"
164 LIBS="$LIBS $XML_LIBS"
166 #include <libxml/tree.h>
168 ], [ LIBXML_TEST_VERSION; return 0;],
169 [ echo "*** The test program compiled, but did not run. This usually means"
170 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
171 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
172 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
173 echo "*** to the installed location Also, make sure you have run ldconfig if that"
174 echo "*** is required on your system"
176 echo "*** If you have an old version installed, it is best to remove it, although"
177 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
178 [ echo "*** The test program failed to compile or link. See the file config.log for the"
179 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
180 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
181 echo "*** may want to edit the xml-config script: $XML_CONFIG" ])
182 CFLAGS="$ac_save_CFLAGS"
189 ifelse([$3], , :, [$3])
196 # Configure paths for LIBXML2
197 # Toshio Kuratomi 2001-04-21
199 # Configure paths for GLIB
200 # Owen Taylor 97-11-3
202 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
203 dnl Test for XML, and define XML_CFLAGS and XML_LIBS
205 AC_DEFUN([AM_PATH_XML2],[
206 AC_ARG_WITH(xml-prefix,
207 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
208 xml_config_prefix="$withval", xml_config_prefix="")
209 AC_ARG_WITH(xml-exec-prefix,
210 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
211 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
212 AC_ARG_ENABLE(xmltest,
213 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
216 if test x$xml_config_exec_prefix != x ; then
217 xml_config_args="$xml_config_args --exec-prefix=$xml_config_exec_prefix"
218 if test x${XML2_CONFIG+set} != xset ; then
219 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
222 if test x$xml_config_prefix != x ; then
223 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
224 if test x${XML2_CONFIG+set} != xset ; then
225 XML2_CONFIG=$xml_config_prefix/bin/xml2-config
229 AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
230 min_xml_version=ifelse([$1], ,2.0.0,[$1])
231 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
233 if test "$XML2_CONFIG" = "no" ; then
236 XML_CFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
237 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
238 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
239 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
240 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
241 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
242 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
243 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
244 if test "x$enable_xmltest" = "xyes" ; then
245 ac_save_CFLAGS="$CFLAGS"
246 ac_save_CXXFLAGS="$CXXFLAGS"
248 CFLAGS="$CFLAGS $XML_CFLAGS"
249 CXXFLAGS="$CXXFLAGS $XML_CFLAGS"
250 LIBS="$XML_LIBS $LIBS"
252 dnl Now check if the installed libxml is sufficiently new.
253 dnl (Also sanity checks the results of xml2-config to some extent)
260 #include <libxml/xmlversion.h>
265 int xml_major_version, xml_minor_version, xml_micro_version;
266 int major, minor, micro;
269 system("touch conf.xmltest");
271 /* Capture xml2-config output via autoconf/configure variables */
272 /* HP/UX 9 (%@#!) writes to sscanf strings */
273 tmp_version = (char *)strdup("$min_xml_version");
274 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
275 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
280 /* Capture the version information from the header files */
281 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
282 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
283 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
288 /* Compare xml2-config output to the libxml headers */
289 if ((xml_major_version != $xml_config_major_version) ||
290 (xml_minor_version != $xml_config_minor_version) ||
291 (xml_micro_version != $xml_config_micro_version))
293 printf("*** libxml header files (version %d.%d.%d) do not match\n",
294 xml_major_version, xml_minor_version, xml_micro_version);
295 printf("*** xml2-config (version %d.%d.%d)\n",
296 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
299 /* Compare the headers to the library to make sure we match */
300 /* Less than ideal -- doesn't provide us with return value feedback,
301 * only exits if there's a serious mismatch between header and library.
305 /* Test that the library is greater than our minimum version */
306 if ((xml_major_version > major) ||
307 ((xml_major_version == major) && (xml_minor_version > minor)) ||
308 ((xml_major_version == major) && (xml_minor_version == minor) &&
309 (xml_micro_version >= micro)))
315 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
316 xml_major_version, xml_minor_version, xml_micro_version);
317 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
318 major, minor, micro);
319 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
321 printf("*** If you have already installed a sufficiently new version, this error\n");
322 printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
323 printf("*** being found. The easiest way to fix this is to remove the old version\n");
324 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
325 printf("*** correct copy of xml2-config. (In this case, you will have to\n");
326 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
327 printf("*** so that the correct libraries are found at run-time))\n");
331 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
332 CFLAGS="$ac_save_CFLAGS"
333 CXXFLAGS="$ac_save_CXXFLAGS"
338 if test "x$no_xml" = x ; then
339 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
340 ifelse([$2], , :, [$2])
343 if test "$XML2_CONFIG" = "no" ; then
344 echo "*** The xml2-config script installed by LIBXML could not be found"
345 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
346 echo "*** your path, or set the XML2_CONFIG environment variable to the"
347 echo "*** full path to xml2-config."
349 if test -f conf.xmltest ; then
352 echo "*** Could not run libxml test program, checking why..."
353 CFLAGS="$CFLAGS $XML_CFLAGS"
354 CXXFLAGS="$CXXFLAGS $XML_CFLAGS"
355 LIBS="$LIBS $XML_LIBS"
357 #include <libxml/xmlversion.h>
359 ], [ LIBXML_TEST_VERSION; return 0;],
360 [ echo "*** The test program compiled, but did not run. This usually means"
361 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
362 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
363 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
364 echo "*** to the installed location Also, make sure you have run ldconfig if that"
365 echo "*** is required on your system"
367 echo "*** If you have an old version installed, it is best to remove it, although"
368 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
369 [ echo "*** The test program failed to compile or link. See the file config.log for the"
370 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
371 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
372 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
373 CFLAGS="$ac_save_CFLAGS"
374 CXXFLAGS="$ac_save_CXXFLAGS"
384 ifelse([$3], , :, [$3])