Build gzip and nasm as part of the toolchain to ensure reproducibility

This commit is contained in:
mintsuki 2020-09-18 21:38:59 +02:00
parent 73fa01d1d0
commit 8410abb3d9
4 changed files with 40 additions and 25 deletions

View File

@ -1,5 +1,6 @@
CC = cc
CFLAGS = -O2 -pipe -Wall -Wextra
PATH := $(shell pwd)/toolchain/bin:$(PATH)
.PHONY: all clean stage2 stage2-clean decompressor decompressor-clean toolchain test.img echfs-test ext2-test fat32-test
@ -10,7 +11,6 @@ all: stage2 decompressor
clean: stage2-clean decompressor-clean
rm -f stage2/stage2.bin.gz
rm -f limine-install
# We don't remove limine.bin because not everyone wants to build the bootloader themselves.
stage2:
$(MAKE) -C stage2 all

View File

@ -1,6 +1,6 @@
CC = ../toolchain/bin/i386-elf-gcc
LD = ../toolchain/bin/i386-elf-gcc
OBJCOPY = ../toolchain/bin/i386-elf-objcopy
CC = i386-elf-gcc
LD = i386-elf-gcc
OBJCOPY = i386-elf-objcopy
CFLAGS = -flto -Os -pipe -Wall -Wextra

View File

@ -1,6 +1,6 @@
CC = ../toolchain/bin/i386-elf-gcc
LD = ../toolchain/bin/i386-elf-gcc
OBJCOPY = ../toolchain/bin/i386-elf-objcopy
CC = i386-elf-gcc
LD = i386-elf-gcc
OBJCOPY = i386-elf-objcopy
CFLAGS = -flto -Os -pipe -Wall -Wextra

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
set -e
set -x
@ -7,6 +7,8 @@ PREFIX="$(pwd)"
TARGET=i386-elf
BINUTILSVERSION=2.35
GCCVERSION=10.2.0
NASMVERSION=2.15.05
GZIPVERSION=1.10
if [ -z "$MAKEFLAGS" ]; then
MAKEFLAGS="$1"
@ -15,29 +17,27 @@ export MAKEFLAGS
export PATH="$PREFIX/bin:$PATH"
if [ -x "$(command -v gmake)" ]; then
mkdir -p "$PREFIX/bin"
cat <<EOF >"$PREFIX/bin/make"
#!/usr/bin/env sh
gmake "\$@"
EOF
chmod +x "$PREFIX/bin/make"
fi
mkdir -p build
cd build
if [ ! -f binutils-$BINUTILSVERSION.tar.gz ]; then
wget -4 https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILSVERSION.tar.gz # Force IPv4 otherwise wget hangs
wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILSVERSION.tar.gz
fi
if [ ! -f gcc-$GCCVERSION.tar.gz ]; then
wget -4 https://ftp.gnu.org/gnu/gcc/gcc-$GCCVERSION/gcc-$GCCVERSION.tar.gz # Same as above
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
fi
tar -xf binutils-$BINUTILSVERSION.tar.gz
tar -xf gcc-$GCCVERSION.tar.gz
rm -rf build
mkdir build
cd build
rm -rf build-gcc build-binutils
tar -xf ../binutils-$BINUTILSVERSION.tar.gz
tar -xf ../gcc-$GCCVERSION.tar.gz
tar -xf ../nasm-$NASMVERSION.tar.gz
tar -xf ../gzip-$GZIPVERSION.tar.gz
mkdir build-binutils
cd build-binutils
@ -56,3 +56,18 @@ make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
cd ..
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 ..