#
# This file is part of "The Java Telnet Applet".
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# "The Java Telnet Applet" is distributed in the hope that it will be 
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with The JAVA Telnet Applet; see the file COPYING.  If not, write to 
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# $Id: Makefile,v 1.24 1997/07/08 09:34:38 leo Exp $

OPT	= -O
DEBUG	= 

.SUFFIXES: .java .class .html

.java.class:
	javac $(OPT) $(DEBUG) $<

.class.html:	
	appletviewer $@

HELP:
	@echo 'To compile "The Java Telnet Applet" do one of the following:'
	@echo '------------------------------------------------------------'
	@echo 'make all          - compile all files to classes'
	@echo 'make test         - compile applet and run appletviewer'
	@echo 'make telnet       - compile standalone and run telnet'
	@echo 'make chartest     - compile character display test and run'
	@echo 'make proxy        - compile proxy server'
	@echo 'make doc          - create documentation'
	@echo 'make clean        - delete backup files'
	@echo 'make realclean    - make clean and delete .class files'

all: appWrapper.class telnet.class modules tools
	@echo All classes created.

test: appWrapper.class telnet.class
	appletviewer index.test.html

telnet:	appWrapper.class telnet.class
	java telnet localhost	

chartest: CharDisplayTest.class
	appletviewer CharDisplay.html

doc:
	javadoc -d Documentation/Source -author -version display socket modules \
	        telnet.java appWrapper.java \
                tools/proxy.java CharDisplayTest.java IOtest.java \
                TelnetWrapper.java

tar:	
	rm -f ../telnet.tgz ../telnet.zip
	(cd ..; tar cvf - Telnet | gzip - > telnet.tgz)
	(cd ..; zip -r telnet.zip Telnet)

bin-tar: all
	(cd ..; tar cvf - Telnet/*.class Telnet/*/*.class \
                          Telnet/README Telnet/INSTALL Telnet/COPYING \
		| gzip - > classes.tgz)
	(cd ..; zip -r classes.zip Telnet/*.class Telnet/*/*.class \
                                   Telnet/README Telnet/INSTALL Telnet/COPYING)

revision: 
	grep @version *.java */*.java|awk '{split($$6,rev,".");printf("%-26.26s %2.2s.%-2.2s (%s)\n",$$1,rev[1],rev[2],$$7);}' > REVISION
	rcs2log *.java */*.java > CHANGES
	sed -e"s/package:.*$$/package: `date`/" index.html > index.html.x
	mv index.html.x index.html

dist:	realclean all doc revision tar bin-tar
	@echo DONE.

clean:	
	rm -f *~ */*~

realclean:	clean
	rm -f *.class */*.class
	(cd tools; make clean)

# dependencies

appWrapper.class: appWrapper.java frame.java

telnet.class: display socket modules \
              telnet.java 

# display classes and terminal emulation

display: display/vt320.class 
display/vt320.class: display/CharDisplay.class display/TerminalHost.class display/Terminal.class
display/CharDisplay.class: display/SoftFont.class

# socket io classes
socket: socket/TelnetIO.class

socket/TelnetIO.class: socket/StatusPeer.class

# dynamical loaded modules
modules: modules/ButtonBar.class \
         modules/Script.class \
         modules/MudConnector.class

modules/ButtonBar.class: modules/Module.java modules/ButtonBar.java frame.java
modules/Script.class: modules/Module.java modules/Script.java
modules/MudConnector.class: modules/Module.java modules/MudConnector.java

# tools
tools: tools/proxy.class CharDisplayTest.class \
       IOtest.class TelnetWrapper.class tools/mrelayd

tools/proxy.class: tools/proxy.java
CharDisplayTest.class: CharDisplayTest.java display/CharDisplay.java
IOtest.class: IOtest.java socket/TelnetIO.java
TelnetWrapper.class: TelnetWrapper.java socket/TelnetIO.java
tools/mrelayd: tools/mrelayd.c
