# Template file for 'gfan'
pkgname=gfan
version=0.6.2
revision=1
wrksrc=gfan$version
build_style=gnu-makefile
makedepends="gmp-devel cddlib-devel"
short_desc="Package for computing Groebner fans and tropical varieties"
maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
license="GPL-2.0-or-later"
homepage="https://math.au.dk/~jensen/software/gfan/gfan.html"
distfiles="https://math.au.dk/~jensen/software/gfan/gfan${version}.tar.gz"
checksum=a674d5e5dc43634397de0d55dd5da3c32bd358d05f72b73a50e62c1a1686f10a

# Makefile has this but our CFLAGS override it; build fails otherwise
CFLAGS="-DGMPRATIONAL"

case $XBPS_TARGET_MACHINE in
	# avoid numerical noise caused by extended-precision of registers
	# fixes testsuite/0009RenderStairCase
	i686*) CFLAGS+=" -ffloat-store" ;;
esac

if [ -n "$CROSS_BUILD" ]; then
	# depend on host gfan for installlinks
	hostmakedepends+=" gfan"
fi

do_install() {
	if [ -z "$CROSS_BUILD" ]; then
		# Makefile doesn't support DESTDIR so we add it to PREFIX
		make PREFIX=${DESTDIR}/usr install
	else
		vbin gfan
		# use host gfan to install links
		cd ${DESTDIR}/usr/bin && gfan installlinks
	fi
}
