dev-python/setuptools: x86 stable (bug #676562)
[gentoo.git] / net-p2p / mldonkey / mldonkey-3.1.6-r1.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="6"
5
6 inherit versionator flag-o-matic eutils autotools toolchain-funcs user
7
8 IUSE="bittorrent doc fasttrack gd gnutella gtk guionly magic +ocamlopt upnp"
9
10 DESCRIPTION="Multi-network P2P application written in Ocaml, with Gtk, web & telnet interface"
11 HOMEPAGE="http://mldonkey.sourceforge.net/"
12 SRC_URI="https://github.com/ygrek/mldonkey/releases/download/release-$(replace_all_version_separators '-')/${P}.tar.bz2"
13
14 LICENSE="GPL-2"
15 SLOT="0"
16 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
17
18 RDEPEND="dev-lang/perl
19         dev-ml/camlp4:=
20         guionly? ( >=gnome-base/librsvg-2.4.0
21                         >=dev-ml/lablgtk-2.6 )
22         gtk? ( >=gnome-base/librsvg-2.4.0
23                         >=dev-ml/lablgtk-2.6[svg] )
24         gd? ( >=media-libs/gd-2.0.28[truetype] )
25         magic? ( sys-apps/file )
26         upnp? ( net-libs/miniupnpc:= net-libs/libnatpmp:= )
27 "
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
62         default
63 }
64
65 src_configure() {
66         # the dirs are not (yet) used, but it doesn't hurt to specify them anyway
67
68         # onlygui       Disable all nets support, build only chosen GUI
69
70         if use gtk || use guionly; then
71                 myconf="--enable-gui=newgui2"
72         else
73                 myconf="--disable-gui"
74         fi
75
76         if use guionly; then
77                 myconf="${myconf} --disable-multinet --disable-donkey"
78         fi
79
80         cd "${S}"
81
82         local my_extra_libs
83         if use gd; then
84                 my_extra_libs="-lpng"
85         fi
86
87         econf LIBS="${my_extra_libs}"\
88                 --sysconfdir=/etc/mldonkey \
89                 --sharedstatedir=/var/mldonkey \
90                 --localstatedir=/var/mldonkey \
91                 --enable-checks \
92                 --disable-batch \
93                 $(use_enable bittorrent) \
94                 $(use_enable fasttrack) \
95                 $(use_enable gnutella) \
96                 $(use_enable gnutella gnutella2) \
97                 $(use_enable gd) \
98                 $(use_enable magic) \
99                 $(use_enable upnp upnp-natpmp) \
100                 --disable-force-upnp-natpmp \
101                 ${myconf}
102 }
103
104 src_compile() {
105         export OCAMLRUNPARAM="l=256M"
106         emake
107
108         if ! use guionly; then
109                 emake utils
110         fi;
111 }
112
113 src_install() {
114         local myext=""
115         use ocamlopt || myext=".byte"
116         use ocamlopt || export STRIP_MASK="*/bin/*"
117         if ! use guionly; then
118                 for i in mlnet mld_hash get_range copysources subconv; do
119                         newbin $i$myext $i
120                 done
121                 use bittorrent && newbin make_torrent$myext make_torrent
122
123                 newconfd "${FILESDIR}/mldonkey.confd-2.8" mldonkey
124                 fperms 600 /etc/conf.d/mldonkey
125                 newinitd "${FILESDIR}/mldonkey.initd" mldonkey
126         fi
127
128         if use gtk; then
129                 for i in mlgui mlguistarter; do
130                         newbin $i$myext $i
131                 done
132                 make_desktop_entry mlgui "MLDonkey GUI" mldonkey "Network;P2P"
133                 newicon "${S}"/packages/rpm/mldonkey-icon-48.png ${PN}.png
134         fi
135
136         if use doc ; then
137                 cd "${S}"/distrib
138                 dodoc ChangeLog *.txt
139
140                 insinto /usr/share/doc/${PF}/scripts
141                 doins kill_mldonkey mldonkey_command mldonkey_previewer make_buginfo
142
143                 cd "${S}"/docs
144                 dodoc *.txt *.tex *.pdf
145                 dohtml *.html
146
147                 cd "${S}"/docs/developers
148                 dodoc *.txt *.tex
149
150                 cd "${S}"/docs/images
151                 insinto /usr/share/doc/${PF}/html/images
152                 doins *
153         fi
154 }
155
156 pkg_preinst() {
157         if ! use guionly; then
158                 enewuser ${MLUSER} -1 -1 /home/p2p users
159         fi
160 }
161
162 pkg_postinst() {
163         if ! use guionly; then
164                 echo
165                 einfo "If you want to start MLDonkey as a system service, use"
166                 einfo "the /etc/init.d/mldonkey script. To control bandwidth, use"
167                 einfo "the 'slow' and 'fast' arguments. Be sure to have a look at"
168                 einfo "/etc/conf.d/mldonkey also."
169                 echo
170         else
171                 echo
172                 einfo "Simply run mlgui to start the chosen MLDonkey gui."
173                 einfo "It puts its config files into ~/.mldonkey"
174         fi
175 }