Skip to content

Commit f1a780d

Browse files
authored
Merge pull request #43 from sleemanj/master
Make build process easier to retarget to new Atmel release
2 parents da24638 + 5ac0743 commit f1a780d

8 files changed

+124
-28
lines changed

Readme.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,35 @@ This is the AVR Toolchain used in the [Arduino IDE](http://arduino.cc/).
55
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/).
66
Therefore, the resulting binaries may differ significantly from Atmel's. And you should start blaming us if things are not working as expected :)
77

8-
Latest toolchain available is based on Atmel 3.5.2 version. It contains:
8+
### Configuring
9+
10+
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/).
11+
12+
At time of writing, the latest toolchain available is based on Atmel 3.5.4 version. It contains:
913
- binutils-2.26
1014
- gcc-4.9.2
1115
- avr-libc-2.0.0
1216
- gdb-7.8
13-
17+
1418
### Building
1519

1620
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 :)
1721

22+
To just build, after getting the requirements...
23+
```bash
24+
./tools.bash
25+
./binutils.build.bash
26+
./gcc.build.bash
27+
./libc.build.bash
28+
./gdb.build.bash
29+
```
30+
after a successful compile the binaries etc will be found in `objdir`
31+
32+
To package, after getting the requirements...
33+
```bash
34+
./package-avr-gcc.bash
35+
```
36+
1837
#### Debian requirements
1938

2039
```bash

avr-libc.build.bash

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

18+
source build.conf
19+
1820
if [[ ! -d toolsdir ]] ;
1921
then
2022
echo "You must first build the tools: run build_tools.bash"
@@ -29,7 +31,7 @@ export PATH="$TOOLS_BIN_PATH:$PATH"
2931

3032
if [[ ! -f avr-libc.tar.bz2 ]] ;
3133
then
32-
wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr-libc.tar.bz2
34+
wget $AVR_SOURCES/avr-libc.tar.bz2
3335
fi
3436

3537
if [[ $OS == "Msys" || $OS == "Cygwin" ]] ; then
@@ -53,7 +55,7 @@ cd -
5355

5456
if [[ ! -f avr8-headers.zip ]] ;
5557
then
56-
wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr8-headers.zip
58+
wget $AVR_SOURCES/avr8-headers.zip
5759
fi
5860

5961
unzip avr8-headers.zip -d avr8-headers

binutils.build.bash

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

18+
source build.conf
19+
1820
if [[ ! -d toolsdir ]] ;
1921
then
2022
echo "You must first build the tools: run build_tools.bash"
@@ -29,7 +31,7 @@ export PATH="$TOOLS_BIN_PATH:$PATH"
2931

3032
if [[ ! -f avr-binutils.tar.bz2 ]] ;
3133
then
32-
wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr-binutils.tar.bz2
34+
wget $AVR_SOURCES/avr-binutils.tar.bz2
3335
fi
3436
tar xfv avr-binutils.tar.bz2
3537

build.conf

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
AVR_VERSION=3.5.4
2+
BUILD_NUMBER=arduino2
3+
4+
AVR_SOURCES="http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/${AVR_VERSION}"
5+
GNU_SOURCES="http://mirror.switch.ch/ftp/mirror/gnu"
6+
MPC_SOURCES="http://www.multiprecision.org/mpc/download"
7+
8+
# The following version numbers are by default parsed out of the SOURCES.README
9+
# in the Atmel distribution, you can override here if you want (or if it breaks)
10+
11+
# GCC_VERSION=4.9.2
12+
# AUTOCONF_VERSION=2.64
13+
# AUTOMAKE_VERSION=1.11.1
14+
# GMP_VERSION=5.0.2
15+
# MPFR_VERSION=3.0.0
16+
# MPC_VERSION=0.9
17+
18+
# With any luck, you don't need to edit the below
19+
################################################################################
20+
21+
# Defaut the versions of gmp/mpfr/mpc to those specified in the SOURCES.README
22+
SOURCES_README="$(wget -O - http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/${AVR_VERSION}/SOURCES.README 2>/dev/null)"
23+
[ -z "$GCC_VERSION" ] && GCC_VERSION="$(echo "$SOURCES_README" | grep -Po "GCC\s+([0-9]+\.)+[0-9]+" | sed -r 's/GCC\s//')"
24+
[ -z "$AUTOMAKE_VERSION" ] && AUTOMAKE_VERSION="$(echo "$SOURCES_README" | grep -Po "automake-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')"
25+
[ -z "$AUTOCONF_VERSION" ] && AUTOCONF_VERSION="$(echo "$SOURCES_README" | grep -Po "autoconf-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')"
26+
[ -z "$GMP_VERSION" ] && GMP_VERSION="$(echo "$SOURCES_README" | grep -Po "gmp-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')"
27+
[ -z "$MPFR_VERSION" ] && MPFR_VERSION="$(echo "$SOURCES_README" | grep -Po "mpfr-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')"
28+
[ -z "$MPC_VERSION" ] && MPC_VERSION="$(echo "$SOURCES_README" | grep -Po "mpc-([0-9]+\.)+[0-9]+" | sed -r 's/[^-]+-//')"
29+
30+
# Build the URLs from which to grab the archives for those components
31+
AUTOCONF_SOURCE="${GNU_SOURCES}/autoconf/autoconf-${AUTOCONF_VERSION}.tar.bz2"
32+
AUTOMAKE_SOURCE="${GNU_SOURCES}/automake/automake-${AUTOMAKE_VERSION}.tar.bz2"
33+
GMP_SOURCE="${GNU_SOURCES}/gmp/gmp-${GMP_VERSION}.tar.bz2"
34+
MPFR_SOURCE="${GNU_SOURCES}/mpfr/mpfr-${MPFR_VERSION}.tar.bz2"
35+
MPC_SOURCE="${MPC_SOURCES}/mpc-${MPC_VERSION}.tar.gz"
36+
37+
# For debugging, spit it all out
38+
cat <<EOF
39+
VERSIONS
40+
-------------------------------------------------------------------------------
41+
GCC: ${GCC_VERSION}
42+
AVR: ${AVR_VERSION}
43+
BUILD: ${BUILD_NUMBER}
44+
AUTOCONF: ${AUTOCONF_VERSION}
45+
AUTOMAKE: ${AUTOMAKE_VERSION}
46+
GMP: ${GMP_VERSION}
47+
MPFR: ${MPFR_VERSION}
48+
MPC: ${MPC_VERSION}
49+
50+
SOURCES
51+
-------------------------------------------------------------------------------
52+
AUTOCONF: ${AUTOCONF_SOURCE}
53+
AUTOMAKE: ${AUTOMAKE_SOURCE}
54+
GMP: ${GMP_SOURCE}
55+
MPFR: ${MPFR_SOURCE}
56+
MPC: ${MPC_SOURCE}
57+
AVR: ${AVR_SOURCES}/*
58+
EOF

gcc.build.bash

+12-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

18+
source build.conf
19+
1820
if [[ ! -d toolsdir ]] ;
1921
then
2022
echo "You must first build the tools: run build_tools.bash"
@@ -27,30 +29,30 @@ cd -
2729

2830
export PATH="$TOOLS_BIN_PATH:$PATH"
2931

30-
if [[ ! -f gmp-5.0.2.tar.bz2 ]] ;
32+
if [[ ! -f gmp-${GMP_VERSION}.tar.bz2 ]] ;
3133
then
32-
wget http://mirror.switch.ch/ftp/mirror/gnu/gmp/gmp-5.0.2.tar.bz2
34+
wget ${GMP_SOURCE}
3335
fi
3436

35-
tar xfv gmp-5.0.2.tar.bz2
37+
tar xfv gmp-${GMP_VERSION}.tar.bz2
3638

37-
if [[ ! -f mpfr-3.0.0.tar.bz2 ]] ;
39+
if [[ ! -f mpfr-${GMPFR_VERSION}.tar.bz2 ]] ;
3840
then
39-
wget http://mirror.switch.ch/ftp/mirror/gnu/mpfr/mpfr-3.0.0.tar.bz2
41+
wget ${MPFR_SOURCE}
4042
fi
4143

42-
tar xfv mpfr-3.0.0.tar.bz2
44+
tar xfv mpfr-${MPFR_VERSION}.tar.bz2
4345

44-
if [[ ! -f mpc-0.9.tar.gz ]] ;
46+
if [[ ! -f mpc-${MPC_VERSION}.tar.gz ]] ;
4547
then
46-
wget http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz
48+
wget ${MPC_SOURCE}
4749
fi
4850

49-
tar xfv mpc-0.9.tar.gz
51+
tar xfv mpc-${MPC_VERSION}.tar.gz
5052

5153
if [[ ! -f avr-gcc.tar.bz2 ]] ;
5254
then
53-
wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr-gcc.tar.bz2
55+
wget $AVR_SOURCES/avr-gcc.tar.bz2
5456
fi
5557

5658
tar xfv avr-gcc.tar.bz2

gdb.build.bash

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

18+
source build.conf
19+
1820
if [[ ! -d toolsdir ]] ;
1921
then
2022
echo "You must first build the tools: run build_tools.bash"
@@ -29,7 +31,7 @@ export PATH="$TOOLS_BIN_PATH:$PATH"
2931

3032
if [[ ! -f avr-gdb.tar.bz2 ]] ;
3133
then
32-
wget http://distribute.atmel.no/tools/opensource/Atmel-AVR-GNU-Toolchain/3.5.3/avr-gdb.tar.bz2
34+
wget $AVR_SOURCES/avr-gdb.tar.bz2
3335
fi
3436

3537
tar xfv avr-gdb.tar.bz2
@@ -65,5 +67,7 @@ fi
6567

6668
nice -n 10 make -j $MAKE_JOBS
6769

68-
make install
70+
# New versions of gdb share the same configure/make scripts with binutils. Running make install-gdb to
71+
# install just the gdb binaries.
72+
make install-gdb
6973

package-avr-gcc.bash

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

18-
OUTPUT_VERSION=4.9.2-atmel3.5.3-arduino2
18+
source build.conf
19+
20+
OUTPUT_VERSION=${GCC_VERSION}-atmel${AVR_VERSION}-${BUILD_NUMBER}
1921

2022
export OS=`uname -o || uname`
2123
export TARGET_OS=$OS
@@ -67,8 +69,8 @@ else
6769

6870
fi
6971

70-
rm -rf autoconf-2.64 automake-1.11.1
71-
rm -rf gcc gmp-5.0.2 mpc-0.9 mpfr-3.0.0 binutils avr-libc libc avr8-headers gdb
72+
rm -rf autoconf-${AUTOCONF_VERSION} automake-${AUTOMAKE_VERSION}
73+
rm -rf gcc gmp-${GMP_VERSION} mpc-${MPC_VERSION} mpfr-${MPFR_VERSION} binutils avr-libc libc avr8-headers gdb
7274
rm -rf toolsdir objdir *-build
7375

7476
./tools.bash

tools.bash

+15-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# along with this program; if not, write to the Free Software
1616
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1717

18+
source build.conf
19+
1820
mkdir -p toolsdir/bin
1921
cd toolsdir
2022
TOOLS_PATH=`pwd`
@@ -28,14 +30,14 @@ if [ -z "$MAKE_JOBS" ]; then
2830
MAKE_JOBS="2"
2931
fi
3032

31-
if [[ ! -f autoconf-2.64.tar.bz2 ]] ;
33+
if [[ ! -f autoconf-${AUTOCONF_VERSION}.tar.bz2 ]] ;
3234
then
33-
wget http://mirror.switch.ch/ftp/mirror/gnu/autoconf/autoconf-2.64.tar.bz2
35+
wget $AUTOCONF_SOURCE
3436
fi
3537

36-
tar xfjv autoconf-2.64.tar.bz2
38+
tar xfjv autoconf-${AUTOCONF_VERSION}.tar.bz2
3739

38-
cd autoconf-2.64
40+
cd autoconf-${AUTOCONF_VERSION}
3941

4042
CONFARGS="--prefix=$TOOLS_PATH"
4143

@@ -47,21 +49,26 @@ make install
4749

4850
cd -
4951

50-
if [[ ! -f automake-1.11.1.tar.bz2 ]] ;
52+
if [[ ! -f automake-${AUTOMAKE_VERSION}.tar.bz2 ]] ;
5153
then
52-
wget http://mirror.switch.ch/ftp/mirror/gnu/automake/automake-1.11.1.tar.bz2
54+
wget $AUTOMAKE_SOURCE
5355
fi
5456

55-
tar xfjv automake-1.11.1.tar.bz2
57+
tar xfjv automake-${AUTOMAKE_VERSION}.tar.bz2
5658

57-
cd automake-1.11.1
59+
cd automake-${AUTOMAKE_VERSION}
5860

5961
./bootstrap
6062

6163
CONFARGS="--prefix=$TOOLS_PATH"
6264

6365
./configure $CONFARGS
6466

67+
# Prevent compilation problem with docs complaining about @itemx not following @item
68+
cp doc/automake.texi doc/automake.texi2
69+
cat doc/automake.texi2 | sed -r 's/@itemx/@c @itemx/' >doc/automake.texi
70+
rm doc/automake.texi2
71+
6572
nice -n 10 make -j $MAKE_JOBS
6673

6774
make install

0 commit comments

Comments
 (0)