#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/quilt/quilt.make

# Force ant to use gcj as JDK to make the build more reproducible
export JAVA_HOME=/usr/lib/jvm/java-gcj

#DEB_ANT_ARGS := -verbose

# This has to be exported to make some magic below work.
export DH_OPTIONS

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	ANT_OPT += -Dcompiler.optimize=false
else
	ANT_OPT += -Dcompiler.optimize=true
endif

ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	ANT_OPT += -Dcompiler.debug=true
else
	ANT_OPT += -Dcompiler.debug=false
endif

build: patch build-stamp

build-stamp: 
	dh_testdir

	ant -noinput $(ANT_OPT) all
	
	touch build-stamp

clean: 
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -Rf dist/reports

	-ant -noinput $(ANT_OPT) clean
	chmod -x dist/jclic/icons/*.png
	${MAKE} -f debian/rules unpatch
	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_clean -k -i
	dh_installdirs -i
	dh_install -i
	cp -f dist/jclic/icons/author.png   $(CURDIR)/debian/jclic/usr/share/pixmaps/jclicauthor.png
	cp -f dist/jclic/icons/reports.png $(CURDIR)/debian/jclic/usr/share/pixmaps/jclicreports.png

binary-arch: build install
# We have nothing to do by default.


binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
	dh_install
	dh_installmenu
	dh_installman debian/*.1
	dh_icons
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install 
