diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | tools/dep_builders/binutils | 47 | ||||
-rwxr-xr-x | tools/dep_builders/dl | 9 | ||||
-rwxr-xr-x | tools/dep_builders/gcc | 54 |
5 files changed, 113 insertions, 0 deletions
@@ -1 +1,2 @@ out/ +toolchain/ @@ -1,3 +1,5 @@ +PATH := $(shell pwd)/toolchain/bin/:$(PATH) + AS = i686-elf-as CC = i686-elf-gcc CFLAGS = -std=gnu99 -ffreestanding -O2 -Wall -Wextra diff --git a/tools/dep_builders/binutils b/tools/dep_builders/binutils new file mode 100755 index 0000000..210c13b --- /dev/null +++ b/tools/dep_builders/binutils @@ -0,0 +1,47 @@ +#!/bin/sh +set -eu + +TOOL="binutils" +VER="2.37" +# this is ugly +{ HASHES=$(cat) ; } <<'HASHES' +c44968b97cd86499efbc4b4ab7d98471f673e5414c554ef54afa930062dbbfcb toolchain/cache/binutils-2.37.tar.gz +HASHES + +export PREFIX="$(pwd)/toolchain/" +export CACHE="$(pwd)/toolchain/cache/" +export PATH="$(pwd)/toolchain/bin/:$PATH" +export TARGET=i686-elf + + +# ensure that we're in the repo root +if [ ! -d .git ]; then + echo please cd to the repo\'s main directory + exit +fi + +mkdir -p $PREFIX + +echo "downloading missing files..." +tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER.tar.gz" +tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER.tar.gz.sig" +tools/dep_builders/dl "https://ftp.gnu.org/gnu/gnu-keyring.gpg" + +echo "verifying signatures..." +if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg $CACHE/$TOOL-$VER.tar.gz.sig +then + echo "THE SIGNATURE COULDN'T BE VERIFIED. something's fishy." + exit +fi +echo "$HASHES" | sha256sum --check || exit + +echo "unpacking the tarball..." +tar xf toolchain/cache/$TOOL-$VER.tar.gz -C toolchain/cache + +echo "building..." +rm -rf $CACHE/$TOOL-$VER/builddir +mkdir $CACHE/$TOOL-$VER/builddir +cd $CACHE/$TOOL-$VER/builddir +../configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror +make +make install diff --git a/tools/dep_builders/dl b/tools/dep_builders/dl new file mode 100755 index 0000000..8cfeebc --- /dev/null +++ b/tools/dep_builders/dl @@ -0,0 +1,9 @@ +#!/bin/sh +# downloads a file to toolchain/cache unless it's already present there + +mkdir -p toolchain/cache +OUT="toolchain/cache/$(basename $1)" + +[ -e "$OUT" ] && exit +echo "downloading $1..." +curl "$1" > $OUT diff --git a/tools/dep_builders/gcc b/tools/dep_builders/gcc new file mode 100755 index 0000000..4c32b53 --- /dev/null +++ b/tools/dep_builders/gcc @@ -0,0 +1,54 @@ +#!/bin/sh +set -eu + +TOOL="gcc" +VER="11.2.0" +# this is ugly +{ HASHES=$(cat) ; } <<'HASHES' +f0837f1bf8244a5cc23bd96ff6366712a791cfae01df8e25b137698aca26efc1 toolchain/cache/gcc-11.2.0.tar.gz +HASHES + +export PREFIX="$(pwd)/toolchain/" +export CACHE="$(pwd)/toolchain/cache/" +export PATH="$(pwd)/toolchain/bin/:$PATH" +export TARGET=i686-elf + + +# ensure that we're in the repo root +if [ ! -d .git ]; then + echo please cd to the repo\'s main directory + exit +fi + +mkdir -p $PREFIX + +echo "downloading missing files..." +tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER/$TOOL-$VER.tar.gz" +tools/dep_builders/dl "https://ftp.gnu.org/gnu/$TOOL/$TOOL-$VER/$TOOL-$VER.tar.gz.sig" +tools/dep_builders/dl "https://ftp.gnu.org/gnu/gnu-keyring.gpg" + +echo "verifying signatures..." +if ! gpg --verify --keyring toolchain/cache/gnu-keyring.gpg $CACHE/$TOOL-$VER.tar.gz.sig +then + echo "THE SIGNATURE COULDN'T BE VERIFIED. something's fishy." + exit +fi +echo "$HASHES" | sha256sum --check || exit + +echo "unpacking the tarball..." +tar xf toolchain/cache/$TOOL-$VER.tar.gz -C $CACHE + +echo "downloading required libraries..." +cd $CACHE/$TOOL-$VER +./contrib/download_prerequisites + +echo "building..." +rm -rf $CACHE/$TOOL-$VER/builddir +mkdir $CACHE/$TOOL-$VER/builddir +cd $CACHE/$TOOL-$VER/builddir + +../configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c --without-headers +make all-gcc +make all-target-libgcc +make install-gcc +make install-target-libgcc |