# Template file for 'elfutils'
pkgname=elfutils
version=0.161
revision=3
build_style=gnu-configure
configure_args="--program-prefix=eu-"
hostmakedepends="m4"
makedepends="zlib-devel bzip2-devel liblzma-devel"
short_desc="Utilities to handle ELF object files"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-3"
homepage="https://fedorahosted.org/elfutils/"
distfiles="https://fedorahosted.org/releases/e/l/${pkgname}/${version}/${pkgname}-${version}.tar.bz2"
checksum=570c91a1783fa5386aaa2dfdd08dda1de777c2b63bf3b9c1437d635ffdd7a070

CFLAGS="-Wno-unused-result"

case "$XBPS_TARGET_MACHINE" in
	*-musl) makedepends+=" argp-standalone" ;;
esac

post_extract() {
	sed -i '/<linux\/uio.h>/d' backends/*_initreg.c
	case "$XBPS_TARGET_MACHINE" in
		*-musl) patch -Np0 <${FILESDIR}/009-no-fts.patch
	esac
}

do_configure() {
	case "$XBPS_TARGET_MACHINE" in
		*-musl) export LIBS="-largp" ;;
	esac
	./configure ${configure_args}
}

libelf_package() {
	short_desc+=" - runtime library"
	pkg_install() {
		vmove "usr/lib/*.so*"
		vmove usr/lib/elfutils
	}
}
elfutils-devel_package() {
	depends="libelf>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.a"
	}
}
