#!/usr/bin/make -f

NAME    := jutils
VERSION := $(shell dpkg-parsechangelog| sed -n '/^Version/{s/Version: \(.*\)-[0-9]*$$/\1/;s/+dfsg//p}')
CVSDATE := $(shell echo $(VERSION)|sed -n 's/\(....\)\(..\)\(..\)/\1-\2-\3/p')
TMPDIR  := tmp-orig-tar
TAR     := ../$(NAME)_$(VERSION)+dfsg.orig.tar.gz

export JAVA_HOME=/usr/lib/jvm/default-java

%:
	dh --with javahelper $@

override_dh_auto_build:
	ant all
	ant javadoc

override_dh_auto_clean:
	dh_auto_clean

get-orig-source:
	-rm $(TAR)
	cvs -d :pserver:guest@cvs.dev.java.net:/cvs export -D $(CVSDATE) -d $(TMPDIR) $(NAME)
	echo "The following files will not be included in Debian tarball:"
	cd $(TMPDIR) && find . \( -name '*.class' -o -name '*.jar' \) -print
	cd $(TMPDIR) && ZIP=--best tar --exclude-vcs --exclude *.jar --exclude *.class -zcf $(TAR) .
	rm -rf $(TMPDIR)
