rulimine/make_toolchain.sh

79 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/sh
2020-09-13 15:36:18 +03:00
set -e
set -x
2021-03-02 12:23:43 +03:00
TARGET="i386-elf x86_64-elf"
2021-02-07 16:17:01 +03:00
BINUTILSVERSION=2.36.1
2021-03-02 12:23:43 +03:00
GCCVERSION=10.2.0
NASMVERSION=2.15.05
GZIPVERSION=1.10
2020-09-13 15:36:18 +03:00
2021-02-25 08:12:32 +03:00
mkdir -p "$1" && cd "$1"
PREFIX="$(pwd)"
export MAKEFLAGS="$2"
2020-09-13 15:36:18 +03:00
export PATH="$PREFIX/bin:$PATH"
if [ ! -f binutils-$BINUTILSVERSION.tar.gz ]; then
wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILSVERSION.tar.gz
2020-09-13 15:36:18 +03:00
fi
if [ ! -f gcc-$GCCVERSION.tar.xz ]; then
2021-03-02 12:23:43 +03:00
wget https://ftp.gnu.org/gnu/gcc/gcc-$GCCVERSION/gcc-$GCCVERSION.tar.gz
fi
if [ ! -f nasm-$NASMVERSION.tar.gz ]; then
wget https://www.nasm.us/pub/nasm/releasebuilds/$NASMVERSION/nasm-$NASMVERSION.tar.gz
fi
if [ ! -f gzip-$GZIPVERSION.tar.gz ]; then
wget https://ftp.gnu.org/gnu/gzip/gzip-$GZIPVERSION.tar.gz
2020-09-13 15:36:18 +03:00
fi
rm -rf build
mkdir build
cd build
2020-09-13 15:36:18 +03:00
tar -xf ../binutils-$BINUTILSVERSION.tar.gz
2021-03-02 12:23:43 +03:00
tar -xf ../gcc-$GCCVERSION.tar.gz
tar -xf ../nasm-$NASMVERSION.tar.gz
tar -xf ../gzip-$GZIPVERSION.tar.gz
2020-09-13 15:36:18 +03:00
2021-03-02 12:23:43 +03:00
for i in $TARGET; do
rm -rf build-binutils
2020-09-13 15:36:18 +03:00
mkdir build-binutils
cd build-binutils
2021-03-02 12:23:43 +03:00
../binutils-$BINUTILSVERSION/configure --target=$i --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror $([ $i = "x86_64-elf" ] && echo --enable-targets=x86_64-elf,x86_64-pe) --enable-64-bit-bfd
2020-09-13 15:36:18 +03:00
make
make install
cd ..
2021-03-02 12:23:43 +03:00
done
2020-09-13 15:36:18 +03:00
cd gcc-$GCCVERSION
contrib/download_prerequisites
cd ..
2021-03-02 12:23:43 +03:00
for i in $TARGET; do
rm -rf build-gcc
2020-09-13 15:36:18 +03:00
mkdir build-gcc
cd build-gcc
2021-03-02 12:23:43 +03:00
../gcc-$GCCVERSION/configure --target=$i --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers
2020-09-13 15:36:18 +03:00
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
cd ..
2021-03-02 12:23:43 +03:00
done
mkdir build-nasm
cd build-nasm
../nasm-$NASMVERSION/configure --prefix="$PREFIX"
make
make install
cd ..
mkdir build-gzip
cd build-gzip
../gzip-$GZIPVERSION/configure --prefix="$PREFIX"
make
make install
cd ..