# Template file for 'ffcall'
pkgname=ffcall
version=2.4
revision=1
build_style=gnu-configure
short_desc="Libraries to build foreign function call interfaces"
maintainer="Martin Riese <grauehaare@gmx.de>"
license="GPL-2.0-or-later"
homepage="https://www.gnu.org/software/libffcall"
distfiles="${GNU_SITE}/libffcall/libffcall-${version}.tar.gz"
checksum=8ef69921dbdc06bc5bb90513622637a7b83a71f31f5ba377be9d8fd8f57912c2

# won't work with parallel_build so just turn it off (thanks to JuanRP for the Hint)
disable_parallel_build=yes

if [ "$CROSS_BUILD" ]; then
	configure_args+=" ffcall_cv_malloc_mprotect_can_exec=yes"
fi

case "$XBPS_TARGET_MACHINE" in
	ppc64*) ;;
	ppc*)
		nopie=yes
		CFLAGS="-fPIC"
		;;
esac

post_extract() {
	case "$XBPS_TARGET_MACHINE" in
		ppc64le*) ;;
		ppc64*)
			msg_normal "Patching ppc64 BE ELFv2...\n"
			patch -sNp1 -i ${FILESDIR}/ppc64-be.patch
			;;
	esac
}

do_install() {
	make DESTDIR=${DESTDIR} htmldir=/usr/share/doc/ffcall install
}

ffcall-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/share/man/man3
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.a"
	}
}
