SUMMARY="A tool to up/download to AVR microcontrollers"
DESCRIPTION="AVRDUDE is an utility to download/upload/manipulate the ROM and \
EEPROM contents of AVR microcontrollers using the in-system programming \
technique (ISP)."
HOMEPAGE="http://www.nongnu.org/avrdude/"
COPYRIGHT="2003-2016 Brian S. Dean"
LICENSE="GNU GPL v2"
REVISION="5"
SOURCE_URI="http://download.savannah.gnu.org/releases/avrdude/avrdude-$portVersion.tar.gz"
CHECKSUM_SHA256="0f9f731b6394ca7795b88359689a7fa1fba818c6e1d962513eb28da670e0a196"
PATCHES="avrdude-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="1.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

GLOBAL_WRITABLE_FILES="
	settings/avrdude.conf keep-old
	"

PROVIDES="
	avrdude$secondaryArchSuffix = $portVersion
	cmd:avrdude$commandSuffix = $portVersion
	lib:libavrdude$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libelf$secondaryArchSuffix
	lib:libftdi1$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libusb_1.0$secondaryArchSuffix
	lib:libusb_0.1$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libelf$secondaryArchSuffix
	devel:libftdi1$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	devel:libusb_1.0$secondaryArchSuffix
	devel:libusb_0.1$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:automake
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtool$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:yacc
	"

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs bindir ./configure --bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install
	rm $libDir/lib*.a
	rm $libDir/lib*.la
}
