LIBRARY      =  ArgoLib
SRCDIR       =  .
OUTDIR       =  ../Release
DEGUBDIR     =  ../Debug
DATE         = $(shell date +%d%m%y-%H%M)

CC = g++
CPPFLAGS = -Wall -DNDEBUG -D__GNUCPP__  -DPROOF -I$(SRCDIR) -O3 -g

VPATH =	$(SRCDIR):				\
	$(SRCDIR)/expressions:			\
	$(SRCDIR)/rewriting:			\
	$(SRCDIR)/output:			\
	$(SRCDIR)/theory:			\
	$(SRCDIR)/theory/signature:		\
	$(SRCDIR)/theory/decision_procedure:	\
	$(SRCDIR)/theory/pra:			\
	$(SRCDIR)/theory/euf:			\
	$(SRCDIR)/sat:				\
	$(SRCDIR)/satsolver:			\
	$(SRCDIR)/auxiliary:			\

SOURCES      =  auxiliary/Names.cpp					\
		expressions/Expression.cpp				\
		expressions/ExpressionNode.cpp				\
		expressions/NumeralNode.cpp				\
		expressions/OperatorNode.cpp				\
		expressions/ExpressionFactory.cpp			\
		expressions/Sorts.cpp					\
		output/Output.cpp					\
	 	output/OutputFormater.cpp				\
		output/SMTFormater.cpp					\
		output/TextFormater.cpp					\
		theory/Theory.cpp     	       				\
		satsolver/Solver.cpp             			\
		satsolver/ResolutionClause.cpp         			\
		satsolver/Clause.cpp	         			\
		satsolver/Variable.cpp	         			\
		satsolver/Literal.cpp	         			\
		satsolver/BacktrackableStack.cpp	 		\
		satsolver/SolverStatistics.cpp	       			\
		sat/SatAbstraction.cpp					\
		sat/CNFConversion.cpp					\
		theory/Signature.cpp					\
		theory/pra/PRALiteral.cpp				\
		theory/pra/PRAPolyform.cpp				\
		theory/pra/Simplex.cpp					\
		theory/pra/QDelta.cpp					\
		theory/pra/VariableOrdering.cpp				\
		theory/pra/Matrix.cpp					\
		theory/euf/EUF.cpp					\
		Main.cpp

NOTDIRSOURCES = $(notdir $(SOURCES))

.PHONY: all clean dist fresh maxspeed examples test run clean-tilde

$(LIBRARY):  $(addprefix $(OUTDIR)/, $(NOTDIRSOURCES:.cpp=.o))
	@echo Linking...
	@$(CC) $(CPPFLAGS) -o $@ $^ -lgmpxx -lgmp

test: $(LIBRARY)
	$(LIBRARY)
	test/compare test/test.exp test/test.real

run: $(LIBRARY)
	$(LIBRARY)

all: $(LIBRARY)

fresh: clean all

clean-tilde : 
	@-rm -f $(shell find . -name '*~')

clean:	clean-tilde
	@echo Removing binaries...
	@-rm -rf $(LIBRARY)
	@-rm -rf $(OUTDIR)/*
	@-rm -rf $(DEGUBDIR)/*
	@-rm -rf $(SRCDIR)/*.plg $(SRCDIR)/*.ncb $(SRCDIR)/*.opt

dist: clean
	@echo Removing old archive
	@-rm ../../$(LIBRARY).*.tar.gz
	@echo Creating new archive...
	@-tar -czv -C ../.. -f ../../$(LIBRARY).$(DATE).tar.gz $(LIBRARY)

maxspeed: CPPFLAGS =  -DNDEBUG -o3 
maxspeed: all


$(OUTDIR)/%.o: %.cpp
	@echo Compiling $<
	$(CC) $(CPPFLAGS) -c -o $@ $<

callgrind:
	-rm callgrind.out.*
	callgrind --collect-jumps=yes --dump-instr=yes --simulate-cache=no $(LIBRARY) ../problems/callgrind.smt
	kcachegrind &
