#!/usr/bin/make -f
#
# fixme: we should do all this with dh_make and not by hand!
#

build:

clean:
	rm -rf debian/tmp
	rm -rf html
	rm -f *.tmp

binary-indep:
	rm -rf debian/tmp
	mkdir -p debian/tmp/usr/bin
	mkdir -p debian/tmp/usr/share/perl5/MobiPerl
	mkdir -p debian/tmp/usr/share/perl5/Image
	mkdir -p debian/tmp/usr/share/perl5/Palm
	mkdir -p debian/tmp/DEBIAN
	install Palm/* debian/tmp/usr/share/perl5/Palm
	ln -s /usr/share/perl5/Image/Info/BMP.pm debian/tmp/usr/share/perl5/Image/BMP.pm
	install MobiPerl/* debian/tmp/usr/share/perl5/MobiPerl
	install -m 755 mobi2html html2mobi lit2mobi mobi2mobi opf2mobi mobils   debian/tmp/usr/bin
	# and now build the html-files, fixing the upstream-makefile:
	mkdir -p html
	pod2html mobi2mobi > html/mobi2mobi.html
	pod2html mobils > html/mobils.html
	pod2html mobi2html > html/mobi2html.html
	pod2html lit2mobi > html/lit2mobi.html
	pod2html opf2mobi > html/opf2mobi.html
	pod2html html2mobi > html/html2mobi.html
	# now install html-files
	mkdir -p debian/tmp/usr/share/doc/mobiperl
	cp html/*.html debian/tmp/usr/share/doc/mobiperl
	# and the debian-docs:
	cp gpl-3.0.txt debian/tmp/usr/share/doc/mobiperl
	cp README debian/tmp/usr/share/doc/mobiperl
	cp debian/README.Debian debian/tmp/usr/share/doc/mobiperl
	# and the Debian-menu-file:
	mkdir -p debian/tmp/usr/share/menu
	cp debian/menu debian/tmp/usr/share/menu/mobiperl
	dpkg-gencontrol -isp
	
binary-arch:
	chown -R root:root debian/tmp
	chmod -R u+w,go=rX debian/tmp
	dpkg --build debian/tmp ..


binary: binary-indep binary-arch

.PHONY: binary
