= AVR用GCCを自分でビルドしてみる = == 概要 == [http://distribute.atmel.no/tools/opensource/avr-gcc/ Atmelが配布しているパッチ]を摘要してビルドします。 最終的に、`/usr/local/avr`以下にすべてのファイルをインストールすることにします。 == 準備 == ディレクトリを作成します。 スーパーユーザでmake installを行うと悲しいことが起きる可能性があるので、スーパーユーザで作業しなくて済むように、あらかじめchownで自分の物にしておきます。 {{{ % sudo mkdir /usr/local/avr % sudo chown 自分 /usr/local/avr % cd /usr/local/avr }}} == パッチをもらってくる == どこか作業ディレクトリで作業します。 {{{ % wget -r --level=2 --accept=patch http://distribute.atmel.no/tools/opensource/avr-gcc/ % mkdir patch % find . -name '*.patch' -exec mv '{}' patch ';' % /bin/rm -rf distribute.atmel.no }}} == binutils == [http://sources.redhat.com/binutils/ このあたりからbinutils-2.20.1をもらってきます。] {{{ % tar xvjf binutils-2.20.1.tar.bz2 % cd binutils-2.20.1 % for f in ../patch/*-binutils-*; do patch -p0 < $f; done % mkdir build % cd build % ../configure --prefix=/usr/local/avr --target=avr --disable-nls --disable-werror % make % make install }}} パスを通しておきましょう。 {{{ % export PATH=/usr/local/avr/bin:$PATH }}} == GCC == [http://gcc.gnu.org/ このあたりからGCC 4.5.1をもらってきます。] GCCそのものの実装のために、GMP、MPFR、MPCというライブラリが必要です。 OSに付属のパッケージがあれば、開発用のパッケージを選んでインストールしておきます。 {{{ % tar xvjf gcc-4.5.1.tar.bz2 % cd gcc-4.5.1 % for f in ../patch/*-gcc-*; do patch -p0 < $f; done % mkdir build % cd build % ../configure --prefix=/usr/local/avr --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2 % make % make install }}} == AVR Libc == [http://download.savannah.gnu.org/releases/avr-libc/ このあたりからAVR Libc 1.7.1をもらってきます。] {{{ % tar xvjf avr-libc-1.7.1.tar.bz2 % cd avr-libc-1.7.1 % for f in ../patch/*-avr-libc-*; do patch -p0 < $f; done % mkdir build % cd build % ../configure --prefix=/usr/local/avr --build=`../config.guess` --host=avr % make % make install }}} == 後片付け == 必要に応じて、もらってきたアーカイブファイル、展開したソースなどを削除します。 最後に、必要であれば、`/usr/local/avr`ディレクトリ以下をrootの持ち物に変更します。 {{{ % sudo chown -R root.root /usr/local/avr }}} ''(2012/9/21 - sgk)''