summaryrefslogtreecommitdiff
blob: 4936471a1bb7d7f6b65fffcf516dd93561f92a0a (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

JAVA_PKG_IUSE="doc source test"
inherit java-pkg-2 java-pkg-simple toolchain-funcs java-ant-2
JAVA_TESTING_FRAMEWORKS="junit-4"

DESCRIPTION="A wrapper that makes it possible to install a Java Application as daemon"
HOMEPAGE="https://wrapper.tanukisoftware.com"
SRC_URI="https://download.tanukisoftware.com/wrapper/${PV}/wrapper_${PV}_src.tar.gz"

LICENSE="tanuki-community"
SLOT="0"
KEYWORDS="amd64 ~arm ~x86"
RESTRICT="!test? ( test )"

RDEPEND=">=virtual/jre-1.8:*"
DEPEND="
	>=virtual/jdk-1.8:*
	test? (
		dev-java/junit:4
		dev-util/cunit
	)
"
BDEPEND="virtual/jdk"

S="${WORKDIR}/wrapper_${PV}_src"

JAVA_SRC_DIR="src/java/"
JAVA_JAR_FILENAME="wrapper.jar"
JAVA_TEST_SRC_DIR="src/test"
JAVA_TEST_GENTOO_CLASSPATH="junit-4"

src_prepare() {
	default

	# replaces as-needed.patch
	sed -i \
		-e 's/gcc -O3/$(CC)/g' \
		-e 's/ -pthread/ $(CFLAGS) $(LDFLAGS) -pthread/g' \
		-e 's/ -shared/ $(LDFLAGS) -shared/g' \
		-e 's/$(TEST)\/testsuite/testsuite/g' \
		src/c/Makefile-*.make || die

	cp "${S}/src/c/Makefile-linux-armel-32.make" "${S}/src/c/Makefile-linux-arm-32.make"
	java-pkg-2_src_prepare

	# enable tests on all platforms
	if use test; then
		grep "testsuite_SOURCE" "src/c/Makefile-linux-x86-64.make" | tee -a src/c/Makefile-*.make
		assert
		echo 'all: testsuite' | tee -a src/c/Makefile-*.make
		assert
	fi
}

src_compile() {
	tc-export CC

	pushd "${T}" || die
	echo 'public class GetArchDataModel{public static void main(String[] args){System.out.println(System.getProperty("sun.arch.data.model"));}}' \
		> GetArchDataModel.java || die
	ejavac GetArchDataModel.java
	local BITS
	BITS="$(java GetArchDataModel)" || die "Failed to identify sun.arch.data.model property"
	popd || die
	eant -Dbits="${BITS}" compile-c

	java-pkg-simple_src_compile
}

src_test() {
	src/c/testsuite --basic || die
	java-pkg-simple_src_test
}

src_install() {
	java-pkg-simple_src_install
	java-pkg_doso lib/libwrapper.so

	dobin bin/wrapper
	dodoc README*.txt
	dodoc doc/revisions.txt
}