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.
 
 

110 lines
3.2 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_jdk21=21.0.5+3
version_jdk20=20.0.2+9
version_jdk19=19.0.2+7
version_jdk18=18.0.2.1+1
version_jdk17=17.0.13+3
version_jdk16=16.0.2+7
version_jdk15=15.0.10+5
version_jdk14=14.0.2+12
version_jdk13=13.0.14+5
version_jdk12=12.0.2+10
version_jdk11=11.0.25+3
version_jdk10=10.0.2+13
version_jdk9=9+181
version_jdk_bootstrap="$1"
version_jdk_major="$2"
eval version_jdk=\"\$version_$version_jdk_major\"
dir_download="$PWD/download"
dir_files="$PWD/files"
mkdir -p build; cd build
dir_install="$PWD/install-$version_jdk_major"
archive="${version_jdk_major}u-jdk-$version_jdk.tar.gz"
srcdir="${version_jdk_major}u-jdk-$(echo $version_jdk | tr + -)"
# 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-disarm-timebomb.patch"
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 MAKE="$PWD/../install-make42/make"
CFLAGS="$CFLAGS -fcommon"
CXXFLAGS="$CFLAGS -fcommon"
;;
jdk10)
patch -p1 -i "$dir_files/jdk-10.0.2+13-disarm-timebomb.patch"
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 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 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)
## Don't detect WSL
#sed -i -e 's/grep -i microsoft/false/' \
#make/autoconf/build-aux/config.guess
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 \
--build="$(uname -m)-pc-linux-gnu" \
--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" \
--enable-headless-only \
--disable-full-docs \
--disable-warnings-as-errors
echo "$version_jdk" > .src-rev
# Build and install
unset MAKEFLAGS
make install