#!/bin/bash
oldpwd=`pwd`
target=avrdude
# download archive
url_base="http://www.very-clever.com/download/nongnu/avrdude/"
url_file=`wget $url_base 2>/dev/null -O - \
| tr '><' '\n\n' | grep ^avrdude.*\.tar\.gz$ | grep -v '[-]doc-' | tail -n1`
wget -c $url_base/$url_file
# extract archive
avrdude=`echo $url_file|sed -e 's|\.tar\.gz||'`
tar -xvjf $url_file
cd $avrdude
# make
export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe"
# -fno-exceptions -fno-rtti
export LDFLAGS="-Wl,-O1"
sh ./configure --prefix=/usr/local
make
# install
rm -rf /tmp/package
make DESTDIR=/tmp/package install-strip
# make tcz
cd /tmp
mksquashfs package $target.tcz
md5sum $target.tcz > $target.tcz.md5.txt
cd package
find usr -not -type d > ../$target.tcz.list
# mv to oldpwd
cd /tmp
mv $target.tcz $oldpwd
mv $target.tcz.md5.txt $oldpwd
mv $target.tcz.list $oldpwd
# clean
cd $oldpwd
rm -rf $avrdude
rm -rf /tmp/package