#!/usr/bin/make -f
# -*- makefile -*-

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

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

XULRUNNERVER=10.0.2
XULRUNNERTAR=xulrunner-$(XULRUNNERVER).source.tar.bz2
DESTDIR=dest

all: build

clean:
	rm -f stamp-*
	rm -fr mozilla-release
	rm -fr debian/cf-xulrunner
	rm -fr debian/cf-xulrunner-dev
	rm -fr debian/tmp
	rm -f debian/files
	rm -f debian/*.log

install: build
	cd mozilla-release; $(MAKE) -f client.mk install DESTDIR=$(CURDIR)/debian/tmp

build: stamp-build-xulrunner

stamp-build-xulrunner: stamp-configure-xulrunner
	cd mozilla-release; $(MAKE) -f client.mk build
	touch $@

stamp-configure-xulrunner: stamp-download-xulrunner
	rm -fr mozilla-release
	tar jxf $(XULRUNNERTAR)
	cp mozconfig mozilla-release/.mozconfig
	touch $@

stamp-download-xulrunner:
	if ! bunzip2 -t $(XULRUNNERTAR); then \
		wget http://ftp.indexdata.dk/pub/support/$(XULRUNNERTAR) ; \
	fi
	touch $@

# Debian stuff
# Build architecture-independent files here.

binary-indep: install

binary-arch: install
	dh_testdir
	dh_testroot
#	dh_installdocs
	dh_installchangelogs 
#	dh_installexamples
	dh_install 
#       dh_installmenu
#       dh_installdebconf       
#       dh_installlogrotate
#       dh_installemacsen
#       dh_installpam
#       dh_installmime
#       dh_installinit
#       dh_installcron
#       dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#       dh_perl
#       dh_python
	dh_makeshlibs 
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch

