123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- #!/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
|