updated RDEPEND to use pkgconfig olny if a init script is provided
[flow-s-ebuilds:flow-s-ebuilds.git] / net-p2p / bitcoin / bitcoin-9999.ebuild
1 # Copyright 2010-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="2"
6
7 inherit db-use distutils eutils subversion wxwidgets
8
9 DESCRIPTION="A P2P network based digital currency."
10 HOMEPAGE="http://bitcoin.org/"
11 ESVN_REPO_URI="https://${PN}.svn.sourceforge.net/svnroot/${PN}/trunk"
12
13 LICENSE="MIT"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="daemon doc nls selinux sse2 wxwidgets"
17
18 DEPEND="dev-libs/boost
19         dev-libs/crypto++
20         dev-libs/openssl[-bindist]
21         nls? (
22                 sys-devel/gettext
23         )
24         selinux? (
25                 sys-libs/libselinux
26         )
27         sys-libs/db:4.8
28         wxwidgets? (
29                 app-admin/eselect-wxwidgets
30                 x11-libs/wxGTK:2.9[X]
31         )"
32 RDEPEND="${DEPEND}
33         dev-util/pkgconfig"
34
35 S="${WORKDIR}/${P}/trunk"
36
37 pkg_setup() {
38         if use daemon; then
39                 ebegin "Creating bitcoin user and group"
40                 enewgroup ${PN}
41                 enewuser ${PN} -1 /bin/bash /var/lib/bitcoin ${PN}
42         fi;
43 }
44
45 src_prepare() {
46         epatch "${FILESDIR}"/${P}-Makefile.patch
47         # Replace the berkdb cflags with the ones on our system.
48         einfo "Berkeley DB: "
49         sed -i -e "s:@@GENTOO_DB_INCLUDEDIR@@:$(db_includedir):g" \
50                 "${S}/makefile.unix"
51         # Set the sse2 code
52         if use sse2; then
53                 einfo "Enabling SSE2 code"
54                 sed -i -e "s:@@GENTOO_CFLAGS_SSE2@@:-DFOURWAYSSE2:g" \
55                         "${S}/makefile.unix"
56                 sed -i -e "s:@@GENTOO_SHA256_SSE2@@:-msse2 -O3 -march=amdfam10:g" \
57                         "${S}/makefile.unix"
58         else
59                 # No sse2 code.
60                 sed -i -e "s:@@GENTOO_CFLAGS_SSE2@@::g" \
61                         "${S}/makefile.unix"
62                 sed -i -e "s:@@GENTOO_SHA256_SSE2@@::g" \
63                         "${S}/makefile.unix"
64         fi
65
66         # http://www.bitcoin.org/smf/index.php?topic=1319.0
67         epatch "${FILESDIR}"/${PN}-monitor.patch
68         # http://www.bitcoin.org/smf/index.php?topic=984.msg13120#msg13120
69         #epatch "${FILESDIR}"/${PN}-bindaddr.patch
70         # http://www.bitcoin.org/smf/index.php?topic=1048.msg13022#msg13022
71         epatch "${FILESDIR}"/${PN}-disable_ip_transactions.patch
72         # http://www.bitcoin.org/smf/index.php?topic=611.msg11859#msg11859
73         epatch "${FILESDIR}"/${PN}-listgenerated.patch
74         # http://www.bitcoin.org/smf/index.php?topic=611.msg9123#msg9123
75         epatch "${FILESDIR}"/${PN}-listtransactions.patch
76         # http://www.bitcoin.org/smf/index.php?topic=611.msg11859#msg11859
77         epatch "${FILESDIR}"/${PN}-max_outbound.patch
78 }
79
80 src_compile() {
81         if use daemon; then
82                 emake -f makefile.unix bitcoind || die "emake bitcoind failed";
83         fi
84         if use wxwidgets; then
85                 emake -f makefile.unix bitcoin || die "emake bitcoin failed";
86         fi
87         if ! use daemon && ! use wxwidgets; then
88                 einfo "No daemon or wxwidgets USE flag selected, compiling daemon by default."
89                 emake -f makefile.unix bitcoind || die "emake bitcoind failed"
90         fi
91 }
92
93 src_install() {
94         if use daemon || ( ! use wxwidgets && ! use daemon ); then
95                 einfo "Installing daemon"
96                 dobin bitcoind
97
98                 einfo "Installing configuration file"
99                 insinto /etc/bitcoin
100                 newins "${FILESDIR}/bitcoin.conf" bitcoin.conf
101                 fowners bitcoin:bitcoin /etc/bitcoin/bitcoin.conf
102                 fperms 600 /etc/bitcoin/bitcoin.conf
103
104                 newconfd "${FILESDIR}/bitcoin.confd" bitcoind
105                 # Init script still nonfunctional.
106                 newinitd "${FILESDIR}/bitcoin.initd" bitcoind
107                 dodir /var/lib/bitcoin
108
109                 einfo "Creating data program directory"
110                 diropts -m700
111                 keepdir /var/lib/bitcoin
112                 fperms 700 /var/lib/bitcoin
113                 fowners bitcoin:bitcoin /var/lib/bitcoin/
114                 dodir /var/lib/bitcoin/.bitcoin
115                 fowners bitcoin:bitcoin /var/lib/bitcoin/.bitcoin
116                 dosym /etc/bitcoin/bitcoin.conf /var/lib/bitcoin/.bitcoin/bitcoin.conf
117         fi
118         if use wxwidgets; then
119                 einfo "Installing wxwidgets gui"
120                 dobin bitcoin
121                 insinto /usr/share/pixmaps
122                 doins "${S}/rc/bitcoin.ico"
123                 make_desktop_entry ${PN} "Bitcoin" "/usr/share/pixmaps/bitcoin.ico" "Network;P2P"
124         fi
125         if use nls; then
126                 einfo "Installing language files"
127                 cd locale
128                 for val in ${LINGUAS}
129                 do
130                         if [ -e "$val/LC_MESSAGES/bitcoin.mo" ]; then
131                                 domo "$val/LC_MESSAGES/bitcoin.mo" || die "domo $val/LC_MESSAGES/bitcoin.mo"
132                         fi
133                 done
134         fi
135
136         if use doc; then
137                 einfo "Installing documentation"
138                 edos2unix *.txt
139                 dodoc *.txt
140         fi
141 }