# Template file for 'chroot-binutils'
pkgname=chroot-binutils
version=2.23.51.0.3
revision=2
wrksrc="binutils-${version}"
short_desc="GNU binary utilities -- for xbps-src use"
maintainer="Juan RP <xtraeme@gmail.com>"
homepage="http://www.gnu.org/software/binutils/"
license="GPL-3"
distfiles="${KERNEL_SITE}/devel/binutils/binutils-$version.tar.xz"
checksum=2162905dabf191a2a803eab8d31e7be52d96d6ccd1e0ce42e25d82c6be918cd0

if [ "$IN_CHROOT" ]; then
	hostmakedepends="flex perl"
fi
makedepends="zlib-devel"

noverifyrdeps=yes
bootstrap=yes
provides="binutils-${version}"
conflicts="binutils>=0"

do_configure() {
	if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
		CONFIGFLAG="--enable-64-bit-bfd --enable-multilib"
	fi

	./configure ${CONFIGURE_SHARED_ARGS} --disable-shared \
		--enable-threads --disable-plugins \
		--with-mmap --disable-bootstrap ${CONFIGFLAG}
}

do_build() {
	make ${makejobs}
}

do_install() {
	if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
		mkdir -p ${DESTDIR}/usr/lib
                cd ${DESTDIR}/usr && ln -s lib lib64 && cd ${wrksrc}
        fi

	make DESTDIR=${DESTDIR} tooldir=/usr install

	[ -h ${DESTDIR}/usr/lib64 ] && rm -f ${DESTDIR}/usr/lib64
	rm -f ${DESTDIR}/usr/lib/*.a
	rm -rf ${DESTDIR}/usr/share ${DESTDIR}/usr/include
}
