#
# Makefile for the Calendar Tool testing implementation.
#


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

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

#
# Define the path to the implementation source files.
#
IMPLE_SRC_DIR = ../../../../implementation/source/java

#
# Schedule test files, including testing stub files.
#
SCHEDULE_TEST_FILES = \
	caltool/schedule/*.java \
	$(IMPLE_SRC_DIR)/caltool/options/Options.java \
	$(IMPLE_SRC_DIR)/caltool/schedule/*.java \
	$(IMPLE_SRC_DIR)/caltool/caldb/UserCalendar.java \
	$(IMPLE_SRC_DIR)/caltool/caldb/ItemKey.java \
	$(IMPLE_SRC_DIR)/caltool/PrecondViolation.java


#
# UserCalendar test files
#
UCAL_TEST_FILES = \
	caltool/caldb/UserCalendarTest.java \
	caltool/caldb/UserCalendarTestDriver.java

# List of packages
PACKAGES = \
		caltool \
		caltool/admin \
		caltool/admin_ui \
		caltool/caldb \
		caltool/caltool_ui \
		caltool/edit \
		caltool/edit_ui \
		caltool/file \
		caltool/file_ui \
		caltool/help \
		caltool/help_ui \
		caltool/options \
		caltool/options_ui \
		caltool/schedule \
		caltool/schedule_ui \
		caltool/view \
		caltool/view_ui

#
# Compile and execute the Schedule module test.
#
scheduletest:	compile_schedule run_schedule diff_schedule

compile_schedule:
	@echo "Compiling tests ..."
	@javac -g \
	  -classpath $(LIB309) \
	  -sourcepath .:$(IMPLE_SRC_DIR) \
	  -d $(EXECUTABLES) \
		$(SCHEDULE_TEST_FILES)

run_schedule:
	@echo "Running tests ..."
	@csh -q -c 'cd $(EXECUTABLES); \
	    java caltool.schedule.ScheduleTestDriver > \
		output/scheduletest.out'

diff_schedule:
	@csh -q -c 'cd $(EXECUTABLES); \
	    echo "Comparing results ..." ; \
	    echo "No further output means no differences found." ; \
	    diff output/scheduletest.out ../../output-good/scheduletest.out > \
		diffs/scheduletest.diff ; \
	    if (! -z diffs/scheduletest.diff) echo "Difference found."'

#
# Make the most recent output the good output.
#
good:
	cp -p $(EXECUTABLES)/output/*.out ../../output-good

ucaltest:
	javac -g -classpath $(CLASS_PATH) $(UCAL_TEST_FILES)

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