#!/usr/bin/make -f
%:
	dh $@ --with javahelper --with maven-repo-helper

override_dh_auto_clean:
	dh_auto_clean
	-ant -f debian/build.xml clean

override_dh_auto_build:
	dh_auto_build
	ant -f debian/build.xml
	export DOC_SRC=docs/docbkx DOC_GEN=docs/reference && \
		xmlto -o $${DOC_GEN}/html --skip-validation xhtml \
			$${DOC_SRC}/index.xml && \
		xmlto -o $${DOC_GEN}/pdf --with-fop --skip-validation pdf \
			$${DOC_SRC}/index.xml && \
		mv $${DOC_GEN}/pdf/index.pdf $${DOC_GEN}/pdf/spring-ldap-reference.pdf
	ant -f debian/build.xml reference

get-orig-source:
	cd $(dir $(firstword $(MAKEFILE_LIST)))../ && \
	uscan \
		--verbose \
		--no-symlink \
		--destdir $(CURDIR)      \
		--watchfile debian/watch \
		--force-download

DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
MAVEN_REPO := http://repo1.maven.org/maven2

get-orig-pom:
	for component in core-tiger core parent; \
	do \
		wget -U NoAgent-1.0 -O debian/poms/spring-ldap-$${component}.pom \
			$(MAVEN_REPO)/org/springframework/ldap/spring-ldap-$${component}/$(DEB_UPSTREAM_VERSION)/spring-ldap-$${component}-$(DEB_UPSTREAM_VERSION).pom ;\
	done

