#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export DEBIAN_MAINTAINER=$(dpkg-parsechangelog -SMaintainer)
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

pkg=mira-assembler
exampledir=usr/share/doc/mira-examples/examples/minidemo/data/bbdataset1/

include /usr/share/dpkg/default.mk

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

override_dh_auto_install-arch:
	make install DESTDIR=$(CURDIR)/debian/$(pkg)

override_dh_auto_install-indep:
	#There is no installation target for the docs
	mkdir -p $(CURDIR)/debian/tmp/usr/share/doc/$(pkg)
	cp -r -t $(CURDIR)/debian/tmp/usr/share/doc/$(pkg) doc/docbook/bookfigures doc/docbook/images \
	    doc/docbook/doccss doc/docbook/DefinitiveGuideToMIRA.html || true

override_dh_auto_test-arch:
	make check

override_dh_auto_test-indep:

override_dh_auto_build-arch:
	# some *.cc files are created by old flex version which breaks the build
	# see bug #812681
	find -name '*.ll' | sed -e 's/[.]ll$$/.cc/' | xargs rm
	dh_auto_build

override_dh_auto_build-indep:
	dh_auto_build --sourcedir=doc

override_dh_installchangelogs:
	dh_installchangelogs src/mira/CHANGES.txt

#Must clean up the docs before cleaning out config.status
#Then scrub some junk not picked up by 'make clean'
override_dh_auto_clean:
	( cd doc ; make clean ) || true
	dh_auto_clean || true
	find * -name Makefile -exec rm '{}' ';'
	find * -name '*.xxd.H' -exec rm '{}' ';'
	find * -name '*.par.H' -exec rm '{}' ';'
	find * -name 'compileinfo.*' -exec rm '{}' ';'

override_dh_builddeb:
	dh_builddeb -- -Z xz

get-orig-source:
	mkdir -p ../tarballs
	uscan --verbose --force-download --destdir=../tarballs

