app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / net-misc / aria2 / aria2-1.33.1.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit bash-completion-r1
7
8 DESCRIPTION="A download utility with segmented downloading with BitTorrent support"
9 HOMEPAGE="https://aria2.github.io/"
10 SRC_URI="https://github.com/aria2/${PN}/releases/download/release-${PV}/${P}.tar.xz"
11
12 LICENSE="GPL-2"
13 KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux"
14 SLOT="0"
15 IUSE="adns bittorrent +gnutls jemalloc libuv +libxml2 metalink +nettle nls sqlite scripts ssh ssl tcmalloc test xmlrpc"
16
17 CDEPEND="sys-libs/zlib:0=
18         ssl? (
19                 app-misc/ca-certificates
20                 gnutls? ( >=net-libs/gnutls-1.2.9:0= )
21                 !gnutls? ( dev-libs/openssl:0= ) )
22         adns? ( >=net-dns/c-ares-1.5.0:0= )
23         bittorrent? (
24                 ssl? (
25                         gnutls? (
26                                 nettle? ( >=dev-libs/nettle-2.4:0=[gmp] >=dev-libs/gmp-6:0= )
27                                 !nettle? ( >=dev-libs/libgcrypt-1.2.2:0= ) ) )
28                 !ssl? (
29                         nettle? ( >=dev-libs/nettle-2.4:0=[gmp] >=dev-libs/gmp-6:0= )
30                         !nettle? ( >=dev-libs/libgcrypt-1.2.2:0= ) ) )
31         jemalloc? ( dev-libs/jemalloc )
32         libuv? ( dev-libs/libuv:0= )
33         metalink? (
34                 libxml2? ( >=dev-libs/libxml2-2.6.26:2= )
35                 !libxml2? ( dev-libs/expat:0= ) )
36         sqlite? ( dev-db/sqlite:3= )
37         ssh? ( net-libs/libssh2:= )
38         tcmalloc? ( dev-util/google-perftools )
39         xmlrpc? (
40                 libxml2? ( >=dev-libs/libxml2-2.6.26:2= )
41                 !libxml2? ( dev-libs/expat:0= ) )"
42
43 DEPEND="${CDEPEND}
44         app-arch/xz-utils
45         virtual/pkgconfig
46         nls? ( sys-devel/gettext )
47         test? ( >=dev-util/cppunit-1.12.0:0 )"
48 RDEPEND="${CDEPEND}
49         nls? ( virtual/libiconv virtual/libintl )
50         scripts? ( dev-lang/ruby )"
51
52 # xmlrpc has no explicit switch, it's turned out by any XML library
53 # so metalink implicitly forces it on
54 REQUIRED_USE="?? ( jemalloc tcmalloc )
55         metalink? ( xmlrpc )"
56 RESTRICT="!test? ( test )"
57
58 pkg_setup() {
59         if use scripts && ! use xmlrpc; then
60                 ewarn "Please note that you may need to enable USE=xmlrpc to run the aria2rpc"
61                 ewarn "and aria2mon scripts against the local aria2."
62         fi
63 }
64
65 src_prepare() {
66         default
67         sed -i -e "s|/tmp|${T}|" test/*.cc test/*.txt || die "sed failed"
68 }
69
70 src_configure() {
71         local myconf=(
72                 # threads, epoll: check for best portability
73
74                 # do not try to compile and run a test LIBXML program
75                 --disable-xmltest
76                 # enable the shared library
77                 --enable-libaria2
78                 # zlib should always be available anyway
79                 --with-libz
80                 --with-ca-bundle="${EPREFIX}/etc/ssl/certs/ca-certificates.crt"
81
82                 # optional features
83                 $(use_enable bittorrent)
84                 $(use_enable metalink)
85                 $(use_enable nls)
86                 $(use_with adns libcares)
87                 $(use_with jemalloc)
88                 $(use_with libuv)
89                 $(use_with sqlite sqlite3)
90                 $(use_with ssh libssh2)
91                 $(use_with tcmalloc)
92         )
93
94         # SSL := gnutls / openssl
95         # USE=ssl
96         #  + USE=gnutls -> gnutls
97         #  + USE=-gnutls -> openssl
98
99         if use ssl; then
100                 myconf+=( $(use_with gnutls) $(use_with !gnutls openssl) )
101         else
102                 myconf+=( --without-gnutls --without-openssl )
103         fi
104
105         # message-digest := nettle / gcrypt / openssl
106         # bignum := nettle+gmp / gcrypt / openssl
107         # bittorrent := message-digest + bignum
108         # USE=bittorrent
109         #  + USE=(ssl -gnutls) -> openssl
110         #  + USE=nettle -> nettle+gmp
111         #  + USE=-nettle -> gcrypt
112
113         if use !bittorrent || use ssl && use !gnutls; then
114                 myconf+=( --without-libgcrypt --without-libnettle --without-libgmp )
115         else
116                 myconf+=( $(use_with !nettle libgcrypt)
117                         $(use_with nettle libnettle) $(use_with nettle libgmp) )
118         fi
119
120         # metalink+xmlrpc := libxml2 / expat
121         # USE=(metalink || xmlrpc)
122         #  + USE=libxml2 -> libxml2
123         #  + USE=-libxml2 -> expat
124
125         if use metalink || use xmlrpc; then
126                 myconf+=( $(use_with !libxml2 libexpat) $(use_with libxml2) )
127         else
128                 myconf+=( --without-libexpat --without-libxml2 )
129         fi
130
131         # Note:
132         # - always enable gzip/http compression since zlib should always be available anyway
133         # - always enable epoll since we can assume kernel 2.6.x
134         # - other options for threads: solaris, pth, win32
135         econf "${myconf[@]}"
136 }
137
138 src_install() {
139         default
140         rm -rf "${D}"/usr/share/doc/aria2 \
141                 "${D}"/usr/share/doc/${PF}/README{,.html}
142
143         dobashcomp doc/bash_completion/aria2c
144         use scripts && dobin doc/xmlrpc/aria2{mon,rpc}
145 }
146
147 pkg_postinst() {
148         if use xmlrpc; then
149                 elog "If you would like to use the additional aria2mon and aria2rpc tools,"
150                 elog "you need to have \033[1mdev-lang/ruby\033[0m installed."
151         fi
152 }