app-arch/file-roller: Version bump
[gentoo.git] / net-misc / gogoc / gogoc-1.2-r3.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 inherit eutils systemd versionator toolchain-funcs
8
9 MY_P=${PN}-$(replace_all_version_separators "_")
10 if [[ ${MY_P/_beta/} != ${MY_P} ]]; then
11         MY_P=${MY_P/_beta/-BETA}
12 else
13         MY_P=${MY_P}-RELEASE
14 fi
15
16 DESCRIPTION="Client to connect to a tunnel broker using the TSP protocol (freenet6 for example)"
17 HOMEPAGE="http://gogonet.gogo6.com/page/download-1"
18 SRC_URI="http://gogo6.com/downloads/${MY_P}.tar.gz"
19
20 # GPL-2 for Gentoo init script
21 LICENSE="MIT GPL-2"
22 SLOT="0"
23 KEYWORDS="amd64 hppa sparc x86"
24 IUSE="debug"
25
26 DEPEND="dev-libs/openssl"
27 RDEPEND="${DEPEND}
28         sys-apps/iproute2
29         >=sys-apps/net-tools-1.60_p20120127084908"
30
31 S="${WORKDIR}/${MY_P}"
32
33 src_prepare() {
34         epatch "${FILESDIR}"/${P}-overflow.patch
35         epatch "${FILESDIR}"/${P}+gcc-4.6.patch
36
37         # Make the makefile handle linking correctly
38         find . -name Makefile -exec sed -i \
39                 -e 's:LDFLAGS:LDLIBS:g' \
40                 -e '/\$(LDLIBS)/s:-o:$(LDFLAGS) -o:' \
41                 {} + || die "multised failed"
42
43         sed -i -e 's:/usr/local/etc/gogoc:/etc/gogoc:' \
44                 gogoc-tsp/platform/*/tsp_local.c \
45                 || die "path sed failed"
46
47         # Newer net-tools use /bin
48         sed -i -e "/^\(route\|ifconfig\)=/s/sbin/bin/" \
49                 gogoc-tsp/template/linux.sh \
50                 || die "net-tools sed failed"
51 }
52
53 src_configure() { :; }
54
55 src_compile() {
56         # parallel make fails as inter-directory dependecies are missing.
57         emake -j1 \
58                 AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" \
59                 CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getCXX)" \
60                 EXTRA_CFLAGS="${CFLAGS}" EXTRA_CXXFLAGS="${CXXFLAGS}" \
61                 $(use debug && echo DEBUG=1) \
62                 all target=linux
63
64         emake -C gogoc-tsp/conf \
65                 PLATFORM=linux PLATFORM_DIR=../platform BIN_DIR=../bin \
66                 gogoc.conf.sample
67 }
68
69 src_install() {
70         dodoc README
71
72         cd "${S}"/gogoc-tsp
73         dosbin bin/gogoc
74
75         dodoc bin/gogoc.conf.sample
76
77         exeinto /etc/gogoc/template
78         doexe template/linux.sh
79
80         newinitd "${FILESDIR}"/gogoc.rc gogoc
81         systemd_dounit "${FILESDIR}"/${PN}.service
82
83         doman man/{man5/gogoc.conf.5,man8/gogoc.8}
84         keepdir /var/lib/gogoc
85
86         diropts -m0700
87         keepdir /etc/gogoc
88 }
89
90 pkg_postinst() {
91         elog "You should create an /etc/gogoc/gogoc.conf file starting from"
92         elog "the sample configuration in /usr/share/doc/${PF}/gogoc.conf.sample.*"
93         elog ""
94         elog "To add support for a TSP IPv6 connection at startup,"
95         elog "remember to run:"
96         elog "# rc-update add gogoc default"
97 }