#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
#include /usr/share/cdbs/1/rules/dpatch.mk

DEB_INSTALL_CHANGELOGS_ALL = HISTORY

# install target directory for xine plugins
XINEPLUGINDIR = libxine1-xvdr/$(shell xine-config --plugindir)

MAKE_OPTIONS = DVBDIR=/usr VDRDIR=/usr/include/vdr LIBDIR=. \
               LOCALEDIR=debian/tmp/usr/share/locale \
               NOSIGNAL_IMAGE_FILE=/usr/share/libxine1-xvdr/nosignal.mpg \
               HAVE_DBUS_GLIB_1=yes

common-build-arch::
	$(MAKE) all $(MAKE_OPTIONS)

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

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

install/vdr-plugin-xineliboutput::
	install -d debian/$(XINEPLUGINDIR)/post/
	install xineplug_inp_xvdr.so debian/$(XINEPLUGINDIR)/
	install xineplug_post_*.so debian/$(XINEPLUGINDIR)/post/

install/xineliboutput-sxfe:: manpages
	install -m 644 -D debian/icon.svg debian/xineliboutput-sxfe/usr/share/icons/xineliboutput-sxfe.svg

install/xineliboutput-fbfe:: manpages
	install -m 644 -D debian/icon.svg debian/xineliboutput-sxfe/usr/share/icons/xineliboutput-fbfe.svg

manpages:
	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

VERSION_DATE = $(shell /bin/date --utc +%0Y%0m%0d.%0k%0M)
VERSION_ID = 1.0.6~cvs$(VERSION_DATE)
get-orig-source:
	echo Downloading vdr-live $(VERSION_ID) from cvs...
	cvs -z3 -d:pserver:anonymous@xineliboutput.cvs.sourceforge.net:/cvsroot/xineliboutput export -r xineliboutput-1_0_6 vdr-xineliboutput
	tar cvfz "../vdr-plugin-xineliboutput_$(VERSION_ID).orig.tar.gz" vdr-xineliboutput
	rm -rf vdr-xineliboutput
	dch -v "$(VERSION_ID)-1" "New Upstream Snapshot"
