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

MANPAGES=vowpalwabbit/vw.1

%:
	dh  $@  --with autoreconf

%.1: %
	help2man --no-info --name="Vowpal Wabbit -- fast online learning tool" ./$< > $@

override_dh_auto_configure:
	dh_auto_configure -- $(shell dpkg-buildflags --export=configure)

override_dh_auto_build:
	dh_auto_build
	debian/rules $(MANPAGES)

override_dh_auto_install:
	dh_auto_install
	: # We generally do not ship .la on Debian systems
	find debian/ -name '*.la' | xargs -r rm -f
	: # We do not patch upstream to not build it (useful to test)
	: # put it makes no sense to install it
	find debian/ -name library_example -delete

override_dh_installexamples:
	dh_installexamples
	: # Change permissions on windows-generated files
	find debian/ -name '*-mswin' -type f | xargs -r chmod a-x

override_dh_auto_test:
	: # I: run tests providing options for verbose output on failures
	cd test && ./RunTests -c -d -f
	: # I: cleaning up after running tests
	find test/ -name '*.tmp' -o -name '*.cache' | xargs -r rm -f
	rm -f test/*.predict

override_dh_auto_clean:
	dh_auto_clean
	-rm -f test/*.predict test/*.tmp depend $(MANPAGES)
	: # And more garbage left with autoreconf
	-rm -f vowpalwabbit/config.h vowpalwabbit/depend

override_dh_strip:
	dh_strip --dbg-package=vowpal-wabbit-dbg

override_dh_compress:
	dh_compress -X.dat -X.predict -X.model -XRunTests
