#!/usr/bin/make -f

CGAP = /usr/bin/gap

DEB_BUILD_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH)
DEB_BUILD_GAP_INFO_ARCH ?= $(shell echo 'Print(GAPInfo.Architecture);' | $(CGAP) -A -q -T)
DEB_BUILD_GAP_KERNEL_MAJOR_VERSION ?= $(shell sed -n -e 's/^GAP_KERNEL_MAJOR_VERSION=//p' /usr/lib/gap/sysinfo.gap )

SUBSTVARS = -Vgapkernel:Depends="gap-kernel-$(DEB_BUILD_GAP_KERNEL_MAJOR_VERSION)"


default:
	@uscan --no-conf --dehs --report || true

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		--with-gaproot=/usr/lib/gap \
		--with-mpfr=yes \
		--with-mpc=yes \
		--with-mpfi=yes \
		--with-fplll=yes \
		--with-cxsc=no

override_dh_prep:
	cat makedoc.g | $(CGAP) -A -q -T
	dh_prep

override_dh_auto_install:
	dh_auto_install --destdir debian/tmp/

override_dh_link:
	dh_link -p gap-float \
		/usr/lib/$(DEB_BUILD_MULTIARCH)/gap/pkg/float/bin /usr/lib/gap/pkg/float/bin/$(DEB_BUILD_GAP_INFO_ARCH) \
		/usr/lib/gap/pkg/float/bin /usr/share/gap/pkg/float/bin \
		/usr/share/gap/pkg/float/doc /usr/share/doc/gap-float/doc

override_dh_gencontrol:
	dh_gencontrol -- $(SUBSTVARS)
