summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/0000-prepare-os.sh25
-rwxr-xr-xscripts/0100-download.sh8
-rwxr-xr-xscripts/0150-build-static-deps.sh55
-rwxr-xr-xscripts/0200-build-target-binutils.sh5
-rwxr-xr-xscripts/0300-build-bootstrap-gcc.sh8
-rwxr-xr-xscripts/0500-build-target-gcc.sh6
-rwxr-xr-xscripts/0600-build-target-gdb.sh15
7 files changed, 106 insertions, 16 deletions
diff --git a/scripts/0000-prepare-os.sh b/scripts/0000-prepare-os.sh
index 33b0deb..a2039ad 100755
--- a/scripts/0000-prepare-os.sh
+++ b/scripts/0000-prepare-os.sh
@@ -2,14 +2,21 @@
set -e
-pacman --noconfirm -Syu
+export DEBIAN_FRONTEND=noninteractive
-pacman --noconfirm --needed -S \
- base-devel \
- libelf \
- libmpc \
- zlib
+apt-get update
-pacman --noconfirm --needed --asdeps -S \
- gmp \
- mpfr
+apt-get install -y --no-install-recommends \
+ build-essential \
+ bison \
+ curl \
+ ca-certificates \
+ flex \
+ gawk \
+ libtool \
+ patch \
+ texinfo \
+ wget \
+ xz-utils
+
+rm -rf /var/lib/apt/lists/*
diff --git a/scripts/0100-download.sh b/scripts/0100-download.sh
index 03bd544..761fbf0 100755
--- a/scripts/0100-download.sh
+++ b/scripts/0100-download.sh
@@ -8,3 +8,11 @@ curl -LO -C - ftp://sourceware.org/pub/newlib/newlib-$NEWLIB_VERSION.tar.gz
curl -LO -C - http://ftp.gwdg.de/pub/linux/sources.redhat.com/binutils/releases/binutils-$BINUTILS_VERSION.tar.xz
curl -LO -C - http://ftp.gwdg.de/pub/linux/sources.redhat.com/gcc/releases/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz
curl -LO -C - http://ftp.gwdg.de/pub/linux/sources.redhat.com/gdb/releases/gdb-$GDB_VERSION.tar.xz
+
+curl -LO -C - https://zlib.net/zlib-$ZLIB_VERSION.tar.gz
+curl -LO -C - https://ftp.gnu.org/gnu/ncurses/ncurses-$NCURSES_VERSION.tar.gz
+curl -LO -C - https://github.com/libexpat/libexpat/releases/download/R_${EXPAT_VERSION//./_}/expat-$EXPAT_VERSION.tar.gz
+curl -LO -C - https://ftp.gnu.org/gnu/readline/readline-$READLINE_VERSION.tar.gz
+curl -LO -C - https://ftp.gnu.org/gnu/gmp/gmp-$GMP_VERSION.tar.xz
+curl -LO -C - https://www.mpfr.org/mpfr-$MPFR_VERSION/mpfr-$MPFR_VERSION.tar.xz
+curl -LO -C - https://ftp.gnu.org/gnu/mpc/mpc-$MPC_VERSION.tar.gz
diff --git a/scripts/0150-build-static-deps.sh b/scripts/0150-build-static-deps.sh
new file mode 100755
index 0000000..d0a460f
--- /dev/null
+++ b/scripts/0150-build-static-deps.sh
@@ -0,0 +1,55 @@
+#!/bin/env bash
+
+set -e
+
+mkdir -p $STATIC_DEPS_PREFIX/include $STATIC_DEPS_PREFIX/lib
+mkdir -p /static-deps && cd /static-deps
+
+echo "Building static zlib..."
+tar xf /downloads/zlib-$ZLIB_VERSION.tar.gz
+cd zlib-$ZLIB_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --static
+make -j$(nproc) && make install
+cd ..
+
+echo "Building static ncurses..."
+tar xf /downloads/ncurses-$NCURSES_VERSION.tar.gz
+cd ncurses-$NCURSES_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --disable-shared --enable-static --with-termlib
+make -j$(nproc) && make install
+cd ..
+
+echo "Building static expat..."
+tar xf /downloads/expat-$EXPAT_VERSION.tar.gz
+cd expat-$EXPAT_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --disable-shared --enable-static
+make -j$(nproc) && make install
+cd ..
+
+echo "Building static readline..."
+tar xf /downloads/readline-$READLINE_VERSION.tar.gz
+cd readline-$READLINE_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --disable-shared --enable-static
+make -j$(nproc) && make install
+cd ..
+
+echo "Building static gmp..."
+tar xf /downloads/gmp-$GMP_VERSION.tar.xz
+cd gmp-$GMP_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --disable-shared --enable-static
+make -j$(nproc) && make install
+cd ..
+
+echo "Building static mpfr..."
+tar xf /downloads/mpfr-$MPFR_VERSION.tar.xz
+cd mpfr-$MPFR_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --with-gmp=$STATIC_DEPS_PREFIX --disable-shared --enable-static
+make -j$(nproc) && make install
+cd ..
+
+echo "Building static mpc..."
+tar xf /downloads/mpc-$MPC_VERSION.tar.gz
+cd mpc-$MPC_VERSION
+./configure --prefix=$STATIC_DEPS_PREFIX --with-gmp=$STATIC_DEPS_PREFIX --with-mpfr=$STATIC_DEPS_PREFIX --disable-shared --enable-static
+make -j$(nproc) && make install
+cd ..
diff --git a/scripts/0200-build-target-binutils.sh b/scripts/0200-build-target-binutils.sh
index 6afcc43..78974ec 100755
--- a/scripts/0200-build-target-binutils.sh
+++ b/scripts/0200-build-target-binutils.sh
@@ -14,7 +14,10 @@ cd .build
--enable-colored-disassembly \
--prefix=/opt/toolchain \
--target=$TARGET \
- --with-pic
+ --with-pic \
+ --with-zlib=yes \
+ CPPFLAGS="-I$STATIC_DEPS_PREFIX/include" \
+ LDFLAGS="-L$STATIC_DEPS_PREFIX/lib"
make -j$(nproc)
diff --git a/scripts/0300-build-bootstrap-gcc.sh b/scripts/0300-build-bootstrap-gcc.sh
index f5c28e7..e5ee70b 100755
--- a/scripts/0300-build-bootstrap-gcc.sh
+++ b/scripts/0300-build-bootstrap-gcc.sh
@@ -8,6 +8,8 @@ tar xf /downloads/gcc-$GCC_VERSION.tar.xz
cd gcc-$GCC_VERSION
+./contrib/download_prerequisites
+
for PATCH in $(ls /patches/gcc-$GCC_VERSION-$TARGET/*.patch); do
patch -p0 -i $PATCH
done
@@ -23,7 +25,11 @@ PATH=/opt/bootstrap/bin:/opt/toolchain/bin:$PATH
--enable-languages=c,c++ \
--prefix=/opt/bootstrap \
--target=$TARGET \
- --without-headers
+ --with-as=/opt/toolchain/bin/${TARGET}-as \
+ --with-ld=/opt/toolchain/bin/${TARGET}-ld \
+ --without-headers \
+ CPPFLAGS="-I$STATIC_DEPS_PREFIX/include" \
+ LDFLAGS="-L$STATIC_DEPS_PREFIX/lib"
make -j$(nproc) all-gcc
make install-gcc
diff --git a/scripts/0500-build-target-gcc.sh b/scripts/0500-build-target-gcc.sh
index e3053f8..47249f9 100755
--- a/scripts/0500-build-target-gcc.sh
+++ b/scripts/0500-build-target-gcc.sh
@@ -8,7 +8,7 @@ CFLAGS=${CFLAGS/-Werror=format-security/}
CXXFLAGS=${CXXFLAGS/-Werror=format-security/}
PATH=/opt/bootstrap/bin:/opt/toolchain/bin:$PATH
-../gcc-$GCC_VERSION/configure \
+../gcc-$GCC_VERSION/configure \
--disable-hosted-libstdcxx \
--disable-nls \
--disable-tm-clone-registry \
@@ -21,7 +21,9 @@ PATH=/opt/bootstrap/bin:/opt/toolchain/bin:$PATH
--prefix=/opt/toolchain \
--target=$TARGET \
--with-mcmodel=kernel \
- --with-newlib
+ --with-newlib \
+ CPPFLAGS="-I$STATIC_DEPS_PREFIX/include" \
+ LDFLAGS="-L$STATIC_DEPS_PREFIX/lib"
make -j$(nproc) all-gcc
make install-strip-gcc
diff --git a/scripts/0600-build-target-gdb.sh b/scripts/0600-build-target-gdb.sh
index 85184de..8e984d8 100755
--- a/scripts/0600-build-target-gdb.sh
+++ b/scripts/0600-build-target-gdb.sh
@@ -10,9 +10,18 @@ tar xf /downloads/gdb-$GDB_VERSION.tar.xz
cd .build
-../gdb-$GDB_VERSION/configure \
- --prefix=/opt/toolchain \
- --target=$TARGET
+../gdb-$GDB_VERSION/configure \
+ --prefix=/opt/toolchain \
+ --target=$TARGET \
+ --disable-nls \
+ --disable-werror \
+ --with-gmp=$STATIC_DEPS_PREFIX \
+ --with-mpfr=$STATIC_DEPS_PREFIX \
+ --with-python=no \
+ --with-expat=yes \
+ --with-zlib=yes \
+ CPPFLAGS="-I$STATIC_DEPS_PREFIX/include -I$STATIC_DEPS_PREFIX/include/ncursesw" \
+ LDFLAGS="-L$STATIC_DEPS_PREFIX/lib"
make -j$(nproc) all-gdb
make install-strip-gdb