#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

override_dh_auto_configure:
	# Setup symlinks: ant
	mkdir -p lib/ant/lib
	ln -sf /usr/share/ant/lib/ant.jar lib/ant/lib

	# JUnit
	mkdir -p lib/junit
	ln -sf /usr/share/java/junit.jar  lib/junit

	# commons-logging
	mkdir -p lib/commons
	ln -sf /usr/share/java/commons-logging.jar lib/commons/commons.jar

	dh_auto_configure

override_dh_auto_build:
	# Build the manpages
	docbook-to-man debian/aj.sgml        > debian/aj.1
	docbook-to-man debian/ajbrowser.sgml > debian/ajbrowser.1
	sh debian/manpage_from.sh docs/devGuideDB/ajc.xml   > debian/ajc.1
	sh debian/manpage_from.sh docs/devGuideDB/ajdoc.xml > debian/ajdoc.1

	dh_auto_build
	ant -f docs/build.xml dist '-Dbuild.time=$(shell date '--date=@$(SOURCE_DATE_EPOCH)' --utc +'%A %b %d, %Y at %H:%M:%S %Z')'

override_dh_auto_install:
	mh_installpom -plibaspectj-java -e$(DEB_VERSION_UPSTREAM) aspectjrt/target/flattened-pom.xml
	mh_installjar -plibaspectj-java -e$(DEB_VERSION_UPSTREAM) -l aspectjrt/target/flattened-pom.xml aspectjrt/target/aspectjrt-$(DEB_VERSION_UPSTREAM).jar
	mh_installpom -plibaspectj-java -e$(DEB_VERSION_UPSTREAM) aspectjtools/target/flattened-pom.xml
	mh_installjar -plibaspectj-java -e$(DEB_VERSION_UPSTREAM) -l aspectjtools/target/flattened-pom.xml aspectjtools/target/aspectjtools-$(DEB_VERSION_UPSTREAM).jar
	mh_installpom -plibaspectj-java -e$(DEB_VERSION_UPSTREAM) aspectjweaver/target/flattened-pom.xml
	mh_installjar -plibaspectj-java -e$(DEB_VERSION_UPSTREAM) -l aspectjweaver/target/flattened-pom.xml aspectjweaver/target/aspectjweaver-$(DEB_VERSION_UPSTREAM).jar

	cp docs/dist/doc/changes.html docs/target/changelog.html
	html2text -o docs/target/changelog.txt docs/target/changelog.html
	dh_installchangelogs docs/target/changelog.html
	dh_installchangelogs docs/target/changelog.txt
