3 # The MIT License (MIT)
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 # Taken from the libxml2 repository
25 # Configure paths for LIBXML2
26 # Mike Hommey 2004-06-19
27 # use CPPFLAGS instead of CFLAGS
28 # Toshio Kuratomi 2001-04-21
30 # Configure paths for GLIB
33 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
34 dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
36 AC_DEFUN([AM_PATH_XML2],[
37 AC_ARG_WITH(xml-prefix,
38 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
39 xml_config_prefix="$withval", xml_config_prefix="")
40 AC_ARG_WITH(xml-exec-prefix,
41 [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
42 xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
43 AC_ARG_ENABLE(xmltest,
44 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
47 if test x$xml_config_exec_prefix != x ; then
48 xml_config_args="$xml_config_args"
49 if test x${XML2_CONFIG+set} != xset ; then
50 XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
53 if test x$xml_config_prefix != x ; then
54 xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
55 if test x${XML2_CONFIG+set} != xset ; then
56 XML2_CONFIG=$xml_config_prefix/bin/xml2-config
60 AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
61 min_xml_version=ifelse([$1], ,2.0.0,[$1])
62 AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
64 if test "$XML2_CONFIG" = "no" ; then
67 XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
68 XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
69 xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
70 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
71 xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
72 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
73 xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
74 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
75 if test "x$enable_xmltest" = "xyes" ; then
76 ac_save_CPPFLAGS="$CPPFLAGS"
78 CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
79 LIBS="$XML_LIBS $LIBS"
81 dnl Now check if the installed libxml is sufficiently new.
82 dnl (Also sanity checks the results of xml2-config to some extent)
89 #include <libxml/xmlversion.h>
94 int xml_major_version, xml_minor_version, xml_micro_version;
95 int major, minor, micro;
98 system("touch conf.xmltest");
100 /* Capture xml2-config output via autoconf/configure variables */
101 /* HP/UX 9 (%@#!) writes to sscanf strings */
102 tmp_version = (char *)strdup("$min_xml_version");
103 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
104 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
109 /* Capture the version information from the header files */
110 tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
111 if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
112 printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
117 /* Compare xml2-config output to the libxml headers */
118 if ((xml_major_version != $xml_config_major_version) ||
119 (xml_minor_version != $xml_config_minor_version) ||
120 (xml_micro_version != $xml_config_micro_version))
122 printf("*** libxml header files (version %d.%d.%d) do not match\n",
123 xml_major_version, xml_minor_version, xml_micro_version);
124 printf("*** xml2-config (version %d.%d.%d)\n",
125 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
128 /* Compare the headers to the library to make sure we match */
129 /* Less than ideal -- doesn't provide us with return value feedback,
130 * only exits if there's a serious mismatch between header and library.
134 /* Test that the library is greater than our minimum version */
135 if ((xml_major_version > major) ||
136 ((xml_major_version == major) && (xml_minor_version > minor)) ||
137 ((xml_major_version == major) && (xml_minor_version == minor) &&
138 (xml_micro_version >= micro)))
144 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
145 xml_major_version, xml_minor_version, xml_micro_version);
146 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
147 major, minor, micro);
148 printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n");
150 printf("*** If you have already installed a sufficiently new version, this error\n");
151 printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
152 printf("*** being found. The easiest way to fix this is to remove the old version\n");
153 printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
154 printf("*** correct copy of xml2-config. (In this case, you will have to\n");
155 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
156 printf("*** so that the correct libraries are found at run-time))\n");
160 ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
161 CPPFLAGS="$ac_save_CPPFLAGS"
166 if test "x$no_xml" = x ; then
167 AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
168 ifelse([$2], , :, [$2])
171 if test "$XML2_CONFIG" = "no" ; then
172 echo "*** The xml2-config script installed by LIBXML could not be found"
173 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
174 echo "*** your path, or set the XML2_CONFIG environment variable to the"
175 echo "*** full path to xml2-config."
177 if test -f conf.xmltest ; then
180 echo "*** Could not run libxml test program, checking why..."
181 CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
182 LIBS="$LIBS $XML_LIBS"
184 #include <libxml/xmlversion.h>
186 ], [ LIBXML_TEST_VERSION; return 0;],
187 [ echo "*** The test program compiled, but did not run. This usually means"
188 echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
189 echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
190 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
191 echo "*** to the installed location Also, make sure you have run ldconfig if that"
192 echo "*** is required on your system"
194 echo "*** If you have an old version installed, it is best to remove it, although"
195 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
196 [ echo "*** The test program failed to compile or link. See the file config.log for the"
197 echo "*** exact error that occured. This usually means LIBXML was incorrectly installed"
198 echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
199 echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
200 CPPFLAGS="$ac_save_CPPFLAGS"
207 ifelse([$3], , :, [$3])
209 AC_SUBST(XML_CPPFLAGS)