# Java compiler 
#JAVAC=jikes
JAVAC=javac
JDK_VERSION=1.3

# The name of the javadoc program
JAVADOC=javadoc

# Classflags to pass to the Java compiler, e.g. to tell it where
# to find jar files not in your classpath. Don't remove ${CLASSDIR}
#CLASSFLAGS=-classpath /users/ekr/src/java/cryptix32.jar:/users/ekr/src/java/cryptix-asn1.jar:/usr/local/jdk1.2.2:${CLASSDIR}

# Flags to pass to the Java compiler
JFLAGS=-g $(CLASSFLAGS)

# Flags to pass to javadoc
# Possibly comment some of these out for JDK 1.1.X
DOCFLAGS=-public  -footer "Copyright (C) 1999-2001 Claymore Systems, Inc." -doctitle '<H1>PureTLS Documentation</H1>' -windowtitle "PureTLS Documentation"
DOCFLAGS += $(CLASSFLAGS) -sourcepath .


# No user serviceable parts beyond this point
MAINPREFIX=..
BUILDDIR=$(MAINPREFIX)/build/
CLASSDIR=$(BUILDDIR)classes/
DOCDIR=${BUILDDIR}doc/api/
ROOT=./
SRCROOTDIR=
JFLAGS += -d $(CLASSDIR)

include ${ROOT}/COM/claymoresystems/cert/targets.mk
include ${ROOT}COM/claymoresystems/crypto/targets.mk
include ${ROOT}COM/claymoresystems/provider/targets.mk	
include ${ROOT}COM/claymoresystems/ptls/targets.mk
include ${ROOT}COM/claymoresystems/sslg/targets.mk
include ${ROOT}COM/claymoresystems/util/targets.mk

.PHONY:  doc clean demo

LIBNAME=puretls.jar
LIBPATH=${BUILDDIR}puretls.jar

# Test to see if the JAR currently exists
JAREXISTS=$(wildcard ${LIBPATH})

# Now set the jar flags appropriately: cf if the jar
# doesn't exist, uf if it does
ifeq (${JAREXISTS},)
JARFLAGS=cf
else
JARFLAGS=uf
endif


all:	${LIBPATH} doc
lib:	${LIBPATH}

#Make from the dist directory
inplace:
	(cd ../../../../; make lib)

# This Makefile has the bug that if you remove the jar file it will
# remake all the .class files as well. This might be viewed as
# feature. 
${LIBPATH}: ${SOURCEFILES}
	- mkdir -p ${CLASSDIR}
	(${JAVAC} ${JFLAGS} $? )
	echo "Adding  $(?:%.java=%.class) to ${LIBNAME}"
	(cd ${CLASSDIR}; jar ${JARFLAGS} ../${LIBNAME} ${?:%.java=%.class})

doc:
	- rm -rf ${DOCDIR}
	- mkdir -p ${DOCDIR} 
	${JAVADOC} ${DOCFLAGS}  -d ${DOCDIR} ${PACKAGES}


clean:
	rm -rf ${MAINPREFIX}/build
	rm -f ${OBJECTS}
	rm -f ${LIBPATH}
	rm -f COM/claymoresystems/ptls/SocketBasedSocketImpl.java

dist:
	(cd ${ROOT}/COM/claymoresystems/ptls/dist; sh build-dist.sh)

demo:
	${JAVAC} ${JFLAGS} ${ROOT}COM/claymoresystems/ptls/demo/*.java
	(cd ${CLASSDIR}; jar cf ../puretlsdemo.jar COM/claymoresystems/ptls/demo/*.class)


# Gross special case hack to deal with incompatibility for
# SocketBasedSocketImpl for JDK 1.4
COM/claymoresystems/ptls/SocketBasedSocketImpl.java: COM/claymoresystems/ptls/SocketBasedSocketImpl.java-$(JDK_VERSION)
	cp $? $@

.KEEP_STATE:
