Port: Add macro for socket linking on solaris
[lttng-tools.git] / config / libxml.m4
CommitLineData
6c1494fd
JG
1# LICENSE
2#
3# The MIT License (MIT)
4#
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:
11#
12# The above copyright notice and this permission notice shall be included in
13# all copies or substantial portions of the Software.
14#
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
21# THE SOFTWARE.
22#
23# Taken from the libxml2 repository
24#
25# Configure paths for LIBXML2
26# Mike Hommey 2004-06-19
27# use CPPFLAGS instead of CFLAGS
28# Toshio Kuratomi 2001-04-21
29# Adapted from:
30# Configure paths for GLIB
31# Owen Taylor 97-11-3
32
33dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
34dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
35dnl
36AC_DEFUN([AM_PATH_XML2],[
37AC_ARG_WITH(xml-prefix,
38 [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
39 xml_config_prefix="$withval", xml_config_prefix="")
40AC_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="")
43AC_ARG_ENABLE(xmltest,
44 [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
45 enable_xmltest=yes)
46
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
51 fi
52 fi
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
57 fi
58 fi
59
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)
63 no_xml=""
64 if test "$XML2_CONFIG" = "no" ; then
65 no_xml=yes
66 else
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"
77 ac_save_LIBS="$LIBS"
78 CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
79 LIBS="$XML_LIBS $LIBS"
80dnl
81dnl Now check if the installed libxml is sufficiently new.
82dnl (Also sanity checks the results of xml2-config to some extent)
83dnl
84 rm -f conf.xmltest
85 AC_TRY_RUN([
86#include <stdlib.h>
87#include <stdio.h>
88#include <string.h>
89#include <libxml/xmlversion.h>
90
91int
92main()
93{
94 int xml_major_version, xml_minor_version, xml_micro_version;
95 int major, minor, micro;
96 char *tmp_version;
97
98 system("touch conf.xmltest");
99
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, &micro) != 3) {
104 printf("%s, bad version string from xml2-config\n", "$min_xml_version");
105 exit(1);
106 }
107 free(tmp_version);
108
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");
113 exit(1);
114 }
115 free(tmp_version);
116
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))
121 {
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);
126 return 1;
127 }
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.
131 */
132 LIBXML_TEST_VERSION;
133
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)))
139 {
140 return 0;
141 }
142 else
143 {
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");
149 printf("***\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");
157 }
158 return 1;
159}
160],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
161 CPPFLAGS="$ac_save_CPPFLAGS"
162 LIBS="$ac_save_LIBS"
163 fi
164 fi
165
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])
169 else
170 AC_MSG_RESULT(no)
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."
176 else
177 if test -f conf.xmltest ; then
178 :
179 else
180 echo "*** Could not run libxml test program, checking why..."
181 CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
182 LIBS="$LIBS $XML_LIBS"
183 AC_TRY_LINK([
184#include <libxml/xmlversion.h>
185#include <stdio.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"
193 echo "***"
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"
201 LIBS="$ac_save_LIBS"
202 fi
203 fi
204
205 XML_CPPFLAGS=""
206 XML_LIBS=""
207 ifelse([$3], , :, [$3])
208 fi
209 AC_SUBST(XML_CPPFLAGS)
210 AC_SUBST(XML_LIBS)
211 rm -f conf.xmltest
212])
This page took 0.035112 seconds and 5 git commands to generate.