#!/bin/bash BINUTILS_VERSION="2.35" BINUTILS_CHECKSUM="1b11659fb49e20e18db460d44485f09442c8c56d5df165de9461eb09c8302f85" GCC_VERSION="10.2.0" GCC_CHECKSUM="b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c" if [ ! -e binutils-${BINUTILS_VERSION}.tar.xz ]; then wget -O binutils-${BINUTILS_VERSION}.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz fi if [[ ! `sha256sum binutils-${BINUTILS_VERSION}.tar.xz` =~ $BINUTILS_CHECKSUM ]]; then echo "Invalid binutils-${BINUTILS_VERSION}.tar.xz checksum" exit fi if [ ! -d binutils-${BINUTILS_VERSION} ]; then tar xJf binutils-${BINUTILS_VERSION}.tar.xz fi if [ ! -e gcc-${GCC_VERSION}.tar.xz ]; then wget -O gcc-${GCC_VERSION}.tar.xz https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz fi if [[ ! `sha256sum gcc-${GCC_VERSION}.tar.xz` =~ $GCC_CHECKSUM ]]; then echo "Invalid gcc-${GCC_VERSION}.tar.xz checksum" exit fi if [ ! -d gcc-${GCC_VERSION} ]; then tar xJf gcc-${GCC_VERSION}.tar.xz fi export PREFIX="$PWD/i686-elf-gcc" export TARGET="i686-elf" export PATH="$PREFIX/bin:$PATH" function build_binutils() { rm -rf build-binutils mkdir -p build-binutils ( cd build-binutils ../binutils-${BINUTILS_VERSION}/configure --target="$TARGET" --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror && \ make && \ make install ) } function build_gcc() { rm -rf build-gcc mkdir -p build-gcc ( cd build-gcc ../gcc-${GCC_VERSION}/configure --target="$TARGET" --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers && \ make all-gcc && \ make all-target-libgcc && \ make install-gcc && \ make install-target-libgcc ) } build_binutils && build_gcc