# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Maintainer: Stefan Wagner <stw@bit-strickerei.de>
pkgname=binutils-avr
pkgver=2.28
pkgrel=0
pkgdesc="Tools necessary to build programs for AVR targets"
url="https://www.gnu.org/software/binutils/"
makedepends="gettext libtool autoconf automake"
arch="all"
license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD"
subpackages="$pkgname-doc"
source="http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.bz2
	binutils-ld-fix-static-linking.patch
	hash-style-gnu.patch"

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

build() {
	mkdir "$_workingdir" || return 1
	cd "$_workingdir"
	"$builddir"/configure \
		--build="$CBUILD" \
		--target=avr \
		--with-lib-path=/usr/lib \
		--prefix=/usr \
		--enable-ld=default \
		--enable-gold=yes \
		--enable-plugins \
		--disable-multilib \
		--disable-werror \
		--disable-nls \
		|| return 1
	make -j1 tooldir=/usr
}

package() {
	cd "$_workingdir"
	make tooldir=/usr install DESTDIR="$pkgdir" || return 1
	rm -rf "$pkgdir"/usr/share/info
	for bin in ar as nm objcopy objdump ranlib strip readelf; do
		rm -f "$pkgdir"/usr/bin/"$bin"
	done
}

sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd  binutils-2.28.tar.bz2
ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49  binutils-ld-fix-static-linking.patch
24e853bf4b58621a77921087e599da2ace47ba3079e2d50fb5d08ae399be5f060c5fdd7f65257bcc0526aebc66e68b98aafd45d714c035da8ea2bdc3d8d4e375  hash-style-gnu.patch"
