#!/usr/bin/make -f
# debian/rules file for bsh (uses cdbs)

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

PACKAGE              := $(DEB_SOURCE_PACKAGE)
VERSION              := $(DEB_UPSTREAM_VERSION)
JAVA_HOME            := /usr/lib/jvm/default-java
DEB_JARS             := servlet-api-2.5 bsf javacc
DEB_ANT_BUILD_TARGET := javadoc jarall test

include /usr/share/gcj/debian_defaults
ifneq (,$(filter $(DEB_HOST_ARCH), $(gcj_native_archs)))
  with_gcj_native := yes
endif

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
    export ANT_OPTS=-Dcompile.debug=true -Dcompile.optimize=false
else
    export ANT_OPTS=-Dcompile.debug=true -Dcompile.optimize=true
endif

clean::
	# remove tests which also fail with SUN JDK 1.4
	rm -f tests/test-scripts/accessibility.bsh \
				tests/test-scripts/class13.bsh \
				tests/test-scripts/class3.bsh \
				tests/test-scripts/classinterf1.bsh \
				tests/test-scripts/strings.bsh
	-rm -rf debian/tmp

install/$(PACKAGE)::
	mh_installpoms -p$(PACKAGE)
	mh_installjar -p$(PACKAGE) -l debian/pom.xml dist/$(PACKAGE)-$(VERSION).jar
	install -m 755 debian/_bsh debian/bsh/usr/bin/bsh
	install -m 755 debian/xbsh debian/bsh/usr/bin/

ifeq ($(with_gcj_native),yes)
install/bsh-gcj:: install/bsh
	dh_nativejava -pbsh-gcj
endif

install/bsh-src:: binary-install/bsh-doc
	mkdir -p debian/bsh-src/usr/src/bsh-src
	tar --exclude debian --exclude classes --exclude dist --exclude api \
		-zcf debian/bsh-src/usr/src/bsh-src/bsh.tar.gz *

get-orig-source:
	-uscan --download-version $(DEB_UPSTREAM_VERSION) --force-download --rename --repack

get-orig-pom:
	wget -O debian/pom.xml http://repository.sonatype.org/service/local/repositories/central/content/org/beanshell/bsh/$(VERSION)/bsh-$(VERSION).pom

