summaryrefslogtreecommitdiff
blob: a4f330caaee766f7fb57893501c16c9c79b55b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright 2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit java-pkg-2 toolchain-funcs

DESCRIPTION='jbigi library used by net-vpn/i2p'
HOMEPAGE='https://geti2p.net'
SRC_URI="https://download.i2p2.de/releases/${PV}/i2psource_${PV}.tar.bz2"

LICENSE='public-domain'
SLOT='0'
KEYWORDS='~amd64 ~x86'
IUSE='test'

DEPEND='
	dev-libs/gmp:0=
	virtual/jdk:1.8
'
RDEPEND="${DEPEND}"

S="${WORKDIR}/i2p-${PV}/core"

PATCHES=(
	"${FILESDIR}/${P}-asmfix.patch"
)

src_compile() {
	local compile_lib
	compile_lib() {
		local name="${1}"
		local file="${2}"
		shift 2

		"$(tc-getCC)" "${@}" ${CFLAGS} $(java-pkg_get-jni-cflags) \
			${LDFLAGS} -shared -fPIC "-Wl,-soname,lib${name}.so" \
			"${file}" -o "lib${name}.so"
	}

	cd "${S}/c/jbigi/jbigi" &&
		compile_lib jbigi src/jbigi.c -Iinclude -lgmp ||
		die 'unable to build jbigi'

	if use amd64 || use x86; then
		cd "${S}/c/jcpuid" &&
			compile_lib jcpuid src/jcpuid.c -Iinclude ||
			die 'unable to build jcpuid'
	fi

	if use test; then
		cd "${S}/java/src" &&
			ejavac -encoding UTF-8 net/i2p/util/NativeBigInteger.java ||
			die 'unable to build tests'
	fi
}

src_test() {
	cd "${S}/java/src" &&
		"$(java-config -J)" -Djava.library.path="${S}/c/jbigi/jbigi" net/i2p/util/NativeBigInteger ||
		die 'unable to pass tests'
}

src_install() {
	dolib.so c/jbigi/jbigi/libjbigi.so

	if use amd64 || use x86; then
		dolib.so c/jcpuid/libjcpuid.so
	fi
}