#
# Makefile for the Calendar Tool Java implementation.
#

# Java 6 tools.
JAVAC = /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/javac

# CSC 309 java lib directory
LIB309 =	/home/gfisher/classes/309/lib/JVM

# Directory for generated executable files
EXECUTABLES =	../../executables/JVM

# Files to compile
FILES = \
		caltool/*.java \
		caltool/model/*.java \
		caltool/model/admin/*.java \
		caltool/model/admin/administrator/*.java \
		caltool/model/admin/user/*.java \
		caltool/view/admin/*.java \
		caltool/view/admin/administrator/*.java \
		caltool/view/admin/user/*.java \
		caltool/model/caldb/*.java \
		caltool/view/*.java \
		caltool/model/edit/*.java \
		caltool/view/edit/*.java \
		caltool/model/file/*.java \
		caltool/view/file/*.java \
		caltool/model/help/*.java \
		caltool/view/help/*.java \
		caltool/model/options/*.java \
		caltool/view/options/*.java \
		caltool/model/schedule/*.java \
		caltool/view/schedule/*.java \
		caltool/model/server/*.java \
		caltool/model/view/*.java \
		caltool/view/view/*.java

# List of packages
PACKAGES = \
		caltool \
		caltool/model \
		caltool/view \
		caltool/model/admin \
		caltool/model/admin/administrator \
		caltool/model/admin/user \
		caltool/view/admin \
		caltool/view/admin/administrator \
		caltool/view/admin/user \
		caltool/model/caldb \
		caltool/model/edit \
		caltool/view/edit \
		caltool/model/file \
		caltool/view/file \
		caltool/model/help \
		caltool/view/help \
		caltool/model/options \
		caltool/view/options \
		caltool/model/schedule \
		caltool/view/schedule \
		caltool/model/server \
		caltool/model/view \
		caltool/view/view

# Run the Java compiler on all of the files.
all:	$(FILES)
#	echo $(FILES)
	$(JAVAC) -g \
	  -classpath $(LIB309) \
	  -d $(EXECUTABLES) \
		$(FILES)
	cd $(EXECUTABLES); make


# The preceding rule results in an executable program that is invoked as
# follows from the implementation/executables/JVM directory:
#
#     java caltool.Main
#
# The makefile in that dir has more information about altenate forms of java
# program invocation.

# Compile with the gnu java compiler.
gcj:	$(FILES)
#	echo $(FILES)
	gcj -g \
	  -classpath $(LIB309):. \
	  -d $(EXECUTABLES) \
	  --main=Main \
		$(FILES)

# Compile and JML check just the Schedule.java class.
sched:
	javac 


# Generate a source dir command for emacs jdb debugging.
emacs-jdb:
	csh -q -c ".make-emacs-jdb-dirs $(PACKAGES)"

# Run the Java compiler on all of the files, putting the class files in this
# source dir, where bluej wants them.
bluej:	$(FILES)
#	echo $(FILES)
	javac -g \
	  -classpath $(LIB309) \
	  -d . \
		$(FILES)
	cd $(EXECUTABLES); make exec

# Print source files in small-font, line-numbered, two-column format.
print:
	csh -q -c ".make-print $(PACKAGES)"


# Echo the package names for use in command-line processing of all packages,
# such as copying a uniform .cvsignore file into each package dir.
echop:
	@echo $(PACKAGES)


# Remove all .class files from the executables/JVM dir.
clean:
	csh -q -c ".make-clean"

# Remove all .class files from this dir.
cleanbluej:
	csh -q -c ".make-clean-bluej"