#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export CLASSPATH=/usr/share/java/commons-logging.jar:/usr/share/java/jss.jar:/usr/share/java/tomcat-coyote.jar:/usr/share/java/oscache.jar

UPSTREAM_VERSION := $(shell dpkg-parsechangelog | sed -n 's/^Version: *\(.*\)-.*$$/\1/ p' | sed -e 's/~.*//')
MOD_MAJOR_VERSION := $(word 1, $(subst ., ,$(UPSTREAM_VERSION)))
MOD_MINOR_VERSION := $(word 2, $(subst ., ,$(UPSTREAM_VERSION)))
MOD_PATCH_VERSION := $(word 3, $(subst ., ,$(UPSTREAM_VERSION)))

override_dh_install::
	mkdir -p $(CURDIR)/debian/tmp/usr/share/java
	install -m 644 build/jars/tomcatjss.jar \
		$(CURDIR)/debian/tmp/usr/share/java/tomcatjss-$(MOD_MAJOR_VERSION).$(MOD_MINOR_VERSION).$(MOD_PATCH_VERSION).jar
	cd $(CURDIR)/debian/tmp/usr/share/java/ && \
	ln -s tomcatjss-$(MOD_MAJOR_VERSION).$(MOD_MINOR_VERSION).$(MOD_PATCH_VERSION).jar tomcatjss.jar
	dh_install

%:
	dh $@ --with javahelper
