#!/bin/bash # http://www.nongnu.org/avr-libc/user-manual/install_tools.html # Stop on errors set -e if [ ! -f .prereq ];then ./prerequise.sh ;fi archi=$(uname -m | awk {'print$1'} | head -c3) echo $archi source avr-file-names function binutils (){ # Figure out which version of the patch to use OLD_PATCH_CUTOFF="2.32" OLD_PATCH_CUTOFF_MAJ=${OLD_PATCH_CUTOFF%%.*} OLD_PATCH_CUTOFF_MIN=${OLD_PATCH_CUTOFF#*.} BINUTILS_VER=${NAME_BINUTILS#binutils-} BINUTILS_VER_MAJ=${BINUTILS_VER%%.*} BINUTILS_VER_MIN_TMP=${BINUTILS_VER#*.} BINUTILS_VER_MIN=${BINUTILS_VER_MIN_TMP%.*} if [ $BINUTILS_VER_MAJ -eq "1" ]; then echo "ERROR: Binutils version 1.xx is too old -- use at least version 2.xx" exit 1; fi if [ $BINUTILS_VER_MAJ -gt $OLD_PATCH_CUTOFF_MAJ ] || \ ( [ $BINUTILS_VER_MAJ -eq $OLD_PATCH_CUTOFF_MAJ ] && [ $BINUTILS_VER_MIN -gt $OLD_PATCH_CUTOFF_MIN ] ) ; then NAME_BINUTILS_SIZE_PATCH="avr-binutils-size-2.33.patch"; else NAME_BINUTILS_SIZE_PATCH="avr-binutils-size-2.32.patch"; fi TIME_START=$(date +%s) makeDir() { rm -rf "$1/" mkdir -p "$1" } echo "Downloading sources..." if [ ! -f $NAME_BINUTILS.tar.xz ]; then wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_BINUTILS.tar.xz fi # Make AVR-Binutils NAME_BINUTILS_BLD=${NAME_BINUTILS}_bld echo "Making Binutils in $NAME_BINUTILS_BLD..." echo "Extracting..." rm -rf $NAME_BINUTILS/ tar xJf $NAME_BINUTILS.tar.xz # Patch the size function cd $NAME_BINUTILS/binutils patch -p 1 < ../../pack/$NAME_BINUTILS_SIZE_PATCH cd ../.. makeDir $NAME_BINUTILS_BLD cd $NAME_BINUTILS_BLD ../$NAME_BINUTILS/configure --prefix=$PREFIX --target=avr --disable-nls make -j $JOBCOUNT sudo make install-strip cd .. TIME_END=$(date +%s) TIME_RUN=$(($TIME_END - $TIME_START)) echo "" echo "Done in $TIME_RUN seconds" } function avr-gcc () { source avr-file-names TIME_START=$(date +%s) makeDir() { rm -rf "$1/" mkdir -p "$1" } echo "Downloading sources..." if [ ! -f $NAME_GCC.tar.xz ]; then wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_GCC.tar.xz fi # Make AVR-GCC NAME_GCC_BLD=${NAME_GCC}_bld echo "Making GCC in $NAME_GCC_BLD..." echo "Extracting..." rm -rf $NAME_GCC/ tar xJf $NAME_GCC.tar.xz # Patch the download_prerequisites script cd $NAME_GCC sed -i 's/ftp/https/g' ./contrib/download_prerequisites ./contrib/download_prerequisites cd .. makeDir $NAME_GCC_BLD cd $NAME_GCC_BLD ../$NAME_GCC/configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --disable-libada --with-dwarf2 --disable-shared --enable-static make -j $JOBCOUNT sudo make install-strip cd .. TIME_END=$(date +%s) TIME_RUN=$(($TIME_END - $TIME_START)) echo "" echo "Done in $TIME_RUN seconds" } function avr-gdb () { source avr-file-names TIME_START=$(date +%s) makeDir() { rm -rf "$1/" mkdir -p "$1" } echo "Downloading sources..." if [ ! -f $NAME_GDB.tar.xz ]; then wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_GDB.tar.xz fi # Make AVR-libc NAME_GDB_BLD=${NAME_GDB}_bld echo "Making AVR-GDB in $NAME_GDB_BLD..." echo "Extracting..." rm -rf $NAME_GDB/ tar xJf $NAME_GDB.tar.xz makeDir $NAME_GDB_BLD cd $NAME_GDB_BLD ../$NAME_GDB/configure --prefix=$PREFIX --target=avr make -j $JOBCOUNT sudo make install cd .. TIME_END=$(date +%s) TIME_RUN=$(($TIME_END - $TIME_START)) echo "" echo "Done in $TIME_RUN seconds" } function avr-libc () { source avr-file-names TIME_START=$(date +%s) makeDir() { rm -rf "$1/" mkdir -p "$1" } echo "Downloading sources..." if [ ! -f $NAME_LIBC.tar.xz ]; then wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_LIBC.tar.xz fi # Make AVR-libc NAME_LIBC_BLD=${NAME_LIBC}_bld echo "Making AVR-LIBC in $NAME_LIBC_BLD..." echo "Extracting..." rm -rf $NAME_LIBC/ tar xJf $NAME_LIBC.tar.xz makeDir $NAME_LIBC_BLD AR='avr-ar' AS='avr-as' CC='avr-gcc' CCAS='gcc' cd $NAME_LIBC_BLD ../$NAME_LIBC/configure --prefix=$PREFIX --build=$(../$NAME_LIBC/config.guess) --host=avr make -j $JOBCOUNT sudo env "PATH=$PATH" make install-strip cd .. TIME_END=$(date +%s) TIME_RUN=$(($TIME_END - $TIME_START)) echo "" echo "Done in $TIME_RUN seconds" } function build-simu (){ source avr-file-names TIME_START=$(date +%s) echo "Downloading sources..." wget -c http://wareck.free.fr/cross_compilation/avr_toolchain/simulavr.tar.xz tar xfJ simulavr.tar.xz # Make simulavr echo "Making simulavr in $NAME_SIMULAVR..." cd $NAME_SIMULAVR/ git checkout traumflug cp ../pack/simulavr_patch1.patch . cp ../pack/simulavr_patch2.patch . patch -p1 < simulavr_patch1.patch patch -p1 < simulavr_patch2.patch ./bootstrap ./configure --enable-tcl --prefix=$PREFIX make sudo make install-strip cd .. TIME_END=$(date +%s) TIME_RUN=$(($TIME_END - $TIME_START)) echo "" echo "Done in $TIME_RUN seconds" } function avdude(){ source avr-file-names TIME_START=$(date +%s) makeDir() { rm -rf "$1/" mkdir -p "$1" } echo "Downloading sources..." if [ ! $archi = "arm" ]; then NAME_AVRDUDE=$NAME_AVRDUDE7;fi if [ ! -f $NAME_AVRDUDE.tar.xz ]; then wget http://wareck.free.fr/cross_compilation/avr_toolchain/$NAME_AVRDUDE.tar.xz fi # Make avrdude NAME_AVRDUDE_BLD=${NAME_AVRDUDE}_bld echo "Making AVRDUDE in $NAME_AVRDUDE_BLD..." echo "Extracting..." rm -rf $NAME_AVRDUDE/ tar xJf $NAME_AVRDUDE.tar.xz makeDir $NAME_AVRDUDE_BLD cd $NAME_AVRDUDE_BLD if [ $archi = "arm" ] then ../$NAME_AVRDUDE/configure --prefix=$PREFIX --enable-linuxgpio=yes else ../$NAME_AVRDUDE/configure --prefix=$PREFIX fi make -j $JOBCOUNT sudo make install-strip cd .. TIME_END=$(date +%s) TIME_RUN=$(($TIME_END - $TIME_START)) echo "" echo "Done in $TIME_RUN seconds" } binutils avr-gcc avr-gdb avr-libc build-simu avdude