#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1
export DESTDIR=$(CURDIR)/debian/tmp
export DH_ALWAYS_EXCLUDE=.gitignore

BITS:=$(shell dpkg-architecture | grep DEB_BUILD_ARCH_BITS | cut -f 2 -d'=')
ifeq ($(BITS),64)
  64BIT:=yes
else
  64BIT:=no
endif

%:
	dh $@ --parallel --with python2

override_dh_auto_clean:
	$(MAKE) cleanup
	cd doc/manuals; make cleanup
	# should be deleted inside doc/manuals/Makefile
	rm -f doc/manuals/annotationsketch.out \
	      doc/manuals/api_reference.tex    \
	      doc/manuals/gtscript_reference.tex
	find doc . -name "*.toc" -delete
	find testdata \( -name '*.ois' -or -name '*.sds' -or -name '*.esq' -or \
	      -name '*.ssp' -or -name '*.des' -or -name "*.md5"  \) -and \( -not \
	      -name '*foo.32.*' -not -name '*foo.64.*' \) -delete
	rm -f www/genometools.org/htdocs/images/callbacks.png \
	      www/genometools.org/htdocs/images/parsed.png    \
	      www/genometools.org/htdocs/images/constructed.png \
	      doc/manuals/annotationsketch.pdf
	rm -f www/genometools.org/htdocs/docs.html \
	      www/genometools.org/htdocs/examples.html \
	      www/genometools.org/htdocs/libgenometools.html \
	      www/genometools.org/htdocs/tools/gt.html
	rm -rf gtpython/build

override_dh_auto_build:
	dh_auto_build --parallel -- useshared=yes 64bit=$(64BIT) errorcheck=no all docs manuals

override_dh_auto_test:
	bin/gt -test
	cd testsuite; ./testsuite.rb -keywords 'gt_sketch and not gt_python and not gt_ruby' -threads 3

override_dh_auto_install:
	dh_auto_install -- installmanpages useshared=yes 64bit=$(64BIT) opt=no errorcheck=no prefix=$(DESTDIR)/usr
	dh_auto_install --sourcedirectory=gtpython --destdir=$(CURDIR)/debian/python-genometools

override_dh_strip:
	dh_strip --dbg-package=genometools-dbg
