#!/bin/bash # # Copyright (c) 2017 The Altra64 project contributors # See LICENSE file in the project root for full license information. # set -euxo pipefail # Download and install latest updates for the system [sudo req.] apt-get update apt-get -y upgrade # Install essential packages [sudo req.] apt-get -y install wget build-essential git texinfo libc6 libgmp-dev libmpfr-dev libmpc-dev libpng-dev zlib1g-dev libtool autoconf # change to the users root directory cd ~/ # add a system variable and make it perminent # echo 'N64_INST=/usr/local/libdragon' >> /etc/environment # echo 'export N64_INST=/usr/local/libdragon' >> ~/.bashrc export N64_INST=/usr/local/libdragon # EDIT THIS LINE TO CHANGE YOUR INSTALL PATH! export INSTALL_PATH=/usr/local/libdragon # Set up path for newlib to compile later export PATH=$PATH:$INSTALL_PATH/bin # Versions export BINUTILS_V=2.27 export GCC_V=6.2.0 export NEWLIB_V=2.4.0 export BINUTILS_V=2.37 #export GCC_V=11.2.0 #export NEWLIB_V=4.1.0 export GCC_V=4.6.4 # make a build folder for libdragon mkdir build_gcc cd build_gcc # Download stage #wget -c ftp://sourceware.org/pub/binutils/releases/binutils-$BINUTILS_V.tar.bz2 wget -c https://sourceware.org/pub/binutils/releases/binutils-$BINUTILS_V.tar.xz wget -c https://sourceware.org/pub/gcc/releases/gcc-$GCC_V/gcc-$GCC_V.tar.bz2 #wget -c https://sourceware.org/pub/gcc/releases/gcc-$GCC_V/gcc-$GCC_V.tar.xz wget -c https://sourceware.org/pub/newlib/newlib-$NEWLIB_V.tar.gz # Extract stage test -d binutils-$BINUTILS_V || tar -xvJf binutils-$BINUTILS_V.tar.xz || tar -xvjf binutils-$BINUTILS_V.tar.bz2 test -d gcc-$GCC_V || tar -xvJf gcc-$GCC_V.tar.xz || tar -xvjf gcc-$GCC_V.tar.bz2 test -d newlib-$NEWLIB_V || tar -xvzf newlib-$NEWLIB_V.tar.gz # Binutils and newlib support compiling in source directory, GCC does not # Compile binutils cd binutils-$BINUTILS_V ./configure --prefix=${INSTALL_PATH} --target=mips64-elf --with-cpu=mips64vr4300 --disable-werror make -j9 make install cd .. # Compile gcc (pass 1) rm -rf gcc_compile mkdir gcc_compile cd gcc_compile CFLAGS_FOR_TARGET="-G0 -mabi=32 -march=vr4300 -mtune=vr4300 -O2" ../gcc-$GCC_V/configure --prefix=${INSTALL_PATH} --target=mips64-elf --enable-languages=c --without-headers --with-newlib --with-system-zlib --disable-libssp --enable-multilib --disable-shared --with-gcc --with-gnu-ld --with-gnu-as --disable-threads --disable-win32-registry --disable-nls --disable-debug --disable-libmudflap --disable-werror make -j9 make install cd .. # hacky hack hack mv /usr/local/libdragon/bin/mips64-elf-gcc /usr/local/libdragon/bin/mips64-elf-gcc.orig cat > /usr/local/libdragon/bin/mips64-elf-gcc <> ~/.bashrc #echo 'export PATH="$PATH:$N64_INST/bin"' >> ~/.bashrc