#!/usr/bin/make -f

#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs -Wl,--as-needed

VENDOR ?= $(shell dpkg-vendor --query vendor 2>/dev/null || echo Debian)

ifeq ($(DEB_HOST_ARCH_OS), linux)
WITH_HWINFO = --with-gudev
endif

%:
	dh $@ --with xine

override_dh_clean:
	rm -f debian/gxine.postinst
	dh_clean

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- \
		$(confflags) \
		--prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc \
		--libdir=\$${prefix}/lib \
		--disable-integration-wizard --enable-watchdog \
		--with-logo-format=image $(WITH_HWINFO) \
		VENDOR_PKG_VERSION="`dpkg-parsechangelog | sed -ne '/^Version:/ { s/^.* //; p }'`; $(VENDOR)" \
		GSSCMD=/usr/bin/gnome-screensaver-command \
		XSSCMD=/usr/bin/xscreensaver-command \
		CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"

override_dh_auto_build:
	dh_auto_build
	cp debian/gxine.postinst.in debian/gxine.postinst
	sed -ie s^@XINE_LIST@^`pkg-config --variable=xine_list libxine`^g debian/gxine.postinst

override_dh_install:
	find debian/tmp -name '*.la' -print -delete
	mkdir -p debian/gxine/var/lib/xine
	dh_install

override_dh_missing:
	dh_missing --fail-missing

override_dh_xine:
	dh_xine -pgxine x gnome ffmpeg
