Scripts for bootstrapping various programming languages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

105 lines
3.0 KiB

#!/bin/sh
set -eu
# From: https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/multiprocessing.eclass
makeopts_jobs() {
# This assumes the first .* will be more greedy than the second .*
# since POSIX doesn't specify a non-greedy match (i.e. ".*?").
local jobs=$(echo " $MAKEFLAGS " | sed -r -n \
-e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' \
-e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p')
echo ${jobs:-1}
}
version_jdk_bootstrap="$1"
version_jdk_major="$2"
version_jdk="$3"
dir_download="$PWD/download"
dir_files="$PWD/files"
mkdir -p build; cd build
dir_install="$PWD/install-$version_jdk_major"
case "$version_jdk_major" in
jdk9)
archive="jdk-jdk-$version_jdk.tar.bz2"
srcdir="jdk-jdk-$version_jdk"
;;
jdk10|jdk11|jdk12|jdk13|jdk14|jdk15)
archive="${version_jdk_major}u-jdk-$version_jdk.tar.bz2"
srcdir="${version_jdk_major}u-jdk-$version_jdk"
;;
*)
archive="${version_jdk_major}u-jdk-$version_jdk.tar.gz"
srcdir="${version_jdk_major}u-jdk-$(echo $version_jdk | tr + -)"
;;
esac
# Prepare source
tar xf "$dir_download/$archive"
cd "$srcdir"
chmod +x configure
# Some jdk versions require fixing up things
CFLAGS=""
CXXFLAGS=""
case "$version_jdk_major" in
jdk9)
patch -p1 -i "$dir_files/jdk-9+181-fix-pointer-comparison.patch"
sed -i -e '/^ *COMPILER_VERSION_NUMBER=/{N;s/\[1-9\]/&[0-9]*/}' \
common/autoconf/generated-configure.sh
export PATH="$PWD/../install-make42:$PATH"
export MAKE="$PWD/../install-make42/make"
CFLAGS="$CFLAGS -fcommon"
CXXFLAGS="$CFLAGS -fcommon"
;;
jdk10)
patch -p1 -i "$dir_files/jdk-10.0.2+13-fix-pointer-comparison.patch"
sed -i -e '/^ *COMPILER_VERSION_NUMBER=/{N;s/\[1-9\]/&[0-9]*/}' \
make/autoconf/generated-configure.sh
export PATH="$PWD/../install-make42:$PATH"
export MAKE="$PWD/../install-make42/make"
CFLAGS="$CFLAGS -fcommon"
CXXFLAGS="$CFLAGS -fcommon"
;;
jdk12)
sed -i -e '/^ *COMPILER_VERSION_NUMBER=/{N;s/@<:@1-9@:>@/&@<:@0-9@:>@*/}' \
make/autoconf/toolchain.m4
export PATH="$PWD/../install-make42:$PATH"
export MAKE="$PWD/../install-make42/make"
CFLAGS="$CFLAGS -fcommon"
CXXFLAGS="$CFLAGS -fcommon"
;;
jdk13)
sed -i -e '/^ *COMPILER_VERSION_NUMBER=/{N;s/@<:@1-9@:>@/&@<:@0-9@:>@*/}' \
make/autoconf/toolchain.m4
CFLAGS="$CFLAGS -fcommon"
CXXFLAGS="$CFLAGS -fcommon"
;;
jdk14)
CFLAGS="$CFLAGS -fcommon"
CXXFLAGS="$CFLAGS -fcommon"
;;
jdk16)
sed -i -e 's/\<prefix\>/fixpath_prefix/g' \
make/autoconf/util_paths.m4
;;
esac
unset _JAVA_OPTIONS JAVAC
# Configure source
CONFIG_SHELL=/bin/bash ./configure \
--prefix="$dir_install" \
--with-boot-jdk="$PWD/../install-$version_jdk_bootstrap" \
--with-jobs="$(makeopts_jobs)" \
--with-extra-cflags="$CFLAGS -w" \
--with-extra-cxxflags="$CXXFLAGS -w" \
--disable-full-docs \
--enable-headless-only \
--disable-warnings-as-errors
echo "$version_jdk" > .src-rev
# Build and install
unset MAKEFLAGS
make install