##################################################
# This makefile is for the files needed to extend 
# JAT to use agents running O-Plan.

JAVA=java
JAVAC=javac -g

JBFPATH=/hame/gw/public_html/jat/classes/jbf
JB=jb.class
JBFLAGS=-yyerror yyverror

BISON=bison
BISONFLAGS=

JF=jf.class
JFFLAGS=--$(FLEXOPT)
FLEXOPT=Cem

FLEX=flex
FLEXFLAGS=-$(FLEXOPT)
LEXTEMPLATE=yylex.$(FLEXOPT).template

##################################################
# targets:
fopl: Clause.class FOPLFormula.class Term.class Symbol.class YYparse.class

clean:
	rm *.class YY*.java fopl.yy.c fopl.tab.c fopl.lex.j


##################################################
# files to be built:
Clause.class ClauseSet.class FormulaSet.class RTProver.class: \
		Clause.java ClauseSet.java FormulaSet.java RTProver.java \
		Formula.class
	$(JAVAC) Clause.java ClauseSet.java FormulaSet.java RTProver.java 

FOPLFormula.class Formula.class LitLObject.class Literal.class \
		Proposition.class NegFormula.class BinConFormula.class \
		MultiConFormula.class QuantFormula.class: \
		FOPLFormula.java Formula.java LitLObject.java Literal.java \
		Proposition.java NegFormula.java BinConFormula.java \
		MultiConFormula.java QuantFormula.java \
		Term.class
	$(JAVAC) FOPLFormula.java Formula.java LitLObject.java Literal.java \
		Proposition.java NegFormula.java BinConFormula.java \
		MultiConFormula.java QuantFormula.java

Term.class ConstTerm.class VarTerm.class FunctTerm.class Substitution.class \
		UnificationException.class SubTermEnum.class: \
		Term.java ConstTerm.java VarTerm.java FunctTerm.java \
		Substitution.java UnificationException.java SubTermEnum.java \
		Symbol.class
	$(JAVAC) Term.java ConstTerm.java VarTerm.java FunctTerm.java \
		Substitution.java UnificationException.java SubTermEnum.java

Symbol.class UnnamedSymbol.class Variable.class: \
		Symbol.java UnnamedSymbol.java Variable.java \
		YYparse.class
	$(JAVAC) Symbol.java UnnamedSymbol.java Variable.java

YYparse.class YYlex.class YYtokentypes.class: \
		Term.java Formula.java \
		YYparse.java YYlex.java YYtokentypes.java
	$(JAVAC) YYparse.java YYlex.java YYtokentypes.java

YYparse.java YYlex.java YYtokentypes.java: \
		fopl.tab.c fopl.lex.j \
		$(JBFPATH)/yyparse.template \
		$(JBFPATH)/yytokentypes.template $(JBFPATH)/$(JB)
	$(JAVA) jbf.jb -package JavaAgent.resource.fopl $(JBFLAGS) \
		fopl.tab.c \
		$(JBFPATH)/yyparse.template YYparse.java \
		$(JBFPATH)/yytokentypes.template YYtokentypes.java \
		fopl.lex.j YYlex.java

fopl.tab.c: fopl.y fopl.lex
	$(BISON) $(BISONFLAGS) fopl.y

fopl.lex.j: fopl.yy.c $(JBFPATH)/$(LEXTEMPLATE) $(JBFPATH)/$(JF)
	$(JAVA) jbf.jf -package JavaAgent.resource.fopl $(JFFLAGS) \
		fopl.yy.c $(JBFPATH)/$(LEXTEMPLATE) \
		fopl.lex.j

fopl.yy.c: fopl.lex fopl.y
	$(FLEX) $(FLEXFLAGS) -ofopl.yy.c fopl.lex
