Merge remote-tracking branch 'github/pr/2627'
[gentoo.git] / dev-libs / libxslt / libxslt-1.1.28-r5.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python2_7 )
8 PYTHON_REQ_USE="xml"
9
10 inherit autotools eutils python-r1 toolchain-funcs multilib-minimal
11
12 DESCRIPTION="XSLT libraries and tools"
13 HOMEPAGE="http://www.xmlsoft.org/"
14 SRC_URI="ftp://xmlsoft.org/${PN}/${P}.tar.gz"
15
16 LICENSE="MIT"
17 SLOT="0"
18 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
19 IUSE="crypt debug examples python static-libs"
20
21 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
22
23 RDEPEND="
24         >=dev-libs/libxml2-2.9.1-r5:2[${MULTILIB_USEDEP}]
25         crypt?  ( >=dev-libs/libgcrypt-1.5.3:0=[${MULTILIB_USEDEP}] )
26         python? (
27                 ${PYTHON_DEPS}
28                 dev-libs/libxml2:2[python,${PYTHON_USEDEP}] )
29         abi_x86_32? (
30                 !<=app-emulation/emul-linux-x86-baselibs-20131008-r20
31                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
32         )
33 "
34 DEPEND="${RDEPEND}"
35
36 MULTILIB_CHOST_TOOLS=(
37         /usr/bin/xslt-config
38 )
39
40 src_prepare() {
41         DOCS=( AUTHORS ChangeLog FEATURES NEWS README TODO )
42
43         # https://bugzilla.gnome.org/show_bug.cgi?id=684621
44         epatch "${FILESDIR}"/${PN}.m4-${PN}-1.1.26.patch
45
46         # use AC_PATH_TOOL for libgcrypt-config for sane cross-compile and multilib support
47         # https://bugzilla.gnome.org/show_bug.cgi?id=725635
48         # same for xml2-config
49         # https://bugs.gentoo.org/show_bug.cgi?id=518728
50         epatch "${FILESDIR}"/${PN}-1.1.28-AC_PATH_TOOL.patch
51
52         # Apply patches from master found in debian
53         epatch \
54                 "${FILESDIR}"/${PN}-1.1.28-broken-fprintf-parameters.patch \
55                 "${FILESDIR}"/${PN}-1.1.28-exslt-str-replace.patch \
56                 "${FILESDIR}"/${PN}-1.1.28-fix-quoting-xlocale.patch \
57                 "${FILESDIR}"/${PN}-1.1.28-seed-pseudo-random-generator.patch
58
59         # Fix null pointer dereference, from master
60         # https://bugs.gentoo.org/show_bug.cgi?id=558822
61         epatch "${FILESDIR}"/${PN}-1.1.28-attribute-type-preprocessing.patch
62
63         # Simplify python setup
64         epatch "${FILESDIR}"/${PN}-1.1.28-simplify-python.patch
65         epatch "${FILESDIR}"/${PN}-1.1.28-disable-static-modules.patch
66
67         mv configure.{in,ac} || die
68
69         eautoreconf
70         # If eautoreconf'd with new autoconf, then epunt_cxx is not necessary
71         # and it is propably otherwise too if upstream generated with new
72         # autoconf
73 #       epunt_cxx
74         # But Prefix always needs elibtoolize if not eautoreconf'd.
75 #       elibtoolize
76 }
77
78 multilib_src_configure() {
79         libxslt_configure() {
80                 ECONF_SOURCE="${S}" econf \
81                         --with-html-dir="${EPREFIX}"/usr/share/doc/${PF} \
82                         --with-html-subdir=html \
83                         $(use_with crypt crypto) \
84                         $(use_with debug) \
85                         $(use_with debug mem-debug) \
86                         $(use_enable static-libs static) \
87                         "$@"
88         }
89
90         libxslt_py_configure() {
91                 mkdir -p "${BUILD_DIR}" || die # ensure python build dirs exist
92                 run_in_build_dir libxslt_configure --with-python
93         }
94
95         libxslt_configure --without-python # build python bindings separately
96
97         if multilib_is_native_abi && use python; then
98                 python_foreach_impl libxslt_py_configure
99         fi
100 }
101
102 multilib_src_compile() {
103         default
104         multilib_is_native_abi && use python && libxslt_foreach_py_emake all
105 }
106
107 multilib_src_test() {
108         default
109         multilib_is_native_abi && use python && libxslt_foreach_py_emake test
110 }
111
112 multilib_src_install() {
113         # "default" does not work here - docs are installed by multilib_src_install_all
114         emake DESTDIR="${D}" install
115
116         if multilib_is_native_abi && use python; then
117                 libxslt_foreach_py_emake \
118                         DESTDIR="${D}" \
119                         docsdir="${EPREFIX}"/usr/share/doc/${PF}/python \
120                         EXAMPLE_DIR="${EPREFIX}"/usr/share/doc/${PF}/python/examples \
121                         install
122                 python_foreach_impl python_optimize
123         fi
124 }
125
126 multilib_src_install_all() {
127         einstalldocs
128
129         if ! use examples; then
130                 rm -rf "${ED}"/usr/share/doc/${PF}/examples
131                 rm -rf "${ED}"/usr/share/doc/${PF}/python/examples
132         fi
133
134         prune_libtool_files --modules
135 }
136
137 libxslt_foreach_py_emake() {
138         libxslt_py_emake() {
139                 pushd "${BUILD_DIR}/python" > /dev/null || die
140                 emake "$@"
141                 popd > /dev/null
142         }
143         local native_builddir=${BUILD_DIR}
144         python_foreach_impl libxslt_py_emake top_builddir="${native_builddir}" "$@"
145 }