2021-03-08 10:09:15 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
TARGET=x86_64-elf
|
|
|
|
BINUTILSVERSION=2.36.1
|
2021-05-04 14:56:00 +03:00
|
|
|
GCCVERSION=11.1.0
|
2021-03-08 10:09:15 +03:00
|
|
|
|
2021-04-03 01:48:38 +03:00
|
|
|
CFLAGS="-O2 -pipe"
|
|
|
|
|
2021-03-08 10:09:15 +03:00
|
|
|
mkdir -p "$1" && cd "$1"
|
|
|
|
PREFIX="$(pwd)"
|
|
|
|
|
|
|
|
export MAKEFLAGS="$2"
|
|
|
|
|
|
|
|
export PATH="$PREFIX/bin:$PATH"
|
|
|
|
|
|
|
|
if [ ! -f binutils-$BINUTILSVERSION.tar.gz ]; then
|
|
|
|
wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILSVERSION.tar.gz
|
|
|
|
fi
|
|
|
|
if [ ! -f gcc-$GCCVERSION.tar.gz ]; then
|
|
|
|
wget https://ftp.gnu.org/gnu/gcc/gcc-$GCCVERSION/gcc-$GCCVERSION.tar.gz
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf build
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
|
|
|
|
tar -xf ../binutils-$BINUTILSVERSION.tar.gz
|
|
|
|
tar -xf ../gcc-$GCCVERSION.tar.gz
|
|
|
|
|
|
|
|
mkdir build-binutils
|
|
|
|
cd build-binutils
|
2021-04-03 01:48:38 +03:00
|
|
|
../binutils-$BINUTILSVERSION/configure CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror --enable-targets=x86_64-elf,x86_64-pe
|
2021-03-08 10:09:15 +03:00
|
|
|
make
|
|
|
|
make install
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
cd gcc-$GCCVERSION
|
|
|
|
contrib/download_prerequisites
|
|
|
|
cd ..
|
|
|
|
mkdir build-gcc
|
|
|
|
cd build-gcc
|
2021-04-03 01:48:38 +03:00
|
|
|
../gcc-$GCCVERSION/configure CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers
|
2021-03-08 10:09:15 +03:00
|
|
|
make all-gcc
|
|
|
|
make all-target-libgcc
|
|
|
|
make install-gcc
|
|
|
|
make install-target-libgcc
|
|
|
|
cd ..
|