#
# This makefile defines compilation and execution rules for the rmi example.
# See the javadoc for the operational details of the client and server
# programs.
#

#
# Define the default server to be falcon, on the default port of 1099.  To
# change the host from the make command line, specify a different value for the
# HOST variable.  E.g., to change the host to be vogon on port 1098, run this
# makefile as follows on the vogon host:
#
#     rmiregistry 1098 &
#     make HOST=vogon:1098 runsl
#
# This will run the server with a liberal policy on host vogon, rmi port 1098.
# See below for the definition of the runsl rule.
#
HOST = falcon

#
# Compile everything.
#
all: s c jarc


#
# Compile the server.
#
s:
		javac -g server/Server.java \
			 server/ServerInterface.java
		rmic server.Server

#
# Compile the client.
#
c:
		javac -g client/Client.java \
			 client/ClientData.java \
			 client/ClientDataInterface.java
#
# Start the Java RMI registry on a UNIX host.
#
runr:
		rmiregistry &

#
# Start the Java RMI registry on a Windows host.
#
runrw:
		start rmiregistry


#
# Run the server on the UNIX host $(HOST), using a strong security policy.
#
runs:
	java -Djava.security.policy=java.policy server.Server $(HOST)

#
# Run the server on the Windows host thyme, using a strong security policy.
#
runs2:
	java -Djava.security.policy=java.policy server.Server thyme

#
# Run the server on $(HOST) with a more liberal Java security policy.
#
runsl:
	java -Djava.security.policy=java.policy.liberal server.Server $(HOST)

#
# Run the server on thyme with a more liberal Java security policy.
#
runs2l:
	java -Djava.security.policy=java.policy.liberal server.Server thyme


#
# Run the client to talk to the $(HOST) server.
#
runc:
	java -Djava.security.policy=java.policy client.Client $(HOST)

#
# Run the client to talk to the $(HOST) server, with a liberal security policy.
#
runcl:
	java -Djava.security.policy=java.policy.liberal client.Client $(HOST)

#
# Run the client to talk to the thyme server.
#
runc2:
	java -Djava.security.policy=java.policy client.Client thyme


#
# Jar up the client code; note the need to include the server stubs and server
# interface.
#
jarc:
	jar cf client.jar client server/*Stub.class server/*Interface*

#
# Run the client from the jar file.
#
runcj:
	java -classpath client.jar -Djava.security.policy=java.policy \
	    client.Client $(HOST)


#
# Generate javadoc.
#
javadoc:
	javadoc -sourcepath . -d doc/javadoc \
		-overview overview.html \
		-doctitle "CSC 309 RMI Example" \
		-windowtitle "CSC 309 RMI Example" \
		    client server

#
# Generate a full jar file, including all sources.
#
jar:
	cd ..; jar cf rmi.jar rmi

#
# Prepare printable source listings.  This generates line-numbered, small-font
# PDF and PostScript files in the doc directory and its subdirectories.
#
print:	gen view lp
gen:
	csh -c .make-gen
view:
	csh -c .make-view
lp:
	csh -c .make-lp