1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools check-reqs flag-o-matic java-pkg-2 java-vm-2 multiprocessing pax-utils toolchain-funcs
8 # we need -ga tag to fetch tarball and unpack it, but exact number everywhere else to
9 # set build version properly
11 SLOT="${MY_PV%%[.+]*}"
13 DESCRIPTION="Open source implementation of the Java programming language"
14 HOMEPAGE="https://openjdk.java.net"
15 SRC_URI="https://hg.${PN}.java.net/jdk-updates/jdk${SLOT}u/archive/jdk-${MY_PV}.tar.bz2 -> ${P}.tar.bz2"
18 KEYWORDS="~amd64 ~arm ~arm64 ~ppc64"
20 IUSE="alsa cups debug doc examples gentoo-vm headless-awt javafx +jbootstrap nsplugin +pch selinux source systemtap webstart"
23 media-libs/freetype:2=
29 systemtap? ( dev-util/systemtap )
32 # Many libs are required to build, but not to run, make is possible to remove
33 # by listing conditionally in RDEPEND unconditionally in DEPEND
36 >=sys-apps/baselayout-java-0.1.0-r1
46 alsa? ( media-libs/alsa-lib )
47 cups? ( net-print/cups )
48 selinux? ( sec-policy/selinux-java )
64 javafx? ( dev-java/openjfx:${SLOT}= )
66 dev-java/openjdk-bin:${SLOT}
67 dev-java/openjdk:${SLOT}
72 webstart? ( >=dev-java/icedtea-web-1.6.1:0 )
73 nsplugin? ( >=dev-java/icedtea-web-1.6.1:0[nsplugin] )
76 REQUIRED_USE="javafx? ( alsa !headless-awt )"
78 S="${WORKDIR}/jdk${SLOT}u-jdk-${MY_PV}"
81 "${FILESDIR}/${P}-sigsegv.patch"
84 # The space required to build varies wildly depending on USE flags,
85 # ranging from 2GB to 16GB. This function is certainly not exact but
86 # should be close enough to be useful.
87 openjdk_check_requirements() {
90 M=$(( $(usex jbootstrap 2 1) * $M ))
91 M=$(( $(usex debug 3 1) * $M ))
92 M=$(( $(usex doc 320 0) + $(usex source 128 0) + 192 + $M ))
94 CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE}
98 openjdk_check_requirements
99 has ccache ${FEATURES} && die "FEATURES=ccache doesn't work with ${PN}"
103 openjdk_check_requirements
106 JAVA_PKG_WANT_BUILD_VM="openjdk-${SLOT} openjdk-bin-${SLOT}"
107 JAVA_PKG_WANT_SOURCE="${SLOT}"
108 JAVA_PKG_WANT_TARGET="${SLOT}"
110 # The nastiness below is necessary while the gentoo-vm USE flag is
111 # masked. First we call java-pkg-2_pkg_setup if it looks like the
112 # flag was unmasked against one of the possible build VMs. If not,
113 # we try finding one of them in their expected locations. This would
114 # have been slightly less messy if openjdk-bin had been installed to
115 # /opt/${PN}-${SLOT} or if there was a mechanism to install a VM env
116 # file but disable it so that it would not normally be selectable.
119 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
120 if [[ -d ${EPREFIX}/usr/lib/jvm/${vm} ]]; then
126 if has_version --host-root dev-java/openjdk:${SLOT}; then
127 export JDK_HOME=${EPREFIX}/usr/$(get_libdir)/openjdk-${SLOT}
129 if [[ ${MERGE_TYPE} != "binary" ]]; then
130 JDK_HOME=$(best_version --host-root dev-java/openjdk-bin:${SLOT})
131 [[ -n ${JDK_HOME} ]] || die "Build VM not found!"
132 JDK_HOME=${JDK_HOME#*/}
133 JDK_HOME=${EPREFIX}/opt/${JDK_HOME%-r*}
141 chmod +x configure || die
145 # Work around stack alignment issue, bug #647954. in case we ever have x86
146 use x86 && append-flags -mincoming-stack-boundary=2
148 # Work around -fno-common ( GCC10 default ), bug #713180
149 append-flags -fcommon
151 # Enabling full docs appears to break doc building. If not
152 # explicitly disabled, the flag will get auto-enabled if pandoc and
153 # graphviz are detected. pandoc has loads of dependencies anyway.
157 --enable-full-docs=no
158 --with-boot-jdk="${JDK_HOME}"
159 --with-extra-cflags="${CFLAGS}"
160 --with-extra-cxxflags="${CXXFLAGS}"
161 --with-extra-ldflags="${LDFLAGS}"
164 --with-libjpeg=system
166 --with-native-debug-symbols=$(usex debug internal none)
167 --with-vendor-name="Gentoo"
168 --with-vendor-url="https://gentoo.org"
169 --with-vendor-bug-url="https://bugs.gentoo.org"
170 --with-vendor-vm-bug-url="https://bugs.openjdk.java.net"
171 --with-vendor-version-string="${PVR}"
172 --with-version-pre=""
173 --with-version-string="${PV%_p*}"
174 --with-version-build="${PV#*_p}"
176 --enable-dtrace=$(usex systemtap yes no)
177 --enable-headless-only=$(usex headless-awt yes no)
181 local zip="${EROOT%/}/usr/$(get_libdir)/openjfx-${SLOT}/javafx-exports.zip"
182 if [[ -r ${zip} ]]; then
183 myconf+=( --with-import-modules="${zip}" )
185 die "${zip} not found or not readable"
189 # PaX breaks pch, bug #601016
190 if use pch && ! host-is-pax; then
191 myconf+=( --enable-precompiled-headers )
193 myconf+=( --disable-precompiled-headers )
197 unset _JAVA_OPTIONS JAVA JAVA_TOOL_OPTIONS JAVAC XARGS
198 CFLAGS= CXXFLAGS= LDFLAGS= \
199 CONFIG_SITE=/dev/null \
206 JOBS=$(makeopts_jobs)
208 CFLAGS_WARNINGS_ARE_ERRORS= # No -Werror
210 $(usex jbootstrap bootcycle-images product-images)
212 emake "${myemakeargs[@]}" -j1 #nowarn
216 local dest="/usr/$(get_libdir)/${PN}-${SLOT}"
217 local ddest="${ED}${dest#/}"
219 cd "${S}"/build/*-release/images/jdk || die
221 # Create files used as storage for system preferences.
222 mkdir .systemPrefs || die
223 touch .systemPrefs/.system.lock || die
224 touch .systemPrefs/.systemRootModFile || die
226 # Oracle and IcedTea have libjsoundalsa.so depending on
227 # libasound.so.2 but OpenJDK only has libjsound.so. Weird.
229 rm -v lib/libjsound.* || die
232 if ! use examples ; then
236 if ! use source ; then
237 rm -v lib/src.zip || die
240 rm -v lib/security/cacerts || die
243 cp -pPR * "${ddest}" || die
245 dosym ../../../../../etc/ssl/certs/java/cacerts "${dest}"/lib/security/cacerts
247 # must be done before running itself
248 java-vm_set-pax-markings "${ddest}"
250 einfo "Creating the Class Data Sharing archives and disabling usage tracking"
251 "${ddest}/bin/java" -server -Xshare:dump -Djdk.disableLastUsageTracking || die
253 use gentoo-vm && java-vm_install-env "${FILESDIR}"/${PN}-${SLOT}.env.sh
255 java-vm_sandbox-predict /dev/random /proc/self/coredump_filter
259 dodoc -r "${S}"/build/*-release/images/docs/*
260 dosym ../../../usr/share/doc/"${PF}" /usr/share/doc/"${PN}-${SLOT}"
265 java-vm-2_pkg_postinst
267 if use gentoo-vm ; then
268 ewarn "WARNING! You have enabled the gentoo-vm USE flag, making this JDK"
269 ewarn "recognised by the system. This will almost certainly break"
270 ewarn "many java ebuilds as they are not ready for openjdk-11"
272 ewarn "The experimental gentoo-vm USE flag has not been enabled so this JDK"
273 ewarn "will not be recognised by the system. For example, simply calling"
274 ewarn "\"java\" will launch a different JVM. This is necessary until Gentoo"
275 ewarn "fully supports Java ${SLOT}. This JDK must therefore be invoked using its"
276 ewarn "absolute location under ${EPREFIX}/usr/$(get_libdir)/${PN}-${SLOT}."