blob: 1a03d5708512fc6ecd8c73a860794e048c463ed3 [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>
45#include <glib.h>
46#include <parser.h>
47
48int
49main()
50{
51 int major, minor, micro;
52 char *tmp_version;
53
54 system("touch conf.xmltest");
55
56 tmp_version = g_strdup("$min_xml_version");
57 if(sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
58 printf("%s, bad version string\n", "$min_xml_version");
59 exit(1);
60 }
61
62 return 0; /* FIXME */
63#if 0 /* FIXME */
64 if((xml_major_version != $xml_config_major_version) ||
65 (xml_minor_version != $xml_config_minor_version) ||
66 (xml_micro_version != $xml_config_micro_version))
67 {
68 printf("\n*** 'xml-config --version' returned %d.%d.%d, but libxml (%d.%d.%d)\n",
69 $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version,
70 xml_major_version, xml_minor_version, xml_micro_version);
71 printf("*** was found! If xml-config was correct, then it is best\n");
72 printf("*** to remove the old version of libxml. You may also be able to fix the error\n");
73 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
74 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
75 printf("*** required on your system.\n");
76 printf("*** If xml-config was wrong, set the environment variable XML_CONFIG\n");
77 printf("*** to point to the correct copy of xml-config, and remove the file config.cache\n");
78 printf("*** before re-running configure\n");
79 }
80 else
81 {
82 if ((xml_major_version > major) ||
83 ((xml_major_version == major) && (xml_minor_version > minor)) ||
84 ((xml_major_version == major) && (xml_minor_version == minor) &&
85 (xml_micro_version >= micro)))
86 {
87 return 0;
88 }
89 else
90 {
91 printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
92 xml_major_version, xml_minor_version, xml_micro_version);
93 printf("*** You need a version of libxml newer than %d.%d.%d. The latest version of\n",
94 major, minor, micro);
95 printf("*** libxml is always available from ftp://ftp.gnome.org.\n");
96 printf("***\n");
97 printf("*** If you have already installed a sufficiently new version, this error\n");
98 printf("*** probably means that the wrong copy of the xml-config shell script is\n");
99 printf("*** being found. The easiest way to fix this is to remove the old version\n");
100 printf("*** of libxml, but you can also set the XML_CONFIG environment to point to the\n");
101 printf("*** correct copy of xml-config. (In this case, you will have to\n");
102 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
103 printf("*** so that the correct libraries are found at run-time))\n");
104 }
105 }
106#endif
107 return 1;
108}
109],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
110
111 CFLAGS="$ac_save_CFLAGS"
112 LIBS="$ac_save_LIBS"
113 fi
114 fi
115
116 if test "x$no_xml" = x ; then
117 AC_MSG_RESULT(yes)
118 ifelse([$2], , :, [$2])
119 else
120 AC_MSG_RESULT(no)
121 if test "$XML_CONFIG" = "no" ; then
122 echo "*** The xml-config script installed by libxml could not be found"
123 echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
124 echo "*** your path, or set the XML_CONFIG environment variable to the"
125 echo "*** full path to xml-config."
126 else
127 if test -f conf.xmltest ; then
128 :
129 else
130 echo "*** Could not run libxml test program, checking why..."
131 CFLAGS="$CFLAGS $XML_CFLAGS"
132 LIBS="$LIBS $XML_LIBS"
133 dnl FIXME: AC_TRY_LINK
134 fi
135 fi
136
137 XML_CFLAGS=""
138 XML_LIBS=""
139 ifelse([$3], , :, [$3])
140 fi
141 AC_SUBST(XML_CFLAGS)
142 AC_SUBST(XML_LIBS)
143 rm -f conf.xmltest
144])