# $Id: makefile,v 1.2.2.1 2002/05/07 14:22:48 bill Exp $

TOP=.

include $(TOP)/makefile.config

SUB_DIRS=com

all: jar


# build the jarfile
jar: subdirs
	cd $(CLASSDIR); jar cvf ../xt.jar com

# build all class files in current dir and all sub dirs
subdirs: build-ready
	@echo "making $(CURRENT_DIR) ..."
	@if [ "$(SUB_DIRS)" != "" ]; then \
	for dir in $(SUB_DIRS); do \
	  cd $${dir}; \
	  $(MAKE); \
	  cd ..; \
	done; \
	fi

# remove all class files in current dir and all sub dirs
clean:
	@echo "cleaning $(CURRENT_DIR) ..."
	@if test -e $(CLASSDIR); then rm -rf $(CLASSDIR); fi
	@if test -e $(DOCDIR); then rm -rf $(DOCDIR); fi
	@if test -e $(DISTDIR); then rm -rf $(DISTDIR); fi
	@if test -e $(TOP)/../xt.jar; then rm -f $(TOP)/../xt.jar; fi
	@if test -e $(TOP)/../$(DISTNAME).tgz; then rm -f $(TOP)/../$(DISTNAME).tgz; fi
	@if test -e $(TOP)/../$(DISTNAME).zip; then rm -f $(TOP)/../$(DISTNAME).zip; fi


dist: jar javadoc
	if ! test -e $(DISTDIR); then mkdir $(DISTDIR); fi; \
	(cd $(TOP)/..; tar cvf - `find ./src -path "*/CVS" -prune -o -type f -print`) | \
	(cd $(DISTDIR) ; tar xvf -)
	echo "moved src"
	(cd $(TOP)/..; tar cvf - `find ./lib -path "*/CVS" -prune -o -type f -print`) | \
	(cd $(DISTDIR) ; tar xvf -)
	echo "moved lib"
	(cd $(TOP)/..; tar cvf - `find ./doc -path "*/CVS" -prune -o -type f -print`) | \
	(cd $(DISTDIR) ; tar xvf -)
	echo "moved doc"
	(cd $(TOP)/..; tar cvf - `find ./demo -path "*/CVS" -prune -o -type f -print`) | \
	(cd $(DISTDIR) ; tar xvf -);
	echo "moved demo"; 
	cp $(TOP)/../README $(TOP)/../index.html $(TOP)/../xt.jar \
	   $(TOP)/../copying.txt $(TOP)/../copyingjc.txt $(DISTDIR) ; 
	(cd $(TOP)/..; tar czvf $(DISTNAME).tgz  $(DISTNAME) ); \



javadoc: build-ready
	javadoc $(JAVAC_CLASSPATH) -sourcepath . \
               -d $(APIDOCDIR) \
               -use \
               -splitIndex \
               -doctitle "XT Version 20020426a" \
		-windowtitle "XT Version 20020426a API" \
               -J-Xmx180m \
		@javadoc-packages

build-ready:
	if ! test -e $(CLASSDIR); then mkdir $(CLASSDIR); fi; \
	if ! test -e $(DOCDIR); then mkdir $(DOCDIR); fi; \
	if ! test -e $(APIDOCDIR); then mkdir $(APIDOCDIR); fi
