#!/usr/bin/make -f

DESTDIR:=$(shell pwd)/debian/tmp
PACKAGE:=xviddetect

build: build-stamp
build-stamp:
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	dh_clean
	rm -f build-stamp install-stamp

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	install -m 0755 xviddetect $(DESTDIR)/usr/bin/xviddetect
	install -m 0755 anXious $(DESTDIR)/usr/bin/anXious
	install -m 0644 video.ids $(DESTDIR)/usr/share/xviddetect/video.ids
	install -m 0644 pci.ids $(DESTDIR)/usr/share/xviddetect/pci.ids
	install -m 0644 debian/XF86Config.template $(DESTDIR)/usr/share/xviddetect/XF86Config.template
	install -m 0644 debian/templates $(DESTDIR)/usr/share/xviddetect/anXious.templates
	install -m 0644 UI.pm $(DESTDIR)/usr/lib/perl5/Debian/xviddetect/UI.pm
	install -m 0644 README $(DESTDIR)/usr/share/doc/$(PACKAGE)/README
	install -m 0644 debian/changelog $(DESTDIR)/usr/share/doc/$(PACKAGE)/changelog.Debian
	gzip -9 $(DESTDIR)/usr/share/doc/$(PACKAGE)/changelog.Debian
	install -m 0644 debian/copyright $(DESTDIR)/usr/share/doc/$(PACKAGE)/copyright
	install -m 0755 xinst $(DESTDIR)/usr/share/doc/$(PACKAGE)/xinst
	
	pod2man --center "Debian specific manpage" xviddetect.pod | gzip -9c > $(DESTDIR)/usr/share/man/man1/xviddetect.1.gz
	chmod 0644 $(DESTDIR)/usr/share/man/man1/xviddetect.1.gz
	pod2man --center "Debian specific manpage" anXious.pod | gzip -9c > $(DESTDIR)/usr/share/man/man1/anXious.1.gz
	chmod 0644 $(DESTDIR)/usr/share/man/man1/anXious.1.gz
	
	touch install-stamp

# Build architecture-independent files here.
binary-indep: clean build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: clean build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installchangelogs
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
