# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Maintainer: Stefan Wagner <stw@bit-strickerei.de>
pkgname=gcc-avr
pkgver=6.1.0
pkgrel=0
pkgdesc="The GNU Compiler Collection for AVR targets"
url="http://gcc.gnu.org"
depends="binutils-avr"
makedepends="bash linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev"
arch="all"
license="GPL LGPL"
subpackages="$pkgname-doc"
_islver=0.17.1
source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-$pkgver.tar.bz2
	http://isl.gforge.inria.fr/isl-${_islver}.tar.bz2"

builddir="$srcdir/gcc-$pkgver"
_workingdir="$builddir/build"

build() {
	mkdir "$_workingdir" || return 1
	cd "$_workingdir"

	# link isl for in-tree build
	ln -s "$srcdir"/isl-"$_islver" "$builddir"/isl

	export CFLAGS_FOR_TARGET='-pipe'
	export CXXFLAGS_FOR_TARGET='-pipe'

	"$builddir"/configure \
		--build="$CBUILD" \
		--target=avr \
		--prefix=/usr \
		--enable-languages=c,c++ \
		--enable-ld=default \
		--enable-__cxa_atexit \
		--disable-install-libiberty \
		--disable-libssp \
		--disable-libstdcxx-pch \
		--disable-libunwind-exceptions \
		--disable-linker-build-id \
		--disable-nls \
		--disable-werror \
		--libdir=/usr/lib \
		--libexecdir=/usr/lib \
		--with-as=/usr/bin/avr-as \
		--with-gnu-as \
		--with-gnu-ld \
		--with-ld=/usr/bin/avr-ld \
		--with-system-zlib \
		--with-isl || return 1
	make
}

package() {
	cd "$_workingdir"
	make install DESTDIR="$pkgdir" || return 1
	rm -rf "$pkgdir"/usr/share/man/man7
	rm -f "$pkgdir"/usr/lib/libcc1.*
	find "$pkgdir"/usr/lib -type f -name "*.a" -exec /usr/bin/avr-strip --strip-debug '{}' \;
}

md5sums="8fb6cb98b8459f5863328380fbf06bd1  gcc-6.1.0.tar.bz2
5184f543a013165e8057be59728664b1  isl-0.17.1.tar.bz2"
sha256sums="09c4c85cabebb971b1de732a0219609f93fc0af5f86f6e437fd8d7f832f1a351  gcc-6.1.0.tar.bz2
d6307bf9a59514087abac3cbaab3d99393a0abb519354f7e7834a8c842310daa  isl-0.17.1.tar.bz2"
sha512sums="eeed3e2018b8c012aabce419e8d718fde701e5c3c179b4486c61ba46e5736eecc8fccdd18b01fcd973a42c6ad3116dbbe2ee247fe3757d622d373f93ebaf8d2e  gcc-6.1.0.tar.bz2
b84f6cab0d9fc7cb64f3afc35fc5f8c05db3456c569510788d65d402ebe8116eb49c327b8055eaebdfd0cac4764f279c1832d5440db6ffa0e52331ac52096058  isl-0.17.1.tar.bz2"