blob: 639c80bd6ceab1dec2ad5ee646664d67f30911d7 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001Change the AM_PATH_XML2 macros to use pkg-config instead of xml2-config.
William A. Kennington IIIac69b482021-06-02 12:28:27 -07002
Andrew Geissler517393d2023-01-13 08:55:19 -06003Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/-/commit/d598d8af0913b6e3d4e61ffa62397a275b669dca]
4Signed-off-by: Ross Burton <ross.burton@arm.com>
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005
Andrew Geisslerd5838332022-05-27 11:33:10 -05006 libxml.m4 | 189 ++----------------------------------------------------
7 1 file changed, 5 insertions(+), 184 deletions(-)
8
9diff --git a/libxml.m4 b/libxml.m4
10index fc7790c..1c53585 100644
11--- a/libxml.m4
12+++ b/libxml.m4
Andrew Geissler9aee5002022-03-30 16:27:02 +000013@@ -1,191 +1,12 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014-# Configure paths for LIBXML2
William A. Kennington IIIac69b482021-06-02 12:28:27 -070015-# Simon Josefsson 2020-02-12
16-# Fix autoconf 2.70+ warnings
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017-# Mike Hommey 2004-06-19
18-# use CPPFLAGS instead of CFLAGS
19-# Toshio Kuratomi 2001-04-21
20-# Adapted from:
21-# Configure paths for GLIB
22-# Owen Taylor 97-11-3
23-
24 dnl AM_PATH_XML2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
25 dnl Test for XML, and define XML_CPPFLAGS and XML_LIBS
26 dnl
27-AC_DEFUN([AM_PATH_XML2],[
28-AC_ARG_WITH(xml-prefix,
29- [ --with-xml-prefix=PFX Prefix where libxml is installed (optional)],
30- xml_config_prefix="$withval", xml_config_prefix="")
31-AC_ARG_WITH(xml-exec-prefix,
32- [ --with-xml-exec-prefix=PFX Exec prefix where libxml is installed (optional)],
33- xml_config_exec_prefix="$withval", xml_config_exec_prefix="")
34-AC_ARG_ENABLE(xmltest,
35- [ --disable-xmltest Do not try to compile and run a test LIBXML program],,
36- enable_xmltest=yes)
37-
38- if test x$xml_config_exec_prefix != x ; then
39- xml_config_args="$xml_config_args"
40- if test x${XML2_CONFIG+set} != xset ; then
41- XML2_CONFIG=$xml_config_exec_prefix/bin/xml2-config
42- fi
43- fi
44- if test x$xml_config_prefix != x ; then
45- xml_config_args="$xml_config_args --prefix=$xml_config_prefix"
46- if test x${XML2_CONFIG+set} != xset ; then
47- XML2_CONFIG=$xml_config_prefix/bin/xml2-config
48- fi
49- fi
50-
51- AC_PATH_PROG(XML2_CONFIG, xml2-config, no)
52- min_xml_version=ifelse([$1], ,2.0.0,[$1])
53- AC_MSG_CHECKING(for libxml - version >= $min_xml_version)
54- no_xml=""
55- if test "$XML2_CONFIG" = "no" ; then
56- no_xml=yes
57- else
58- XML_CPPFLAGS=`$XML2_CONFIG $xml_config_args --cflags`
59- XML_LIBS=`$XML2_CONFIG $xml_config_args --libs`
60- xml_config_major_version=`$XML2_CONFIG $xml_config_args --version | \
61- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
62- xml_config_minor_version=`$XML2_CONFIG $xml_config_args --version | \
63- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
64- xml_config_micro_version=`$XML2_CONFIG $xml_config_args --version | \
65- sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
66- if test "x$enable_xmltest" = "xyes" ; then
67- ac_save_CPPFLAGS="$CPPFLAGS"
68- ac_save_LIBS="$LIBS"
69- CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
70- LIBS="$XML_LIBS $LIBS"
71-dnl
72-dnl Now check if the installed libxml is sufficiently new.
73-dnl (Also sanity checks the results of xml2-config to some extent)
74-dnl
75- rm -f conf.xmltest
William A. Kennington IIIac69b482021-06-02 12:28:27 -070076- AC_RUN_IFELSE(
77- [AC_LANG_SOURCE([[
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078-#include <stdlib.h>
79-#include <stdio.h>
80-#include <string.h>
81-#include <libxml/xmlversion.h>
82-
83-int
84-main()
85-{
86- int xml_major_version, xml_minor_version, xml_micro_version;
87- int major, minor, micro;
88- char *tmp_version;
89-
90- system("touch conf.xmltest");
91-
92- /* Capture xml2-config output via autoconf/configure variables */
93- /* HP/UX 9 (%@#!) writes to sscanf strings */
94- tmp_version = (char *)strdup("$min_xml_version");
95- if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
96- printf("%s, bad version string from xml2-config\n", "$min_xml_version");
97- exit(1);
98- }
99- free(tmp_version);
100-
101- /* Capture the version information from the header files */
102- tmp_version = (char *)strdup(LIBXML_DOTTED_VERSION);
103- if (sscanf(tmp_version, "%d.%d.%d", &xml_major_version, &xml_minor_version, &xml_micro_version) != 3) {
104- printf("%s, bad version string from libxml includes\n", "LIBXML_DOTTED_VERSION");
105- exit(1);
106- }
107- free(tmp_version);
108-
109- /* Compare xml2-config output to the libxml headers */
110- if ((xml_major_version != $xml_config_major_version) ||
111- (xml_minor_version != $xml_config_minor_version) ||
112- (xml_micro_version != $xml_config_micro_version))
113- {
114- printf("*** libxml header files (version %d.%d.%d) do not match\n",
115- xml_major_version, xml_minor_version, xml_micro_version);
116- printf("*** xml2-config (version %d.%d.%d)\n",
117- $xml_config_major_version, $xml_config_minor_version, $xml_config_micro_version);
118- return 1;
119- }
120-/* Compare the headers to the library to make sure we match */
121- /* Less than ideal -- doesn't provide us with return value feedback,
122- * only exits if there's a serious mismatch between header and library.
123- */
124- LIBXML_TEST_VERSION;
125-
126- /* Test that the library is greater than our minimum version */
127- if ((xml_major_version > major) ||
128- ((xml_major_version == major) && (xml_minor_version > minor)) ||
129- ((xml_major_version == major) && (xml_minor_version == minor) &&
130- (xml_micro_version >= micro)))
131- {
132- return 0;
133- }
134- else
135- {
136- printf("\n*** An old version of libxml (%d.%d.%d) was found.\n",
137- xml_major_version, xml_minor_version, xml_micro_version);
Andrew Geissler9aee5002022-03-30 16:27:02 +0000138- printf("*** You need a version of libxml newer than %d.%d.%d.\n",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139- major, minor, micro);
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140- printf("***\n");
141- printf("*** If you have already installed a sufficiently new version, this error\n");
142- printf("*** probably means that the wrong copy of the xml2-config shell script is\n");
143- printf("*** being found. The easiest way to fix this is to remove the old version\n");
144- printf("*** of LIBXML, but you can also set the XML2_CONFIG environment to point to the\n");
145- printf("*** correct copy of xml2-config. (In this case, you will have to\n");
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700146- printf("*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf\n");
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147- printf("*** so that the correct libraries are found at run-time))\n");
148- }
149- return 1;
150-}
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700151-]])],, no_xml=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500152- CPPFLAGS="$ac_save_CPPFLAGS"
153- LIBS="$ac_save_LIBS"
154- fi
155- fi
156+AC_DEFUN([AM_PATH_XML2],[
157+ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
158
159- if test "x$no_xml" = x ; then
160- AC_MSG_RESULT(yes (version $xml_config_major_version.$xml_config_minor_version.$xml_config_micro_version))
161- ifelse([$2], , :, [$2])
162- else
163- AC_MSG_RESULT(no)
164- if test "$XML2_CONFIG" = "no" ; then
165- echo "*** The xml2-config script installed by LIBXML could not be found"
166- echo "*** If libxml was installed in PREFIX, make sure PREFIX/bin is in"
167- echo "*** your path, or set the XML2_CONFIG environment variable to the"
168- echo "*** full path to xml2-config."
169- else
170- if test -f conf.xmltest ; then
171- :
172- else
173- echo "*** Could not run libxml test program, checking why..."
174- CPPFLAGS="$CPPFLAGS $XML_CPPFLAGS"
175- LIBS="$LIBS $XML_LIBS"
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700176- AC_LINK_IFELSE(
177- [AC_LANG_PROGRAM([[
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178-#include <libxml/xmlversion.h>
179-#include <stdio.h>
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700180-]], [[ LIBXML_TEST_VERSION; return 0;]])],
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181- [ echo "*** The test program compiled, but did not run. This usually means"
182- echo "*** that the run-time linker is not finding LIBXML or finding the wrong"
183- echo "*** version of LIBXML. If it is not finding LIBXML, you'll need to set your"
184- echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
185- echo "*** to the installed location Also, make sure you have run ldconfig if that"
186- echo "*** is required on your system"
187- echo "***"
188- echo "*** If you have an old version installed, it is best to remove it, although"
189- echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
190- [ echo "*** The test program failed to compile or link. See the file config.log for the"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400191- echo "*** exact error that occurred. This usually means LIBXML was incorrectly installed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192- echo "*** or that you have moved LIBXML since it was installed. In the latter case, you"
193- echo "*** may want to edit the xml2-config script: $XML2_CONFIG" ])
194- CPPFLAGS="$ac_save_CPPFLAGS"
195- LIBS="$ac_save_LIBS"
196- fi
197- fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500198+ verdep=ifelse([$1], [], [], [">= $1"])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199+ PKG_CHECK_MODULES(XML, [libxml-2.0 $verdep], [$2], [$3])
200
201- XML_CPPFLAGS=""
202- XML_LIBS=""
203- ifelse([$3], , :, [$3])
204- fi
205+ XML_CPPFLAGS=$XML_CFLAGS
206 AC_SUBST(XML_CPPFLAGS)
207- AC_SUBST(XML_LIBS)
208- rm -f conf.xmltest
209 ])
Andrew Geisslerd5838332022-05-27 11:33:10 -0500210--
2112.34.1
212