#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

MAKE_OPTIONS = VDRDIR=/usr/include/vdr LIBDIR=/usr/lib LOCALEDIR=debian/tmp/usr/share/locale \
               NOSIGNAL_IMAGE_FILE=/usr/share/libxine2-xvdr/nosignal.mpg

CXXFLAGS += $(shell pkg-config vdr --variable=cxxflags)
CFLAGS += $(shell pkg-config vdr --variable=cflags)

%:
	dh $@

override_dh_auto_configure:
	./configure

override_dh_auto_build:
	dh_auto_build -- all $(MAKE_OPTIONS)
	txt2man -s 1 -t vdr-sxfe -v "Remote X-Server frontend for vdr-plugin-xineliboutput" debian/vdr-sxfe.1.txt >vdr-sxfe.1
	txt2man -s 1 -t vdr-fbfe -v "Remote Framebuffer frontend for vdr-plugin-xineliboutput" debian/vdr-fbfe.1.txt >vdr-fbfe.1

override_dh_auto_clean:
	$(MAKE) -o .dependencies clean $(MAKE_OPTIONS)
	rm -f vdr-sxfe.1 vdr-fbfe.1

override_dh_gencontrol:
	sh /usr/share/vdr-dev/dependencies.sh
	dpkg -p libxine2-dev | sed -re '/^Version:/! d; s/^Version: (([0-9]:)?([0-9]+\.){2}[0-9]+).*$$/xine:Depends=libxine2 (>= \1)/' \
	>> debian/libxine2-xvdr.substvars
	dh_gencontrol

override_dh_auto_install:
	dh_auto_install -- $(MAKE_OPTIONS)
	install -m 644 -D debian/icon.svg debian/xineliboutput-sxfe/usr/share/icons/xineliboutput-sxfe.svg
	install -m 644 -D debian/icon.svg debian/xineliboutput-sxfe/usr/share/icons/xineliboutput-fbfe.svg

override_dh_strip:
	dh_strip -pvdr-plugin-xineliboutput --dbg-package=vdr-plugin-xineliboutput-dbg
	dh_strip -plibxineliboutput-fbfe --dbg-package=libxineliboutput-fbfe-dbg
	dh_strip -plibxineliboutput-sxfe --dbg-package=libxineliboutput-sxfe-dbg
	dh_strip -pxineliboutput-fbfe --dbg-package=xineliboutput-fbfe-dbg
	dh_strip -pxineliboutput-sxfe --dbg-package=xineliboutput-sxfe-dbg
	dh_strip -plibxine2-xvdr --dbg-package=libxine2-xvdr-dbg

get-vcs-snapshot:
	sh debian/get-vcs-snapshot.sh
