Merge remote-tracking branch 'remotes/hhoffstaette/libxcb-python35'
[gentoo.git] / net-p2p / mldonkey / mldonkey-3.1.5.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6 WANT_AUTOCONF=2.5
7
8 inherit flag-o-matic eutils autotools toolchain-funcs user
9
10 IUSE="bittorrent doc fasttrack gd gnutella gtk guionly magic +ocamlopt"
11
12 DESCRIPTION="A multi-network P2P application written in Ocaml, with its own Gtk GUI, web and telnet interface"
13 HOMEPAGE="http://mldonkey.sourceforge.net/"
14 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
15
16 LICENSE="GPL-2"
17 SLOT="0"
18 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~sparc ~x86 ~x86-fbsd"
19
20 RDEPEND="dev-lang/perl
21         dev-ml/camlp4:=
22         guionly? ( >=gnome-base/librsvg-2.4.0
23                         >=dev-ml/lablgtk-2.6 )
24         gtk? ( >=gnome-base/librsvg-2.4.0
25                         >=dev-ml/lablgtk-2.6[svg] )
26         gd? ( >=media-libs/gd-2.0.28[truetype] )
27         magic? ( sys-apps/file )"
28
29 DEPEND="${RDEPEND}
30         >=dev-lang/ocaml-3.10.2[ocamlopt?]"
31
32 MLUSER="p2p"
33
34 pkg_setup() {
35         if use gtk; then
36                 echo ""
37                 einfo "If the compile with gui fails, and you have updated Ocaml"
38                 einfo "recently, you may have forgotten that you need to run"
39                 einfo "/usr/portage/dev-lang/ocaml/files/ocaml-rebuild.sh"
40                 einfo "to learn which ebuilds you need to recompile"
41                 einfo "each time you update Ocaml to a different version"
42                 einfo "see the Ocaml ebuild for details"
43                 echo ""
44         fi
45
46         # dev-lang/ocaml creates its own objects but calls gcc for linking, which will
47         # results in relocations if gcc wants to create a PIE executable
48         if gcc-specs-pie ; then
49                 append-ldflags -nopie
50                 ewarn "Ocaml generates its own native asm, you're using a PIE compiler"
51                 ewarn "We have appended -nopie to ocaml build options"
52                 ewarn "because linking an executable with pie while the objects are not pic will not work"
53         fi
54 }
55
56 src_prepare() {
57         cd "${S}"/config
58         eautoconf
59         cd "${S}"
60         use ocamlopt || sed -i -e "s/ocamlopt/idontwantocamlopt/g" "${S}/config/configure" || die "failed to disable ocamlopt"
61         epatch "${FILESDIR}/ocaml4.patch"
62 }
63
64 src_configure() {
65         # the dirs are not (yet) used, but it doesn't hurt to specify them anyway
66
67         # onlygui       Disable all nets support, build only chosen GUI
68
69         if use gtk || use guionly; then
70                 myconf="--enable-gui=newgui2"
71         else
72                 myconf="--disable-gui"
73         fi
74
75         if use guionly; then
76                 myconf="${myconf} --disable-multinet --disable-donkey"
77         fi
78
79         cd "${S}"
80
81         local my_extra_libs
82         if use gd; then
83                 my_extra_libs="-lpng"
84         fi
85
86         econf LIBS="${my_extra_libs}"\
87                 --sysconfdir=/etc/mldonkey \
88                 --sharedstatedir=/var/mldonkey \
89                 --localstatedir=/var/mldonkey \
90                 --enable-checks \
91                 --disable-batch \
92                 $(use_enable bittorrent) \
93                 $(use_enable fasttrack) \
94                 $(use_enable gnutella) \
95                 $(use_enable gnutella gnutella2) \
96                 $(use_enable gd) \
97                 $(use_enable magic) \
98                 ${myconf}
99 }
100
101 src_compile() {
102         export OCAMLRUNPARAM="l=256M"
103         emake
104
105         if ! use guionly; then
106                 emake utils
107         fi;
108 }
109
110 src_install() {
111         local myext=""
112         use ocamlopt || myext=".byte"
113         use ocamlopt || export STRIP_MASK="*/bin/*"
114         if ! use guionly; then
115                 for i in mlnet mld_hash get_range copysources subconv; do
116                         newbin $i$myext $i
117                 done
118                 use bittorrent && newbin make_torrent$myext make_torrent
119
120                 newconfd "${FILESDIR}/mldonkey.confd-2.8" mldonkey
121                 fperms 600 /etc/conf.d/mldonkey
122                 newinitd "${FILESDIR}/mldonkey.initd" mldonkey
123         fi
124
125         if use gtk; then
126                 for i in mlgui mlguistarter; do
127                         newbin $i$myext $i
128                 done
129                 make_desktop_entry mlgui "MLDonkey GUI" mldonkey "Network;P2P"
130                 newicon "${S}"/packages/rpm/mldonkey-icon-48.png ${PN}.png
131         fi
132
133         if use doc ; then
134                 cd "${S}"/distrib
135                 dodoc ChangeLog *.txt
136
137                 insinto /usr/share/doc/${PF}/scripts
138                 doins kill_mldonkey mldonkey_command mldonkey_previewer make_buginfo
139
140                 cd "${S}"/docs
141                 dodoc *.txt *.tex *.pdf
142                 dohtml *.html
143
144                 cd "${S}"/docs/developers
145                 dodoc *.txt *.tex
146
147                 cd "${S}"/docs/images
148                 insinto /usr/share/doc/${PF}/html/images
149                 doins *
150         fi
151 }
152
153 pkg_preinst() {
154         if ! use guionly; then
155                 enewuser ${MLUSER} -1 -1 /home/p2p users
156         fi
157 }
158
159 pkg_postinst() {
160         if ! use guionly; then
161                 echo
162                 einfo "If you want to start MLDonkey as a system service, use"
163                 einfo "the /etc/init.d/mldonkey script. To control bandwidth, use"
164                 einfo "the 'slow' and 'fast' arguments. Be sure to have a look at"
165                 einfo "/etc/conf.d/mldonkey also."
166                 echo
167         else
168                 echo
169                 einfo "Simply run mlgui to start the chosen MLDonkey gui."
170                 einfo "It puts its config files into ~/.mldonkey"
171         fi
172 }