#!/bin/sh -e

export CFLAGS="$CFLAGS -static"

patch -p1 < bash-5.1-parallel_make.patch

for patch in bash51-0??; do
    patch -p0 < "$patch"
done

./configure \
    --prefix=/usr \
    --without-bash-malloc \
    --without-installed-readline \
    --disable-nls \
    --enable-static-link \
    ARFLAGS='-r -o'

make
make DESTDIR="$1" install

ln -s bash "$1/usr/bin/sh"
