#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

#j2re_recommends := $(shell apt-cache show j2re1.4 | sed -n '/^Recommends:/s/^Recommends: *//p')

# Yea I don't like the debian/compat file...
# This is the debhelper compatability version to use.
export DH_COMPAT=4

build: debian/j2re-recommends

update:
	@if [ ! -f /usr/lib/j2se/1.4/jre/bin/java ]; then \
	    echo "Please install the j2re1.4 package for updating the dependencies"; \
	    false; \
	fi
	rm -f debian/j2re-recommends
	$(MAKE) -f debian/rules build

debian/j2re-recommends:
	apt-cache --no-all-versions --installed show j2re1.4 \
		| sed -n '/^Recommends:/s/^Recommends: */j2re:Recommends=/p' > $@
	
clean:
	dh_testdir
	dh_testroot
	dh_clean

install:
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	dh_install

binary-arch: install
	dh_testdir
	dh_testroot
	dh_installchangelogs 
	dh_installdocs
#	dh_installexamples
#	dh_installmenu
	dh_link
	dh_compress 
	dh_fixperms
	dh_installdeb
	cp debian/j2re-recommends debian/$(firstword $(shell dh_listpackages)).substvars
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-indep: 

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