diff --git a/tools/setup-autoconf.sh b/tools/setup-autoconf.sh new file mode 100755 index 00000000..9ccd18f6 --- /dev/null +++ b/tools/setup-autoconf.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -e +source $(dirname $0)/setup-env.sh + +cd $LUNA_ROOT + +# libstdc++ needs autoconf (precisely version 2.69) so if the user has an older/more recent version, we must build autoconf from source. + +export AUTOCONF_VERSION=2.69 + +mkdir -p toolchain/tarballs +mkdir -p toolchain/build + +if [ ! -f toolchain/tarballs/autoconf-$AUTOCONF_VERSION.tar.gz ]; then + echo Downloading autoconf (precisely version 2.69)... + + wget -Otoolchain/tarballs/autoconf-$AUTOCONF_VERSION.tar.gz https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.gz +fi + +rm -rf toolchain/build/build-autoconf +rm -rf toolchain/build/autoconf-$AUTOCONF_VERSION + +echo Extracting autoconf (precisely version 2.69)... + +tar xf toolchain/tarballs/autoconf-$AUTOCONF_VERSION.tar.xz -C toolchain/build/ + +mkdir -p toolchain/build/build-autoconf + +cd toolchain/build/build-autoconf + +unset CC +unset CXX +unset LD +unset AR + +echo Building autoconf (precisely version 2.69)... + +../autoconf-$AUTOCONF_VERSION/configure --prefix="/" +make +DESTDIR=$LUNA_ROOT/toolchain/dist make install diff --git a/tools/setup-gcc.sh b/tools/setup-gcc.sh index 773352c4..b31fa492 100755 --- a/tools/setup-gcc.sh +++ b/tools/setup-gcc.sh @@ -36,6 +36,10 @@ patch -u -i $LUNA_ROOT/tools/gcc.patch -p 1 -d build cd - +cd toolchain/build/gcc-$LUNA_GCC_VERSION_REQUIRED/libstdc++-v3 +autoconf +cd - + echo Configuring GCC... mkdir -p toolchain/build/gcc-$LUNA_ARCH diff --git a/tools/setup.sh b/tools/setup.sh index c14ba50c..889c5fc6 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -1,6 +1,12 @@ #!/usr/bin/env bash set -e +if ! $(dirname $0)/test-autoconf.sh +then + echo Building autoconf... + $(dirname $0)/setup-autoconf.sh +fi + if ! $(dirname $0)/test-binutils.sh then echo Building Binutils... @@ -17,4 +23,4 @@ if ! [ -f $(dirname $0)/../toolchain/dist/mkbootimg ] then echo Building mkbootimg... $(dirname $0)/setup-mkbootimg.sh -fi \ No newline at end of file +fi diff --git a/tools/test-autoconf.sh b/tools/test-autoconf.sh new file mode 100755 index 00000000..53955dc5 --- /dev/null +++ b/tools/test-autoconf.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e +source $(dirname $0)/setup-env.sh + +if [ -x "$(command -v autoconf)" ] +then + if [ "$(autoconf --version | head -n 1 | awk '{ print $4 }')" == "2.69" ] + then + exit 0 + else + echo "You have autoconf installed, but it is not version 2.69, which is required by libstdc++. Thus, we must build autoconf from source." + exit 1 + fi +else +exit 1 +fi