3f180c142abbf0a6f149c9ac7168ca9e533e232e
[gentoo.git] / net-libs / neon / neon-0.30.2.ebuild
1 # Copyright 2001-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit autotools libtool multilib-minimal
7
8 DESCRIPTION="HTTP and WebDAV client library"
9 HOMEPAGE="http://webdav.org/neon/"
10 SRC_URI="http://webdav.org/neon/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0/27"
14 KEYWORDS="~alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~ppc-aix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
15 IUSE="doc expat gnutls kerberos libproxy libressl nls pkcs11 ssl static-libs zlib"
16 RESTRICT="test"
17
18 RDEPEND="expat? ( dev-libs/expat:0=[${MULTILIB_USEDEP}] )
19         !expat? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )
20         kerberos? ( virtual/krb5:0=[${MULTILIB_USEDEP}] )
21         libproxy? ( net-libs/libproxy:0=[${MULTILIB_USEDEP}] )
22         nls? ( virtual/libintl:0=[${MULTILIB_USEDEP}] )
23         ssl? (
24                 gnutls? (
25                         app-misc/ca-certificates
26                         net-libs/gnutls:0=[${MULTILIB_USEDEP}]
27                 )
28                 !gnutls? (
29                         libressl? ( dev-libs/libressl:=[${MULTILIB_USEDEP}] )
30                         !libressl? ( dev-libs/openssl:0=[${MULTILIB_USEDEP}] )
31                 )
32                 pkcs11? ( dev-libs/pakchois:0=[${MULTILIB_USEDEP}] )
33         )
34         zlib? ( sys-libs/zlib:0=[${MULTILIB_USEDEP}] )"
35 DEPEND="${RDEPEND}
36         virtual/pkgconfig[${MULTILIB_USEDEP}]"
37
38 MULTILIB_CHOST_TOOLS=(
39         /usr/bin/neon-config
40 )
41
42 src_prepare() {
43         # Use CHOST-prefixed version of xml2-config for cross-compilation.
44         sed -e "s/AC_CHECK_PROG(XML2_CONFIG,/AC_CHECK_TOOL(XML2_CONFIG,/" -i macros/neon-xml-parser.m4 || die "sed failed"
45
46         # Fix compatibility with OpenSSL >=1.1.
47         sed -e "s/RSA_F_RSA_PRIVATE_ENCRYPT/RSA_F_RSA_OSSL_PRIVATE_ENCRYPT/" -i src/ne_pkcs11.c || die "sed failed"
48
49         if has_version "<dev-libs/libressl-3.0.0"; then
50                 # Support LibreSSL.
51                 # Functions RSA_meth_get0_app_data() and RSA_meth_set0_app_data() are not implemented in LibreSSL 2.9.2.
52                 sed -e "1202s/#if OPENSSL_VERSION_NUMBER < 0x10100000L/& || defined(LIBRESSL_VERSION_NUMBER)/" -i src/ne_openssl.c || die "sed failed"
53                 sed -e "97a #if defined(LIBRESSL_VERSION_NUMBER)\nstatic void *RSA_meth_get0_app_data(const RSA_METHOD *meth)\n{\n    return meth->app_data;\n}\nstatic int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)\n{\n    meth->app_data = app_data;\n    return 1;\n}\n#endif" -i src/ne_pkcs11.c || die "sed failed"
54         fi
55
56         eapply_user
57
58         AT_M4DIR="macros" eautoreconf
59
60         elibtoolize
61
62         multilib_copy_sources
63 }
64
65 multilib_src_configure() {
66         local myconf=()
67
68         if has_version sys-libs/glibc; then
69                 einfo "Enabling SSL library thread-safety using POSIX threads..."
70                 myconf+=(--enable-threadsafe-ssl=posix)
71         fi
72
73         if use expat; then
74                 myconf+=(--with-expat)
75         else
76                 myconf+=(--with-libxml2)
77         fi
78
79         if use ssl; then
80                 if use gnutls; then
81                         myconf+=(--with-ssl=gnutls --with-ca-bundle="${EPREFIX}/etc/ssl/certs/ca-certificates.crt")
82                 else
83                         myconf+=(--with-ssl=openssl)
84                 fi
85         fi
86
87         econf \
88                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
89                 --enable-shared \
90                 $(use_with kerberos gssapi) \
91                 $(use_with libproxy) \
92                 $(use_enable nls) \
93                 $(use_with pkcs11 pakchois) \
94                 $(use_enable static-libs static) \
95                 $(use_with zlib) \
96                 "${myconf[@]}"
97 }
98
99 multilib_src_install() {
100         emake DESTDIR="${D}" install-{config,headers,lib,man,nls}
101
102         if multilib_is_native_abi && use doc; then
103                 (
104                         docinto html
105                         dodoc -r doc/html/*
106                 )
107         fi
108 }
109
110 multilib_src_install_all() {
111         find "${D}" -name "*.la" -type f -delete || die
112
113         dodoc AUTHORS BUGS NEWS README THANKS TODO
114 }