Line 0
Link Here
|
0 |
- |
1 |
# Copyright 1999-2016 Gentoo Foundation |
|
|
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Id$ |
4 |
|
5 |
EAPI=5 |
6 |
|
7 |
inherit eutils flag-o-matic multilib java-vm-2 autotools |
8 |
|
9 |
DESCRIPTION="An extremely small and specification-compliant virtual machine" |
10 |
HOMEPAGE="http://jamvm.sourceforge.net/" |
11 |
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz" |
12 |
|
13 |
LICENSE="GPL-2" |
14 |
SLOT="0" |
15 |
KEYWORDS="amd64 x86" |
16 |
IUSE="debug libffi" |
17 |
|
18 |
DEPEND="dev-java/gnu-classpath:0.98 |
19 |
|| ( dev-java/eclipse-ecj:* dev-java/ecj-gcj:* ) |
20 |
libffi? ( virtual/libffi ) |
21 |
ppc64? ( virtual/libffi ) |
22 |
sparc? ( virtual/libffi )" |
23 |
RDEPEND="${DEPEND}" |
24 |
|
25 |
PATCHES=( |
26 |
"${FILESDIR}"/"${P}-classes-location.patch" |
27 |
"${FILESDIR}"/"${P}-noexecstack.patch" |
28 |
) |
29 |
|
30 |
src_prepare() { |
31 |
# without this patch, classes.zip is not found at runtime |
32 |
epatch "${PATCHES[@]}" |
33 |
|
34 |
if use elibc_musl ; then |
35 |
epatch "${FILESDIR}"/"${P}-musl.patch" |
36 |
fi |
37 |
|
38 |
eautoreconf |
39 |
|
40 |
# These come precompiled. |
41 |
# configure script uses detects the compiler |
42 |
# from PATH. I guess we should compile this from source. |
43 |
# Then just make sure not to hit |
44 |
# https://bugs.gentoo.org/show_bug.cgi?id=163801 |
45 |
# |
46 |
#rm -v lib/classes.zip || die |
47 |
} |
48 |
|
49 |
src_configure() { |
50 |
filter-flags "-fomit-frame-pointer" |
51 |
|
52 |
if use ppc64 || use sparc || use libffi; then |
53 |
append-cflags "$(pkg-config --cflags-only-I libffi)" |
54 |
fi |
55 |
|
56 |
local fficonf="--enable-ffi" |
57 |
if { ! use ppc64 && ! use sparc; }; then |
58 |
fficonf="$(use_enable libffi ffi)" |
59 |
fi |
60 |
|
61 |
econf ${fficonf} \ |
62 |
--disable-dependency-tracking \ |
63 |
$(use_enable debug trace) \ |
64 |
--libdir="${EPREFIX}"/usr/$(get_libdir)/${PN} \ |
65 |
--includedir="${EPREFIX}"/usr/include/${PN} \ |
66 |
--with-classpath-install-dir=/usr |
67 |
} |
68 |
|
69 |
create_launcher() { |
70 |
local script="${D}/${INSTALL_DIR}/bin/${1}" |
71 |
cat > "${script}" <<-EOF |
72 |
#!/bin/sh |
73 |
exec /usr/bin/jamvm \ |
74 |
-Xbootclasspath/p:/usr/share/classpath/tools.zip" \ |
75 |
gnu.classpath.tools.${1}.Main "\$@" |
76 |
EOF |
77 |
chmod +x "${script}" || die |
78 |
} |
79 |
|
80 |
src_install() { |
81 |
local libdir=$(get_libdir) |
82 |
local CLASSPATH_DIR=/usr/libexec/gnu-classpath-0.98 |
83 |
local JDK_DIR=/usr/${libdir}/${PN}-jdk |
84 |
|
85 |
emake DESTDIR="${D}" install |
86 |
|
87 |
dodoc ACKNOWLEDGEMENTS AUTHORS ChangeLog NEWS README |
88 |
|
89 |
set_java_env "${FILESDIR}/${P}-env.file" |
90 |
|
91 |
dodir ${JDK_DIR}/bin |
92 |
dosym /usr/bin/jamvm ${JDK_DIR}/bin/java |
93 |
for files in ${CLASSPATH_DIR}/g*; do |
94 |
if [ $files = "${CLASSPATH_DIR}/bin/gjdoc" ] ; then |
95 |
dosym $files ${JDK_DIR}/bin/javadoc || die |
96 |
else |
97 |
dosym $files \ |
98 |
${JDK_DIR}/bin/$(echo $files|sed "s#$(dirname $files)/g##") || die |
99 |
fi |
100 |
done |
101 |
|
102 |
dodir ${JDK_DIR}/jre/lib |
103 |
dosym /usr/share/classpath/glibj.zip ${JDK_DIR}/jre/lib/rt.jar |
104 |
dodir ${JDK_DIR}/lib |
105 |
dosym /usr/share/classpath/tools.zip ${JDK_DIR}/lib/tools.jar |
106 |
|
107 |
local ecj_jar="$(readlink "${EPREFIX}"/usr/share/eclipse-ecj/ecj.jar)" |
108 |
exeinto ${JDK_DIR}/bin |
109 |
sed -e "s#@JAVA@#/usr/bin/jamvm#" \ |
110 |
-e "s#@ECJ_JAR@#${ecj_jar}#" \ |
111 |
-e "s#@RT_JAR@#/usr/share/classpath/glibj.zip#" \ |
112 |
-e "s#@TOOLS_JAR@#/usr/share/classpath/tools.zip#" \ |
113 |
"${FILESDIR}"/"${P}-javac.in" | newexe - javac |
114 |
|
115 |
local libarch="${ARCH}" |
116 |
[ ${ARCH} == x86 ] && libarch="i386" |
117 |
[ ${ARCH} == x86_64 ] && libarch="amd64" |
118 |
dodir ${JDK_DIR}/jre/lib/${libarch}/client |
119 |
dodir ${JDK_DIR}/jre/lib/${libarch}/server |
120 |
dosym /usr/${libdir}/${PN}/libjvm.so ${JDK_DIR}/jre/lib/${libarch}/client/libjvm.so |
121 |
dosym /usr/${libdir}/${PN}/libjvm.so ${JDK_DIR}/jre/lib/${libarch}/server/libjvm.so |
122 |
dosym /usr/${libdir}/classpath/libjawt.so ${JDK_DIR}/jre/lib/${libarch}/libjawt.so |
123 |
|
124 |
# Can't use java-vm_set-pax-markings as doesn't work with symbolic links |
125 |
# Ensure a PaX header is created. |
126 |
local pax_markings="C" |
127 |
# Usally disabeling MPROTECT is sufficent. |
128 |
local pax_markings+="m" |
129 |
# On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well. |
130 |
use x86 && pax_markings+="sp" |
131 |
|
132 |
pax-mark ${pax_markings} "${ED}"/usr/bin/jamvm |
133 |
} |