#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

VENDOR ?= xine project

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

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

# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
override_dh_auto_configure:
	dh_auto_configure -Sautoconf -- \
		--disable-integration-wizard --enable-watchdog \
		--with-logo-format=image \
		VENDOR_PKG_VERSION="`dpkg-parsechangelog | sed -ne '/^Version:/ { s/^.* //; p }'`; $(VENDOR)" \
		GSSCMD=/usr/bin/gnome-screensaver-command \
		XSSCMD=/usr/bin/xscreensaver-command \
		XDGSSCMD=/usr/bin/xdg-screensaver

override_dh_install:
	awk 'BEGIN { s = "%s;" } { printf s, $$1; s = "%s;" }' <mime.extra >$(CURDIR)/debian/tmp/usr/share/gxine/mime.extra
	dh_install

override_dh_link:
	rm -rf debian/gxineplugin/usr/share/doc/gxineplugin
	# Allow for arbitrary architectures
	mkdir -p debian/gxineplugin/usr/lib/mozilla/plugins debian/gxineplugin/usr/lib/mozilla-firefox/plugins
	ln -sr debian/gxineplugin/usr/lib/*/gxine/gxineplugin.so debian/gxineplugin/usr/lib/mozilla/plugins/
	ln debian/gxineplugin/usr/lib/mozilla/plugins/gxineplugin.so debian/gxineplugin/usr/lib/mozilla-firefox/plugins/
	dh_link
