#!/usr/bin/make -f

VERSION_DFSG = $(shell dpkg-parsechangelog | grep Version | egrep -o "[0-9]+\.[0-9]+(\.[0-9]+)?\+dfsg")
VERSION = $(shell echo $(VERSION_DFSG) | sed s/\+dfsg//)

clean:
	dh clean
	find -name "*.o" | xargs -r rm
	find -name "*.qm" | xargs -r rm
	find -name .ui | xargs -r rm -rf
	find -name .moc | xargs -r rm -rf
	find -name Makefile | xargs -r rm 
	find -name Makefile.tmp | xargs -r rm 

override_dh_auto_configure:
	./configure --prefix=/usr --omit-local-ffmpeg --no-configurator

override_dh_auto_install:
	$(MAKE) install INSTALL_ROOT=$(CURDIR)/debian/tmp
	$(MAKE) -C qdvdauthor/plugins/simpledvd -f Makefile.tmp install INSTALL_ROOT=$(CURDIR)/debian/tmp
	$(MAKE) -C qdvdauthor/plugins/complexdvd -f Makefile.tmp install INSTALL_ROOT=$(CURDIR)/debian/tmp
	$(MAKE) -C qdvdauthor/plugins/menuslide install INSTALL_ROOT=$(CURDIR)/debian/tmp

override_dh_makeshlibs:

get-orig-source:
	echo $(VERSION) $(VERSION_DFSG)
	uscan --no-symlink --force-download --verbose
	cd debian && tar xvzf ../../qdvdauthor-$(VERSION).tar.gz
	cd debian/qdvdauthor-$(VERSION) && rm bin/bbdmux && rm bin/dvd-slideshow && find -name CVS | xargs rm -rf
	mv debian/qdvdauthor-$(VERSION) debian/qdvdauthor-$(VERSION_DFSG)
	cd debian && tar cvzf ../../qdvdauthor_$(VERSION_DFSG).orig.tar.gz qdvdauthor-$(VERSION_DFSG)
	rm -rf debian/qdvdauthor-$(VERSION_DFSG)

%:
	dh $@
