#!/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")

export DEB_CFLAGS_MAINT_APPEND = $(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get LDFLAGS)

%:
	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 -D -m 644 debian/foomatic-db-engine.ppd-updater $(CURDIR)/debian/foomatic-db-engine/usr/share/cups/ppd-updaters/foomatic-db-engine

	# 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
