
TOMCAT_HOME = @TOMCAT_HOME@
VERSION = @VERSION@
JAVAC = @JAVAC@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
INSTALL = @INSTALL@
JAR = @JAR@

#SWORDORBJAR=sword-orb-$(VERSION).jar
SWORDORBJAR=sword-orb.jar

all: $(SWORDORBJAR)

src/org/crosswire/sword/orb/SWMgr.java: $(top_builddir)/corba/java/src/org/crosswire/util/Base64.java
	idlj -pkgTranslate swordorb org.crosswire.sword.orb -td src $(top_srcdir)/corba/swordorb.idl

classes/org/crosswire/sword/orb/SwordOrb.class: src/org/crosswire/sword/orb/SWMgr.java
	mkdir -p $(top_builddir)/corba/java/classes
	$(JAVAC) -classpath ${TOMCAT_HOME}/common/lib/servlet-api.jar -d $(top_builddir)/corba/java/classes -sourcepath src src/org/crosswire/sword/orb/*.java src/org/crosswire/util/*.java

$(top_builddir)/corba/java/src/org/crosswire/util/Base64.java:
	cp -a $(top_srcdir)/corba/java/src .
	find . -name .svn|xargs rm -r

clean:
	-rm src/org/crosswire/sword/orb/SW*.java
	-rm src/org/crosswire/sword/orb/_SW*.java
	-rm src/org/crosswire/sword/orb/Mod*.java
	-rm src/org/crosswire/sword/orb/Search*.java
	-rm src/org/crosswire/sword/orb/String*.java
	-rm -rf classes/*
	-rmdir -p src/org/crosswire/sword/orb
	-rm $(SWORDORBJAR)

$(SWORDORBJAR): classes/org/crosswire/sword/orb/SwordOrb.class
	$(JAR) cf $(SWORDORBJAR) -C $(top_builddir)/corba/java/classes org

install:
	@INSTALL@ $(SWORDORBJAR) $(TOMCAT_HOME)/common/lib

uninstall:
	-rm $(TOMCAT_HOME)/common/lib/$(SWORDORBJAR)
