From 45bdb22ff0562d3ef63b89cf75148737fcfaf81a Mon Sep 17 00:00:00 2001 From: James Sleeman Date: Fri, 2 Dec 2016 19:14:57 +1300 Subject: [PATCH 1/2] Make build process easier to retarget to new Atmel release, auto detect version numbers and so forth. Just edit the first line of build.conf, then run... packag-avr-gcc.bash or to just build... tools.bash binutils.build.bash gcc.build.bash avr-libc.build.bash gdb.build.bash Add extra build docs. --- Readme.md | 23 ++++++++++++++++-- avr-libc.build.bash | 6 +++-- binutils.build.bash | 4 ++- build.conf | 58 ++++++++++++++++++++++++++++++++++++++++++++ gcc.build.bash | 22 +++++++++-------- gdb.build.bash | 4 ++- package-avr-gcc.bash | 8 +++--- tools.bash | 23 ++++++++++++------ 8 files changed, 121 insertions(+), 27 deletions(-) create mode 100644 build.conf diff --git a/Readme.md b/Readme.md index c74a460..ba7e567 100644 --- a/Readme.md +++ b/Readme.md @@ -5,16 +5,35 @@ This is the AVR Toolchain used in the [Arduino IDE](http://arduino.cc/). As soon as Atmel [ships a newer toolchain](http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/), we pull the source code, **patch it** with some user contributed patches and deliver it with the [Arduino IDE](http://arduino.cc/). Therefore, the resulting binaries may differ significantly from Atmel's. And you should start blaming us if things are not working as expected :) -Latest toolchain available is based on Atmel 3.5.2 version. It contains: +### Configuring + +Edit the `build.conf` file, currently the only thing worth changing is `AVR_VERSION` on the first line to match whatever the [latest version is](http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/). + +At time of writing, the latest toolchain available is based on Atmel 3.5.4 version. It contains: - binutils-2.26 - gcc-4.9.2 - avr-libc-2.0.0 - gdb-7.8 - + ### Building Setup has been done on partially set up development machines. If, trying to compile on your machine, you find any package missing from the following list, please open an issue at once! We all can't afford wasting time on setup :) +To just build, after getting the requirements... +```bash +./tools.bash +./binutils.build.bash +./gcc.build.bash +./libc.build.bash +./gdb.build.bash +``` +after a successful compile the binaries etc will be found in `objdir` + +To package, after getting the requirements... +```bash +./package-avr-gcc.bash +``` + #### Debian requirements ```bash diff --git a/avr-libc.build.bash b/avr-libc.build.bash index 22ebab7..f5d5940 100755 --- a/avr-libc.build.bash +++ b/avr-libc.build.bash @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +source build.conf + if [[ ! -d toolsdir ]] ; then echo "You must first build the tools: run build_tools.bash" @@ -29,7 +31,7 @@ export PATH="$TOOLS_BIN_PATH:$PATH" if [[ ! -f avr-libc.tar.bz2 ]] ; then - wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr-libc.tar.bz2 + wget $AVR_SOURCES/avr-libc.tar.bz2 fi if [[ $OS == "Msys" || $OS == "Cygwin" ]] ; then @@ -53,7 +55,7 @@ cd - if [[ ! -f avr8-headers.zip ]] ; then - wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr8-headers.zip + wget $AVR_SOURCES/avr8-headers.zip fi unzip avr8-headers.zip -d avr8-headers diff --git a/binutils.build.bash b/binutils.build.bash index 5ecce7d..d930231 100755 --- a/binutils.build.bash +++ b/binutils.build.bash @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +source build.conf + if [[ ! -d toolsdir ]] ; then echo "You must first build the tools: run build_tools.bash" @@ -29,7 +31,7 @@ export PATH="$TOOLS_BIN_PATH:$PATH" if [[ ! -f avr-binutils.tar.bz2 ]] ; then - wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr-binutils.tar.bz2 + wget $AVR_SOURCES/avr-binutils.tar.bz2 fi tar xfv avr-binutils.tar.bz2 diff --git a/build.conf b/build.conf new file mode 100644 index 0000000..0fe8140 --- /dev/null +++ b/build.conf @@ -0,0 +1,58 @@ +AVR_VERSION=3.5.4 +BUILD_NUMBER=arduino2 + +AVR_SOURCES="http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/${AVR_VERSION}" +GNU_SOURCES="http://mirror.switch.ch/ftp/mirror/gnu" +MPC_SOURCES="http://www.multiprecision.org/mpc/download" + +# The following version numbers are by default parsed out of the SOURCES.README +# in the Atmel distribution, you can override here if you want (or if it breaks) + +# GCC_VERSION=4.9.2 +# AUTOCONF_VERSION=2.64 +# AUTOMAKE_VERSION=1.11.1 +# GMP_VERSION=5.0.2 +# MPFR_VERSION=3.0.0 +# MPC_VERSION=0.9 + +# With any luck, you don't need to edit the below +################################################################################ + +# Defaut the versions of gmp/mpfr/mpc to those specified in the SOURCES.README +SOURCES_README="$(wget -O - http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/${AVR_VERSION}/SOURCES.README 2>/dev/null)" +[ -z "$GCC_VERSION" ] && GCC_VERSION="$(echo "$SOURCES_README" | grep -Po "GCC\s+([0-9]+\.)+[0-9]+" | sed -r 's/GCC\s//')" +[ -z "$AUTOMAKE_VERSION" ] && AUTOMAKE_VERSION="$(echo "$SOURCES_README" | grep -Po "automake-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')" +[ -z "$AUTOCONF_VERSION" ] && AUTOCONF_VERSION="$(echo "$SOURCES_README" | grep -Po "autoconf-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')" +[ -z "$GMP_VERSION" ] && GMP_VERSION="$(echo "$SOURCES_README" | grep -Po "gmp-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')" +[ -z "$MPFR_VERSION" ] && MPFR_VERSION="$(echo "$SOURCES_README" | grep -Po "mpfr-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')" +[ -z "$MPC_VERSION" ] && MPC_VERSION="$(echo "$SOURCES_README" | grep -Po "mpc-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')" + +# Build the URLs from which to grab the archives for those components +AUTOCONF_SOURCE="${GNU_SOURCES}/autoconf/autoconf-${AUTOCONF_VERSION}.tar.bz2" +AUTOMAKE_SOURCE="${GNU_SOURCES}/automake/automake-${AUTOMAKE_VERSION}.tar.bz2" +GMP_SOURCE="${GNU_SOURCES}/gmp/gmp-${GMP_VERSION}.tar.bz2" +MPFR_SOURCE="${GNU_SOURCES}/mpfr/mpfr-${MPFR_VERSION}.tar.bz2" +MPC_SOURCE="${MPC_SOURCES}/mpc-${MPC_VERSION}.tar.gz" + +# For debugging, spit it all out +cat <doc/automake.texi +rm doc/automake.texi2 + nice -n 10 make -j $MAKE_JOBS make install From 5ac07431ed0d0a4c9aca410d24b155d5e5337b35 Mon Sep 17 00:00:00 2001 From: James Sleeman Date: Fri, 2 Dec 2016 22:07:17 +1300 Subject: [PATCH 2/2] Install gdb only instead of also pulling in it's (old) binutils over the top of the one we already compiled. See https://github.com/arduino/toolchain-avr/issues/42 --- gdb.build.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb.build.bash b/gdb.build.bash index 222dfd5..967b574 100755 --- a/gdb.build.bash +++ b/gdb.build.bash @@ -67,5 +67,7 @@ fi nice -n 10 make -j $MAKE_JOBS -make install +# New versions of gdb share the same configure/make scripts with binutils. Running make install-gdb to +# install just the gdb binaries. +make install-gdb