run : 
	@echo "Use the following"
	@echo "make basic	to create er, relational, and integrate "
	@echo "          	er models"
	@echo "make university  to run University database integration demo"
	@echo "make bank        to run Bank database integration demo"
	@echo "make bank-xml    to run Bank XML file integration demo"
	@echo "make ugpg        to run UG/PG student integration demo"
	@echo "make demo   	to run whatever is the latest demo under test"
	@echo "make optimiser	to optimise the er integration"
	@echo "make editor	to run the command line editor"
	@echo "make gui		to run the graphical editor"
	@echo "make templates	to create the template transformations"
	@echo "make templatesgui  to run graphical interface to execute template"
	@echo "	               transformations"
	@echo "make icde03      to build example for ICDE03 paper"
	@echo "make reinitialise   to wipe everything from the repository"

PHONY : all classes models schemas transformations  erdemo clean \
	 universityreadme readuniversity \
	 university UniversityDatabaseIntegration \
	 ReadUniversity ReadUniversity1 ReadUniversity2 ReadUniversity3 

.SUFFIXES : 

.SUFFIXES : .java .class

JFLAGS :=
JCCFLAGS := -O -deprecation

icde03 : reinitialise ReadICDE03 ICDE03

reinitialise : DefineRepository.class
	java DefineRepository

bank-xml : semistructured/xml/XMLBankIntegration.class semistructured/xml/XMLBankIntegrationQueries.class
	java semistructured.xml.XMLBankIntegration
	java semistructured.xml.XMLBankIntegrationQueries

basic : reinitreps models schemas transformations

nutshell : AutoMedInANutshell.class
	java AutoMedInANutshell

ugpg : UGPGStudentsExample/DefineRepository.class \
	UGPGStudentsExample/DefineSSDFormats.class \
	UGPGStudentsExample/DefinePatterns.class \
	UGPGStudentsExample/DefineSchemas.class \
	UGPGStudentsExample/DefineTransformations.class
	java UGPGStudentsExample.DefineRepository
	java UGPGStudentsExample.DefineSchemas
	java UGPGStudentsExample.DefinePatterns
	java UGPGStudentsExample.DefineSSDFormats
	java UGPGStudentsExample.DefineTransformations

demo : basic university templates templatesdemo 

editor :
	java uk.ac.ic.doc.automed.editor.Editor

gui :
	java uk.ac.ic.doc.automed.editor.Gui

gui_bigmen :
	java -Xmx1024M -Xss1024M uk.ac.ic.doc.automed.editor.Gui

optimiseer : OptimiseERTransformationPathway.class
	java OptimiseERTransformationPathway

optimisesql92 : OptimiseTransformationPathway.class
	java OptimiseTransformationPathway


university :  UniversityDatabaseWrapping \
	UniversityDatabaseIntegration

university_template :  UniversityDatabaseWrapping \
	UniversityTemplateIntegration

university_automatic :  UniversityDatabaseWrapping \
	UniversityAutomaticIntegration

automatic_integration: DefineMatchedSchemas.class IntegrateMatchedSchemas.class 
	java $(JFLAGS) DefineMatchedSchemas
	java $(JFLAGS) IntegrateMatchedSchemas


bank :  BankDatabaseIntegration

universityreadme :
	cat README.unidemo

reinitreps : DefineRepository.class
	java $(JFLAGS) DefineRepository

models : DefineModels.class
	java $(JFLAGS) DefineModels

schemas : DefineSchemas.class
	java $(JFLAGS) DefineSchemas

transformations : DefineTransformations.class
	java $(JFLAGS) DefineTransformations

erdemo : ERDemo.class
	java $(JFLAGS) ERDemo

UniversityDatabaseWrapping : UniversityDatabaseWrapping.class AutoMedUtils.class
	java UniversityDatabaseWrapping \
		-debug ${DEBUG} \
		-user ${DBUSER} \
		-password ${DBPASSWD} \
		-driver ${DBDRIVER} \
		-url ${DBURL}

UniversityDatabaseIntegration : UniversityDatabaseIntegration.class
	java UniversityDatabaseIntegration \
		-debug ${DEBUG} 

UniversityTemplateIntegration : UniversityTemplateIntegration.class
	java UniversityTemplateIntegration \
		-debug ${DEBUG}

UniversityAutomaticIntegration : UniversityAutomaticIntegration.class
	java UniversityAutomaticIntegration \
		-debug ${DEBUG}

BankDatabaseIntegration : BankDatabaseIntegration.class
	java BankDatabaseIntegration \
		-debug ${DEBUG} \
		-user ${DBUSER} \
		-password ${DBPASSWD} \
		-driver ${DBDRIVER} \
		-url ${DBURL}

StudentCourseIntegration : StudentCourseIntegration.class
	java StudentCourseIntegration \
		-debug ${DEBUG} \
		-user ${DBUSER} \
		-password ${DBPASSWD} \
		-driver ${DBDRIVER} \
		-url ${DBURL}

ICDE03 : ICDE03.class
	java ICDE03

ReadICDE03 : ReadMetaData.class
	java ReadMetaData \
		-setFeatures 0 \
		-recreateSQL92Model \
		-debug ${DEBUG} \
		-user ${DBUSER} \
		-password ${DBPASSWD} \
		-driver ${DBDRIVER} \
		-url ${DBURL}ug \
		-schema ug \
		-url ${DBURL}phd \
		-schema phd


#ReadMetaData.class : ReadMetaData.java
#	javac ReadMetaData.java

templates:
	@cd templates && ./javaenv.sh $(MAKE) basic

templatesdemo:
	@cd templates && ./javaenv.sh $(MAKE) demo

templatesgui:
	@cd templates && ./javaenv.sh $(MAKE) templatesgui

clean :
	rm -f oldgui/*.class *.class drawables/*.class *~ \
	semistructured/*.class	semistructured/xml/*.class utils/*.class \
	UGPGStudentsExample/*.class hs_err_pid*.log error_log errors \
	hdmstore/*.class query_processing/*.class 
	@cd templates && ./javaenv.sh $(MAKE) clean

classes : $(patsubst %.java,%.class,$(wildcard *.java))

%.class : %.java
	javac $(JCCFLAGS) $< 

