build-avr-binutils 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # http://www.nongnu.org/avr-libc/user-manual/install_tools.html
  3. # Stop on errors
  4. set -e
  5. source avr-file-names
  6. # Figure out which version of the patch to use
  7. OLD_PATCH_CUTOFF="2.32"
  8. OLD_PATCH_CUTOFF_MAJ=${OLD_PATCH_CUTOFF%%.*}
  9. OLD_PATCH_CUTOFF_MIN=${OLD_PATCH_CUTOFF#*.}
  10. BINUTILS_VER=${NAME_BINUTILS#binutils-}
  11. BINUTILS_VER_MAJ=${BINUTILS_VER%%.*}
  12. BINUTILS_VER_MIN_TMP=${BINUTILS_VER#*.}
  13. BINUTILS_VER_MIN=${BINUTILS_VER_MIN_TMP%.*}
  14. if [ $BINUTILS_VER_MAJ -eq "1" ]; then
  15. echo "ERROR: Binutils version 1.xx is too old -- use at least version 2.xx"
  16. exit 1;
  17. fi
  18. if [ $BINUTILS_VER_MAJ -gt $OLD_PATCH_CUTOFF_MAJ ] || \
  19. ( [ $BINUTILS_VER_MAJ -eq $OLD_PATCH_CUTOFF_MAJ ] && [ $BINUTILS_VER_MIN -gt $OLD_PATCH_CUTOFF_MIN ] ) ; then
  20. NAME_BINUTILS_SIZE_PATCH="avr-binutils-size-2.33.patch";
  21. else
  22. NAME_BINUTILS_SIZE_PATCH="avr-binutils-size-2.32.patch";
  23. fi
  24. TIME_START=$(date +%s)
  25. makeDir()
  26. {
  27. rm -rf "$1/"
  28. mkdir -p "$1"
  29. }
  30. echo "Downloading sources..."
  31. if [ ! -f $NAME_BINUTILS.tar.xz ]; then
  32. wget https://ftp.mirrorservice.org/sites/ftp.gnu.org/gnu/binutils/$NAME_BINUTILS.tar.xz
  33. fi
  34. # Make AVR-Binutils
  35. NAME_BINUTILS_BLD=${NAME_BINUTILS}_bld
  36. echo "Making Binutils in $NAME_BINUTILS_BLD..."
  37. echo "Extracting..."
  38. rm -rf $NAME_BINUTILS/
  39. tar xf $NAME_BINUTILS.tar.xz
  40. # Patch the size function
  41. cd $NAME_BINUTILS/binutils
  42. patch -p 1 < ../../$NAME_BINUTILS_SIZE_PATCH
  43. cd ../..
  44. makeDir $NAME_BINUTILS_BLD
  45. cd $NAME_BINUTILS_BLD
  46. ../$NAME_BINUTILS/configure --prefix=$PREFIX --target=avr --disable-nls
  47. make -j $JOBCOUNT
  48. sudo make install-strip
  49. cd ..
  50. TIME_END=$(date +%s)
  51. TIME_RUN=$(($TIME_END - $TIME_START))
  52. echo ""
  53. echo "Done in $TIME_RUN seconds"
  54. exit 0