dev-libs/libxml2: bump to 2.9.9
[gentoo.git] / dev-libs / libxml2 / libxml2-2.9.9.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python2_7 python3_{4,5,6,7} )
6 PYTHON_REQ_USE="xml"
7
8 inherit libtool flag-o-matic ltprune python-r1 autotools prefix multilib-minimal
9
10 DESCRIPTION="XML C parser and toolkit"
11 HOMEPAGE="http://www.xmlsoft.org/"
12
13 LICENSE="MIT"
14 SLOT="2"
15 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
16 IUSE="debug examples icu ipv6 lzma python readline static-libs test"
17 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
18
19 XSTS_HOME="http://www.w3.org/XML/2004/xml-schema-test-suite"
20 XSTS_NAME_1="xmlschema2002-01-16"
21 XSTS_NAME_2="xmlschema2004-01-14"
22 XSTS_TARBALL_1="xsts-2002-01-16.tar.gz"
23 XSTS_TARBALL_2="xsts-2004-01-14.tar.gz"
24 XMLCONF_TARBALL="xmlts20080827.tar.gz"
25
26 SRC_URI="ftp://xmlsoft.org/${PN}/${PN}-${PV/_rc/-rc}.tar.gz
27         test? (
28                 ${XSTS_HOME}/${XSTS_NAME_1}/${XSTS_TARBALL_1}
29                 ${XSTS_HOME}/${XSTS_NAME_2}/${XSTS_TARBALL_2}
30                 http://www.w3.org/XML/Test/${XMLCONF_TARBALL} )"
31
32 RDEPEND="
33         >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}]
34         icu? ( >=dev-libs/icu-51.2-r1:=[${MULTILIB_USEDEP}] )
35         lzma? ( >=app-arch/xz-utils-5.0.5-r1:=[${MULTILIB_USEDEP}] )
36         python? ( ${PYTHON_DEPS} )
37         readline? ( sys-libs/readline:= )
38 "
39 DEPEND="${RDEPEND}
40         dev-util/gtk-doc-am
41         virtual/pkgconfig
42         hppa? ( >=sys-devel/binutils-2.15.92.0.2 )
43 "
44
45 S="${WORKDIR}/${PN}-${PV%_rc*}"
46
47 MULTILIB_CHOST_TOOLS=(
48         /usr/bin/xml2-config
49 )
50
51 src_unpack() {
52         # ${A} isn't used to avoid unpacking of test tarballs into $WORKDIR,
53         # as they are needed as tarballs in ${S}/xstc instead and not unpacked
54         unpack ${P/_rc/-rc}.tar.gz
55         cd "${S}" || die
56
57         if use test; then
58                 cp "${DISTDIR}/${XSTS_TARBALL_1}" \
59                         "${DISTDIR}/${XSTS_TARBALL_2}" \
60                         "${S}"/xstc/ \
61                         || die "Failed to install test tarballs"
62                 unpack ${XMLCONF_TARBALL}
63         fi
64 }
65
66 src_prepare() {
67         default
68
69         DOCS=( AUTHORS ChangeLog NEWS README* TODO* )
70
71         # Patches needed for prefix support
72         eapply "${FILESDIR}"/${PN}-2.7.1-catalog_path.patch
73
74         eprefixify catalog.c xmlcatalog.c runtest.c xmllint.c
75
76         # Fix build for Windows platform
77         # https://bugzilla.gnome.org/show_bug.cgi?id=760456
78         # eapply "${FILESDIR}"/${PN}-2.8.0_rc1-winnt.patch
79
80         # Fix python detection, bug #567066
81         # https://bugzilla.gnome.org/show_bug.cgi?id=760458
82         eapply "${FILESDIR}"/${PN}-2.9.2-python-ABIFLAG.patch
83
84         # Fix python tests when building out of tree #565576
85         eapply "${FILESDIR}"/${PN}-2.9.8-out-of-tree-test.patch
86
87         if [[ ${CHOST} == *-darwin* ]] ; then
88                 # Avoid final linking arguments for python modules
89                 sed -i -e '/PYTHON_LIBS/s/ldflags/libs/' configure.ac || die
90                 # gcc-apple doesn't grok -Wno-array-bounds
91                 sed -i -e 's/-Wno-array-bounds//' configure.ac || die
92         fi
93
94         # Please do not remove, as else we get references to PORTAGE_TMPDIR
95         # in /usr/lib/python?.?/site-packages/libxml2mod.la among things.
96         # We now need to run eautoreconf at the end to prevent maintainer mode.
97 #       elibtoolize
98 #       epunt_cxx # if we don't eautoreconf
99
100         eautoreconf
101 }
102
103 multilib_src_configure() {
104         # filter seemingly problematic CFLAGS (#26320)
105         filter-flags -fprefetch-loop-arrays -funroll-loops
106
107         # USE zlib support breaks gnome2
108         # (libgnomeprint for instance fails to compile with
109         # fresh install, and existing) - <azarah@gentoo.org> (22 Dec 2002).
110
111         # The meaning of the 'debug' USE flag does not apply to the --with-debug
112         # switch (enabling the libxml2 debug module). See bug #100898.
113
114         # --with-mem-debug causes unusual segmentation faults (bug #105120).
115
116         libxml2_configure() {
117                 ECONF_SOURCE="${S}" econf \
118                         --with-html-subdir=${PF}/html \
119                         $(use_with debug run-debug) \
120                         $(use_with icu) \
121                         $(use_with lzma) \
122                         $(use_enable ipv6) \
123                         $(use_enable static-libs static) \
124                         $(multilib_native_use_with readline) \
125                         $(multilib_native_use_with readline history) \
126                         "$@"
127         }
128
129         libxml2_py_configure() {
130                 mkdir -p "${BUILD_DIR}" || die # ensure python build dirs exist
131                 run_in_build_dir libxml2_configure "--with-python=${ROOT%/}${PYTHON}" # odd build system, also see bug #582130
132         }
133
134         libxml2_configure --without-python # build python bindings separately
135
136         if multilib_is_native_abi && use python; then
137                 python_foreach_impl libxml2_py_configure
138         fi
139 }
140
141 multilib_src_compile() {
142         default
143         if multilib_is_native_abi && use python; then
144                 local native_builddir=${BUILD_DIR}
145                 python_foreach_impl libxml2_py_emake top_builddir="${native_builddir}" all
146         fi
147 }
148
149 multilib_src_test() {
150         emake check
151         multilib_is_native_abi && use python && python_foreach_impl libxml2_py_emake test
152 }
153
154 multilib_src_install() {
155         emake DESTDIR="${D}" \
156                 EXAMPLES_DIR="${EPREFIX}"/usr/share/doc/${PF}/examples install
157
158         if multilib_is_native_abi && use python; then
159                 python_foreach_impl libxml2_py_emake \
160                         DESTDIR="${D}" \
161                         docsdir="${EPREFIX}"/usr/share/doc/${PF}/python \
162                         exampledir="${EPREFIX}"/usr/share/doc/${PF}/python/examples \
163                         install
164                 python_foreach_impl python_optimize
165         fi
166 }
167
168 multilib_src_install_all() {
169         # on windows, xmllint is installed by interix libxml2 in parent prefix.
170         # this is the version to use. the native winnt version does not support
171         # symlinks, which makes repoman fail if the portage tree is linked in
172         # from another location (which is my default). -- mduft
173         if [[ ${CHOST} == *-winnt* ]]; then
174                 rm -rf "${ED}"/usr/bin/xmllint
175                 rm -rf "${ED}"/usr/bin/xmlcatalog
176         fi
177
178         rm -rf "${ED}"/usr/share/doc/${P}
179         einstalldocs
180
181         if ! use examples; then
182                 rm -rf "${ED}"/usr/share/doc/${PF}/examples
183                 rm -rf "${ED}"/usr/share/doc/${PF}/python/examples
184         fi
185
186         prune_libtool_files --modules
187 }
188
189 pkg_postinst() {
190         # We don't want to do the xmlcatalog during stage1, as xmlcatalog will not
191         # be in / and stage1 builds to ROOT=/tmp/stage1root. This fixes bug #208887.
192         if [[ "${ROOT}" != "/" ]]; then
193                 elog "Skipping XML catalog creation for stage building (bug #208887)."
194         else
195                 # need an XML catalog, so no-one writes to a non-existent one
196                 CATALOG="${EROOT}etc/xml/catalog"
197
198                 # we dont want to clobber an existing catalog though,
199                 # only ensure that one is there
200                 # <obz@gentoo.org>
201                 if [[ ! -e ${CATALOG} ]]; then
202                         [[ -d "${EROOT}etc/xml" ]] || mkdir -p "${EROOT}etc/xml"
203                         "${EPREFIX}"/usr/bin/xmlcatalog --create > "${CATALOG}"
204                         einfo "Created XML catalog in ${CATALOG}"
205                 fi
206         fi
207 }
208
209 libxml2_py_emake() {
210         pushd "${BUILD_DIR}/python" > /dev/null || die
211         emake "$@"
212         popd > /dev/null
213 }