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

.SUFFIXES : 

.SUFFIXES : .java .class

JFLAGS :=
JCCFLAGS := -O

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 demo   	to run whatever is the latest demo"
	@echo "make optimiseer	to optimise the er integration"
	@echo "make editor	to run the command line editor"
	@echo "make gui   	to run the graphical compound transformation"
	@echo "           	tool (models/schemas should be defined first!)"
	@echo "make templates	to create the template transformations"
	@echo "             	(models should be defined first!)"

basic : reinitreps models schemas transformations 

demo : basic readuniversity templates gui 

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

#change by nick 31-7-02 so that the graphical tool can display
#er and sql92 schemas
gui : graphicalapi graphicaler graphicalsql92 
	java uk.ac.ic.doc.automed.gui.SchemaTool

testintegrate: TestIntegration.class
	java TestIntegration

optimiseer : OptimiseERTransformationPathway.class
	java OptimiseERTransformationPathway

optimisesql92 : OptimiseTransformationPathway.class
	java OptimiseTransformationPathway

readuniversity : ReadUniversity

university : ReadUniversity UniversityDatabaseIntegration

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

UniversityDatabaseIntegration : UniversityDatabaseIntegration.class
	time java UniversityDatabaseIntegration

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

ReadUniversity : ReadMetaData.class
	java ReadMetaData \
		-setFeatures 6 \
		-recreateSQL92Model \
		-debug ${DEBUG} \
		-user ${DBUSER} \
		-password ${DBPASSWD} \
		-driver ${DBDRIVER} \
		-url ${DBURL}university1 \
		-schema uni_s1 \
		-url ${DBURL}university2 \
		-schema uni_s2 \
		-url ${DBURL}university3 \
		-schema uni_s3 \
		-url ${DBURL}university4 \
		-schema uni_s4 \
		-url ${DBURL}university5 \
		-schema uni_s5

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


#added by nick 31-7-02 to define the graphical representations of models
#if the models don't exist, they are created!
graphicalapi: DefineGraphicalRepresentationAPI.class
	java $(JFLAGS) DefineGraphicalRepresentationAPI

graphicaler: DefineERGraphicalRepresentation.class
	java $(JFLAGS) DefineERGraphicalRepresentation

graphicalsql92: DefineSQL92GraphicalRepresentation.class
	java $(JFLAGS) DefineSQL92GraphicalRepresentation


#order should be: create models, then templates
templates: statements ertemplates sql92templates

statements: templates/DefineStatements.class
	java $(JFLAGS) DefineStatements

sql92templates: templates/Contract.class templates/ExtendField.class templates/FieldToTableBasic.class templates/MandatoryField.class
	java $(JFLAGS) Contract
	java $(JFLAGS) ExtendField
	java $(JFLAGS) FieldToTableBasic
	java $(JFLAGS) MandatoryField


ertemplates: templates/AttributeToEntityBasic.class templates/AttributeToEntityBasicAndAddAttribute.class templates/MandatoryAttribute.class templates/AttributeGeneralization.class
	java $(JFLAGS) AttributeToEntityBasic
	java $(JFLAGS) AttributeToEntityBasicAndAddAttribute
	java $(JFLAGS) MandatoryAttribute
	java $(JFLAGS) AttributeGeneralization



clean :
	rm -f templates/*.class *.class *~

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

