#!/bin/sh set -e set -x bootstrapdir=$(mktemp -d -p $PWD bootstrap-XXXXXXXX) mkdir -p $bootstrapdir/tarballs mkdir -p $bootstrapdir/tools mkdir -p $bootstrapdir/sources mkdir -p $bootstrapdir/usr mkdir -p $bootstrapdir/usr/lib mkdir -p $bootstrapdir/usr/bin mkdir -p $bootstrapdir/etc mkdir -p $bootstrapdir/var mkdir -p $bootstrapdir/run mkdir -p $bootstrapdir/tmp mkdir -p $bootstrapdir/home mkdir -p $bootstrapdir/boot ln -s lib $bootstrapdir/usr/lib64 ln -s usr/lib $bootstrapdir/lib64 ln -s usr/lib $bootstrapdir/lib ln -s bin $bootstrapdir/usr/sbin ln -s usr/bin $bootstrapdir/bin ln -s usr/bin $bootstrapdir/sbin bootstrap_target=x86_64-rasde-linux-musl cores=$(nproc) cd $bootstrapdir/tarballs curl -L \ -O https://sourceware.org/pub/binutils/releases/binutils-2.47.tar.zst \ -O https://ftpmirror.gnu.org/gnu/gcc/gcc-16.2.0/gcc-16.2.0.tar.xz \ -O https://cdn.kernel.org/pub/linux/kernel/v7.x/linux-7.2.2.tar.xz \ -O https://musl.libc.org/releases/musl-1.2.6.tar.gz \ -O https://ftpmirror.gnu.org/pub/gnu/m4/m4-1.4.21.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/ncurses/ncurses-6.6.tar.gz \ -O https://ftpmirror.gnu.org/gnu/bash/bash-5.3.tar.gz \ -O https://ftpmirror.gnu.org/gnu/coreutils/coreutils-9.11.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/diffutils/diffutils-3.12.tar.xz \ -O http://ftp.astron.com/pub/file/file-5.48.tar.gz \ -O https://ftpmirror.gnu.org/pub/gnu/findutils/findutils-4.11.0.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/gawk/gawk-5.4.1.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/grep/grep-3.12.tar.xz \ -O https://ftpmirror.gnu.org/gnu/gzip/gzip-1.14.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/make/make-4.4.1.tar.lz \ -O https://ftpmirror.gnu.org/pub/gnu/patch/patch-2.8.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/sed/sed-4.10.tar.xz \ -O https://ftpmirror.gnu.org/gnu/tar/tar-1.35.tar.xz \ -O https://ftpmirror.gnu.org/gnu/mpfr/mpfr-4.2.2.tar.xz \ -O https://ftpmirror.gnu.org/pub/gnu/gmp/gmp-6.3.0.tar.xz \ -O https://ftpmirror.gnu.org/gnu/mpc/mpc-1.4.1.tar.xz \ -O https://tukaani.org/xz/xz-5.8.3.tar.gz for x in $(find $bootstrapdir/tarballs); do tar xf $x -C $bootstrapdir/sources done export PATH="$bootstrapdir/tools/bin:$PATH" cd $bootstrapdir/sources/binutils* mkdir build cd build ../configure --prefix=$bootstrapdir/tools \ --with-sysroot=$bootstrapdir \ --target=$bootstrap_target \ --disable-nls \ --enable-gprofng=no \ --disable-werror \ --enable-new-dtags \ --enable-default-hash-style=gnu make -j$cores make install -j$cores cd $bootstrapdir/sources/gcc* mkdir build cd build ../configure \ --target=$bootstrap_target \ --prefix=$bootstrapdir/tools \ --with-sysroot=$bootstrapdir \ --with-newlib \ --without-headers \ --enable-default-pie \ --enable-default-ssp \ --disable-nls \ --disable-shared \ --disable-multilib \ --disable-threads \ --disable-libatomic \ --disable-libgomp \ --disable-libquadmath \ --disable-libssp \ --disable-libvtv \ --disable-libstdcxx \ --enable-languages=c,c++ make -j$cores make install -j$cores cd $bootstrapdir/sources/linux* make mrproper -j$cores make headers -j$cores make headers_install -j$cores cp -r ./usr/include $bootstrapdir/usr cd $bootstrapdir/sources/musl* ./configure --prefix=/usr make -j$cores make DESTDIR=$bootstrapdir install -j$cores ln -s ../lib/libc.so $bootstrapdir/usr/bin/ldd cd $bootstrapdir/sources/gcc* mkdir build-libstdcpp cd build-libstdcpp ../libstdc++-v3/configure \ --host=$bootstrap_target \ --build=$(../config.guess) \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --disable-libstdcxx-pch \ --with-gxx-include-dir=/tools/$boostrap_target/include/c++/16.2.0 make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/m4* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install j$cores cd $bootstrapdir/sources/ncurses* mkdir build pushd build ../configure --prefix=$bootstrapdir/tools AWK=gawk make -C include make -C progs tic install progs/tic $bootstrapdir/tools/bin popd ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(./config.guess) \ --mandir=/usr/share/man \ --with-manpage-format=normal \ --with-shared \ --with-normal \ --disable-widenc \ --with-cxx-shared \ --without-debug \ --without-ada \ --disable-stripping \ AWK=gawk make -j$cores make DESTDIR=$bootstrapdir install -j$cores make distclean ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(./config.guess) \ --mandir=/usr/share/man \ --with-manpage-format=normal \ --with-shared \ --enable-widenc \ --with-cxx-shared \ --without-debug \ --without-ada \ --disable-stripping \ AWK=gawk make -j$cores make DESTDIR=$bootstrapdir install -j$cores ln -sf libncurses.so $bootstrapdir/usr/lib/libcurses.so ln -sf libncurses.a $bootstrapdir/usr/lib/libcurses.a cd $bootstrapdir/sources/bash* ./configure --prefix=/usr \ --build=$(sh support/config.guess) \ --host=$bootstrap_target \ --without-bash-malloc make -j$cores make DESTDIR=$bootstrapdir install -j$cores ln -s bash $bootstrapdir/bin/sh cd $bootstrapdir/sources/coreutils* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) \ --enable-install-program=hostname \ --enable-no-install-program=kill,uptime make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/diffutils* ./configure --prefix=/usr \ --host=$bootstrap_target \ gl_cv_func_strcasecmp_works=y \ --build=$(./build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/file* mkdir build pushd build ../configure --disable-bzlib \ --disable-libseccomp \ --disable-xzlib \ --disable-zlib make popd ./configure --prefix=/usr --host=$bootstrap_target --build=$(./config.guess) make FILE_COMPILE=$(pwd)/build/src/file make DESTDIR=$bootstrapdir install rm -v $bootstrapdir/usr/lib/libmagic.la cd $bootstrapdir/sources/findutils* ./configure --prefix=/usr \ --localstatedir=/var/lib/locate \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/gawk* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/grep* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(./build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/gzip* ./configure --prefix=/usr --host=$bootstrap_target make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/make* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/patch* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/sed* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/tar* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores cd $bootstrapdir/sources/xz* ./configure --prefix=/usr \ --host=$bootstrap_target \ --build=$(build-aux/config.guess) make -j$cores make DESTDIR=$bootstrapdir install -j$cores rm -v $bootstrapdir/usr/lib/liblzma.la cd $bootstrapdir/sources/binutils* sed '6031s/$add_dir//' -i ltmain.sh rm -rf build mkdir build cd build ../configure \ --prefix=/usr \ --build=$(../config.guess) \ --host=$bootstrap_target \ --disable-nls \ --enable-shared \ --enable-gprofng=no \ --disable-werror \ --enable-64-bit-bfd \ --enable-new-dtags \ --enable-default-hash-style=gnu make -j$cores make DESTDIR=$bootstrapdir install -j$cores rm -v $bootstrapdir/usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes,sframe}.la cd $bootstrapdir/sources/gcc* rm -rf build mkdir build cd build ../configure \ --build=$(../config.guess) \ --host=$bootstrap_target \ --target=$bootstrap_target \ --prefix=/usr \ --with-build-sysroot=$bootstrapdir \ --enable-default-pie \ --enable-default-ssp \ --disable-nls \ --disable-multilib \ --disable-libatomic \ --disable-libgomp \ --disable-libquadmath \ --disable-libsanitizer \ --disable-libssp \ --disable-libvtv \ --enable-languages=c,c++ \ LDFLAGS_FOR_TARGET=-L$PWD/$bootstrap_target/libgcc make -j$cores make DESTDIR=$bootstrapdir install -j$cores ln -sv gcc $bootstrapdir/usr/bin/cc