Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 1 | # Configure paths for LIBXML2 |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 2 | # Mike Hommey 2004-06-19 |
| 3 | # use CPPFLAGS instead of CFLAGS |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 4 | # Toshio Kuratomi 2001-04-21 |
| 5 | # Adapted from: |
| 6 | # Configure paths for GLIB |
| 7 | # Owen Taylor 97-11-3 |
| 8 | |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 9 | dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 10 | dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 11 | dnl |
Daniel Veillard | cc199e0 | 2003-10-24 21:11:48 +0000 | [diff] [blame] | 12 | AC_DEFUN([AM_PATH_XML2],[ |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 13 | AC_ARG_WITH(xml-prefix, |
| 14 | [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)], |
| 15 | xml_config_prefix="$withval", xml_config_prefix="") |
| 16 | AC_ARG_WITH(xml-exec-prefix, |
| 17 | [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)], |
| 18 | xml_config_exec_prefix="$withval", xml_config_exec_prefix="") |
| 19 | AC_ARG_ENABLE(xmltest, |
| 20 | [ --disable-xmltest Do not try to compile and run a test LIBXML program],, |
| 21 | enable_xmltest=yes) |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 22 | |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 23 | if test x$xml_config_exec_prefix != x ; then |
Daniel Veillard | 3df0118 | 2003-12-10 10:17:51 +0000 | [diff] [blame] | 24 | xml_config_args="$xml_config_args" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 25 | if test x${XML2_CONFIG+set} != xset ; then |
| 26 | XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 27 | fi |
| 28 | fi |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 29 | if test x$xml_config_prefix != x ; then |
| 30 | xml_config_args="$xml_config_args --prefix=$xml_config_prefix" |
| 31 | if test x${XML2_CONFIG+set} != xset ; then |
| 32 | XML2_CONFIG=$xml_config_prefix/bin/xml2-config |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 33 | fi |
| 34 | fi |
| 35 | |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 36 | AC_PATH_PROG(XML2_CONFIG, xml2-config, no) |
| 37 | min_xml_version=ifelse([$1], ,2.0.0,[$1]) |
| 38 | AC_MSG_CHECKING(for libxml - version >= $min_xml_version) |
| 39 | no_xml="" |
| 40 | if test "$XML2_CONFIG" = "no" ; then |
| 41 | no_xml=yes |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 42 | else |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 43 | XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags` |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 44 | XML_LIBS=`$XML2_CONFIG $xml_config_args --libs` |
| 45 | xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \ |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 46 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 47 | xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \ |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 48 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 49 | xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \ |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 50 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 51 | if test "x$enable_xmltest" = "xyes" ; then |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 52 | ac_save_CPPFLAGS="$CPPFLAGS" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 53 | ac_save_LIBS="$LIBS" |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 54 | CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 55 | LIBS="$XML_LIBS $LIBS" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 56 | dnl |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 57 | dnl Now check if the installed libxml is sufficiently new. |
| 58 | dnl (Also sanity checks the results of xml2-config to some extent) |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 59 | dnl |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 60 | rm -f conf.xmltest |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 61 | AC_TRY_RUN([ |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 62 | #include <stdlib.h> |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 63 | #include <stdio.h> |
Daniel Veillard | 88e0ad4 | 2002-04-09 13:48:02 +0000 | [diff] [blame] | 64 | #include <string.h> |
Daniel Veillard | e979e3b | 2002-03-29 22:43:00 +0000 | [diff] [blame] | 65 | #include <libxml/xmlversion.h> |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 66 | |
| 67 | int |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 68 | main() |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 69 | { |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 70 | int xml_major_version, xml_minor_version, xml_micro_version; |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 71 | int major, minor, micro; |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 72 | char *tmp_version; |
| 73 | |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 74 | system("touch conf.xmltest"); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 75 | |
| 76 | /* Capture xml2-config output via autoconf/configure variables */ |
| 77 | /* HP/UX 9 (%@#!) writes to sscanf strings */ |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 78 | tmp_version = (char *)strdup("$min_xml_version"); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 79 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 80 | printf("%s, bad version string from xml2-config\n", "$min_xml_version"); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 81 | exit(1); |
| 82 | } |
| 83 | free(tmp_version); |
| 84 | |
| 85 | /* Capture the version information from the header files */ |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 86 | tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION); |
| 87 | if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) { |
| 88 | printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION"); |
| 89 | exit(1); |
| 90 | } |
| 91 | free(tmp_version); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 92 | |
| 93 | /* Compare xml2-config output to the libxml headers */ |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 94 | if ((xml_major_version != $xml_config_major_version) || |
| 95 | (xml_minor_version != $xml_config_minor_version) || |
| 96 | (xml_micro_version != $xml_config_micro_version)) |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 97 | { |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 98 | printf("*** libxml header files (version %d.%d.%d) do not match\n", |
| 99 | xml_major_version, xml_minor_version, xml_micro_version); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 100 | printf("*** xml2-config (version %d.%d.%d)\n", |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 101 | $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 102 | return 1; |
| 103 | } |
| 104 | /* Compare the headers to the library to make sure we match */ |
| 105 | /* Less than ideal -- doesn't provide us with return value feedback, |
| 106 | * only exits if there's a serious mismatch between header and library. |
| 107 | */ |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 108 | LIBXML_TEST_VERSION; |
| 109 | |
| 110 | /* Test that the library is greater than our minimum version */ |
| 111 | if ((xml_major_version > major) || |
| 112 | ((xml_major_version == major) && (xml_minor_version > minor)) || |
| 113 | ((xml_major_version == major) && (xml_minor_version == minor) && |
| 114 | (xml_micro_version >= micro))) |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | else |
| 119 | { |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 120 | printf("\n*** An old version of libxml (%d.%d.%d) was found.\n", |
| 121 | xml_major_version, xml_minor_version, xml_micro_version); |
| 122 | printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n", |
| 123 | major, minor, micro); |
| 124 | printf("*** libxml is always available from ftp://ftp.xmlsoft.org.\n"); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 125 | printf("***\n"); |
| 126 | printf("*** If you have already installed a sufficiently new version, this error\n"); |
| 127 | printf("*** probably means that the wrong copy of the xml2-config shell script is\n"); |
| 128 | printf("*** being found. The easiest way to fix this is to remove the old version\n"); |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 129 | printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n"); |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 130 | printf("*** correct copy of xml2-config. (In this case, you will have to\n"); |
| 131 | printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); |
| 132 | printf("*** so that the correct libraries are found at run-time))\n"); |
| 133 | } |
| 134 | return 1; |
| 135 | } |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 136 | ],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 137 | CPPFLAGS="$ac_save_CPPFLAGS" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 138 | LIBS="$ac_save_LIBS" |
| 139 | fi |
| 140 | fi |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 141 | |
| 142 | if test "x$no_xml" = x ; then |
| 143 | AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version)) |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 144 | ifelse([$2], , :, [$2]) |
| 145 | else |
| 146 | AC_MSG_RESULT(no) |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 147 | if test "$XML2_CONFIG" = "no" ; then |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 148 | echo "*** The xml2-config script installed by LIBXML could not be found" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 149 | echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in" |
| 150 | echo "*** your path, or set the XML2_CONFIG environment variable to the" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 151 | echo "*** full path to xml2-config." |
| 152 | else |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 153 | if test -f conf.xmltest ; then |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 154 | : |
| 155 | else |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 156 | echo "*** Could not run libxml test program, checking why..." |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 157 | CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 158 | LIBS="$LIBS $XML_LIBS" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 159 | AC_TRY_LINK([ |
Daniel Veillard | e979e3b | 2002-03-29 22:43:00 +0000 | [diff] [blame] | 160 | #include <libxml/xmlversion.h> |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 161 | #include <stdio.h> |
| 162 | ], [ LIBXML_TEST_VERSION; return 0;], |
| 163 | [ echo "*** The test program compiled, but did not run. This usually means" |
| 164 | echo "*** that the run-time linker is not finding LIBXML or finding the wrong" |
| 165 | echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your" |
| 166 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
| 167 | echo "*** to the installed location Also, make sure you have run ldconfig if that" |
| 168 | echo "*** is required on your system" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 169 | echo "***" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 170 | echo "*** If you have an old version installed, it is best to remove it, although" |
| 171 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], |
| 172 | [ echo "*** The test program failed to compile or link. See the file config.log for the" |
| 173 | echo "*** exact error that occured. This usually means LIBXML was incorrectly installed" |
| 174 | echo "*** or that you have moved LIBXML since it was installed. In the latter case, you" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 175 | echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ]) |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 176 | CPPFLAGS="$ac_save_CPPFLAGS" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 177 | LIBS="$ac_save_LIBS" |
| 178 | fi |
| 179 | fi |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 180 | |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 181 | XML_CPPFLAGS="" |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 182 | XML_LIBS="" |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 183 | ifelse([$3], , :, [$3]) |
| 184 | fi |
Daniel Veillard | b7cbbae | 2004-06-28 09:27:23 +0000 | [diff] [blame] | 185 | AC_SUBST(XML_CPPFLAGS) |
Daniel Veillard | 2913e4c | 2001-04-26 19:29:02 +0000 | [diff] [blame] | 186 | AC_SUBST(XML_LIBS) |
| 187 | rm -f conf.xmltest |
Daniel Veillard | 5c4ec4c | 2001-04-26 07:43:59 +0000 | [diff] [blame] | 188 | ]) |