Assumes an initial boot JDK (JDK 8) in /home/chris/java8. This boot JDK is used to build both OpenJDK 8 and OpenJDK 9.

Check out JDK projects (do this once)

#/bin/sh
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u/
hg clone http://hg.openjdk.java.net/jdk9/dev/
mv dev jdk9-dev
hg clone http://hg.openjdk.java.net/jdk/jdk10/
hg clone http://hg.openjdk.java.net/jdk/jdk11/
hg clone http://hg.openjdk.java.net/jdk/jdk12/
hg clone http://hg.openjdk.java.net/jdk/jdk/
mv jdk jdk13

Update OpenJDK projects (run this before each build)

#/bin/sh
echo "Updating JDK8"
cd jdk8u/ && hg pull && hg update && cd ..

echo "Updating JDK9"
cd jdk9-dev/ && hg pull && hg update && cd ..

echo "Updating JDK10"
cd jdk10/ && hg pull && hg update && cd ..

echo "Updating JDK11"
cd jdk11/ && hg pull && hg update && cd ..

echo "Updating JDK12"
cd jdk12/ && hg pull && hg update && cd ..

echo "Updating JDK13"
cd jdk13/ && hg pull && hg update && cd ..

Cascading builds, creates tar.gz JDK images for distribution

#!/bin/sh
export MODE="release"
export EXTRA_C_FLAGS="-w -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations"
export ARCH="linux-x86_64"
export CONF_OLD="$ARCH-normal-server-$MODE"
export CONF_NEW="$ARCH-server-$MODE"
export MAKE_IMAGES="make clean images"
export OPENJDK_BASE="/home/chris/openjdk"
export TAR_CREATE="tar -czhf"
export VENDOR_NAME="chriswhocodes"
export VENDOR_VERSION="nightly"
export IMAGE_SUFFIX="$VENDOR_NAME-$VENDOR_VERSION-$ARCH-$MODE"
export BASE_CONFIGURE="sh ./configure"

echo "========================= BUILDING JDK 8"
export JAVA_HOME=/home/chris/java8
cd $OPENJDK_BASE/jdk8u
$BASE_CONFIGURE --with-extra-cflags="$EXTRA_C_FLAGS"
$MAKE_IMAGES CONF=$CONF_OLD

export JDK_IMAGE=j2sdk-image
export ARCHIVE_NAME=jdk8-$IMAGE_SUFFIX
cd build/$CONF_OLD/images
mv $JDK_IMAGE $ARCHIVE_NAME
$TAR_CREATE $ARCHIVE_NAME.tgz $ARCHIVE_NAME
mv $ARCHIVE_NAME $JDK_IMAGE
mv $ARCHIVE_NAME.tgz $OPENJDK_BASE

echo "========================= BUILDING JDK 9"
export JAVA_HOME=/home/chris/java8
cd $OPENJDK_BASE/jdk9-dev
$BASE_CONFIGURE --with-extra-cflags="$EXTRA_C_FLAGS"
$MAKE_IMAGES CONF=$CONF_OLD

export JDK_IMAGE=jdk
export ARCHIVE_NAME=jdk9-$IMAGE_SUFFIX
cd build/$CONF_OLD/images
mv $JDK_IMAGE $ARCHIVE_NAME
$TAR_CREATE $ARCHIVE_NAME.tgz $ARCHIVE_NAME
mv $ARCHIVE_NAME $JDK_IMAGE
mv $ARCHIVE_NAME.tgz $OPENJDK_BASE

echo "========================= BUILDING JDK 10"
export JAVA_HOME=$OPENJDK_BASE/jdk9-dev/build/$CONF_OLD/jdk
cd $OPENJDK_BASE/jdk10
$BASE_CONFIGURE --with-extra-cflags="$EXTRA_C_FLAGS" --with-vendor-name=$VENDOR_NAME --with-vendor-version-string=$VENDOR_VERSION
$MAKE_IMAGES CONF=$CONF_OLD

export JDK_IMAGE=jdk
export ARCHIVE_NAME=jdk10-$IMAGE_SUFFIX
cd build/$CONF_OLD/images
mv $JDK_IMAGE $ARCHIVE_NAME
$TAR_CREATE $ARCHIVE_NAME.tgz $ARCHIVE_NAME
mv $ARCHIVE_NAME $JDK_IMAGE
mv $ARCHIVE_NAME.tgz $OPENJDK_BASE

echo "========================= BUILDING JDK 11"
export JAVA_HOME=$OPENJDK_BASE/jdk10/build/$CONF_OLD/jdk
cd $OPENJDK_BASE/jdk11
$BASE_CONFIGURE --with-extra-cflags="$EXTRA_C_FLAGS" --with-vendor-name=$VENDOR_NAME --with-vendor-version-string=$VENDOR_VERSION
$MAKE_IMAGES CONF=$CONF_OLD

export JDK_IMAGE=jdk
export ARCHIVE_NAME=jdk11-$IMAGE_SUFFIX
cd build/$CONF_OLD/images
mv $JDK_IMAGE $ARCHIVE_NAME
$TAR_CREATE $ARCHIVE_NAME.tgz $ARCHIVE_NAME
mv $ARCHIVE_NAME $JDK_IMAGE
mv $ARCHIVE_NAME.tgz $OPENJDK_BASE

echo "========================= BUILDING JDK 12"
export JAVA_HOME=$OPENJDK_BASE/jdk11/build/$CONF_OLD/jdk
cd $OPENJDK_BASE/jdk12
$BASE_CONFIGURE --with-extra-cflags="$EXTRA_C_FLAGS" --with-vendor-name=$VENDOR_NAME --with-vendor-version-string=$VENDOR_VERSION
$MAKE_IMAGES CONF=$CONF_NEW

export JDK_IMAGE=jdk
export ARCHIVE_NAME=jdk12-$IMAGE_SUFFIX
cd build/$CONF_NEW/images
mv $JDK_IMAGE $ARCHIVE_NAME
$TAR_CREATE $ARCHIVE_NAME.tgz $ARCHIVE_NAME
mv $ARCHIVE_NAME $JDK_IMAGE
mv $ARCHIVE_NAME.tgz $OPENJDK_BASE

echo "========================= BUILDING JDK 13"
export JAVA_HOME=$OPENJDK_BASE/jdk12/build/$CONF_NEW/jdk
cd $OPENJDK_BASE/jdk13
$BASE_CONFIGURE --with-extra-cflags="$EXTRA_C_FLAGS" --with-vendor-name=$VENDOR_NAME --with-vendor-version-string=$VENDOR_VERSION
$MAKE_IMAGES CONF=$CONF_NEW

export JDK_IMAGE=jdk
export ARCHIVE_NAME=jdk13-$IMAGE_SUFFIX
cd build/$CONF_NEW/images
mv $JDK_IMAGE $ARCHIVE_NAME
$TAR_CREATE $ARCHIVE_NAME.tgz $ARCHIVE_NAME
mv $ARCHIVE_NAME $JDK_IMAGE
mv $ARCHIVE_NAME.tgz $OPENJDK_BASE