#!/usr/bin/make -f

derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes") || echo "no")
is_debian := $(shell (dpkg-vendor --is Debian && echo "yes") || echo "no")
binary_version := $(shell dpkg-parsechangelog | grep '^Version:' | awk '{print $$2}')

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- PERL_INSTALLDIRS=vendor

override_dh_bugfiles:
	# Only install the bug presubj on Debian
ifeq ($(is_debian),yes)
	dh_bugfiles
endif

override_dh_install:
	dh_install
	
	# Install the apport hook on Ubuntu and derivatives
ifeq ($(derives_from_ubuntu),yes)
	install -D -m 644 debian/ubuntu/apport-hook.py $(CURDIR)/debian/foomatic-db-engine/usr/share/apport/package-hooks/source_foomatic-db-engine.py
endif

# Bug #595523
# The foomatic-filters-ppds transitional package must be > 20080528-2.1 (Lenny's version)
# Hence epoch'ing foomatic-filters-ppds
override_dh_gencontrol:
	dh_gencontrol -pfoomatic-filters-ppds -- -v1:${binary_version}
	dh_gencontrol --remaining-packages
