#!/usr/bin/make -f
# Copyright 2016 Bill Allombert <ballombe@debian.org>

build-indep-stamp:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p debian/gaproot/pkg
	ln -s ../../.. debian/gaproot/pkg/tomlib
	(cd tst && gap -q -l '../debian/gaproot;/usr/share/gap' < testall.g ) \
           | tee debian/gap.tst
	! grep "^########" debian/gap.tst
endif
	make -C doc gapdoc
	make -C doc clean
	rm -f doc/tomlib.brf doc/tomlib.out
	touch build-indep-stamp
build-arch: 
build-indep: build-indep-stamp
build: build-arch build-indep

clean:
	dh_testdir
	dh_testroot
	make -C doc spotless
	rm -f doc/bib.xml.bib
	rm -f build-indep-stamp
	rm -rf debian/gaproot
	rm -f debian/gap.tst
	dh_clean

install: DH_OPTIONS=
install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	dh_install -X Makefile -X README -X stamp -X debian -X tst -X .pc . usr/share/gap/pkg/tomlib
	chmod a-x debian/gap-table-of-marks/usr/share/gap/pkg/tomlib/doc/*
	gzip --no-name -r --best debian/gap-table-of-marks/usr/share/gap/pkg/tomlib/data/
	dh_installdocs README

# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: build install
	dh_testdir -i
	dh_testroot -i
	dh_installchangelogs  -i
	dh_link -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary-arch: 
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
