#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/maven.mk

JAVA_HOME := /usr/lib/jvm/default-java
DEB_MAVEN_ARGS := -f debian/pom.xml

# Downloads and renames upstream guacamole-common-js source
guacamole-common-js-source:
	uscan --package guacamole-common-js --watchfile debian/watch.guacamole-common-js --upstream-version $(DEB_UPSTREAM_VERSION) --force-download --rename
	mv ../guacamole-common-js_$(DEB_UPSTREAM_VERSION).orig.tar.gz ../guacamole_$(DEB_UPSTREAM_VERSION).orig-guacamole-common-js.tar.gz

# Downloads and renames upstream guacamole-ext source
guacamole-ext-source:
	uscan --package guacamole-ext --watchfile debian/watch.guacamole-ext --upstream-version $(DEB_UPSTREAM_VERSION) --force-download --rename
	mv ../guacamole-ext_$(DEB_UPSTREAM_VERSION).orig.tar.gz ../guacamole_$(DEB_UPSTREAM_VERSION).orig-guacamole-ext.tar.gz

# Downloads and renames upstream guacamole-common source
guacamole-common-source:
	uscan --package guacamole-common --watchfile debian/watch.guacamole-common --upstream-version $(DEB_UPSTREAM_VERSION) --force-download --rename
	mv ../guacamole-common_$(DEB_UPSTREAM_VERSION).orig.tar.gz ../guacamole_$(DEB_UPSTREAM_VERSION).orig-guacamole-common.tar.gz

# Downloads and renames upstream guacamole source
guacamole-source:
	uscan --package guacamole-guacamole --watchfile debian/watch --upstream-version $(DEB_UPSTREAM_VERSION) --force-download --rename
	mv ../guacamole-guacamole_$(DEB_UPSTREAM_VERSION).orig.tar.gz ../guacamole_$(DEB_UPSTREAM_VERSION).orig-guacamole.tar.gz

# Creates an empty guacamole_VERSION.orig.tar.gz file (necessary for multi-
# tarball build)
guacamole-empty-orig:
	tar -czf ../guacamole_$(DEB_UPSTREAM_VERSION).orig.tar.gz -T /dev/null

# Downloads and renames all upstream source tarballs
get-orig-source: guacamole-empty-orig guacamole-source guacamole-common-source guacamole-ext-source guacamole-common-js-source

# maven-debian-helper leaves empty mvn-build after clean
# po-debconf docs recommend running debconf-updatepo here
clean::
	debconf-updatepo
	$(RM) mvn-build

