#!/usr/bin/make -f

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

JAVA_HOME := /usr/lib/jvm/default-java
ANT_HOME  := /usr/share/ant
LIB	  := /usr/share/java/jaxen.jar

DEB_JARS := jaxen

DEB_ANT_CLEAN_TARGET := clean
DEB_ANT_BUILD_TARGET := all
DEB_ANT_BUILDFILE := debian/build.xml

include /usr/share/gcj/debian_defaults

ifneq (,$(filter $(DEB_HOST_ARCH), $(gcj_native_archs)))
  with_gcj_native := yes
endif

install/libgui-commands-java::
	# repack with Class-Path in manifest file.
	cd build && \
	file=META-INF/MANIFEST.MF ; \
	jar -xf gui-commands.jar && \
		sed -i '/^[ \r\t]*$$/d' $$file && \
		/bin/echo -e "Class-Path: $(LIB)\r" >> $$file && \
	jar -cfm gui-commands.jar $$file .

	mv build/gui-commands.jar build/gui-commands-$(DEB_UPSTREAM_VERSION).jar
	dh_install -plibgui-commands-java build/gui-commands-$(DEB_UPSTREAM_VERSION).jar usr/share/java/
	dh_link -plibgui-commands-java usr/share/java/gui-commands-$(DEB_UPSTREAM_VERSION).jar usr/share/java/gui-commands.jar

ifeq ($(with_gcj_native),yes)
install/libgui-commands-java-gcj:: install/libgui-commands-java
	dh_nativejava -plibgui-commands-java-gcj
endif

install/libgui-commands-java-doc::
	dh_installdocs -plibgui-commands-java-doc build/api
