# This file is part of PARAM.
#
# PARAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PARAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PARAM.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright 2009-2010 Ernst Moritz Hahn (emh@cs.uni-sb.de)

# please modify the following entries
CXX = g++
BOOST_VERSION = 39
BOOST_PATH = $(HOME)/boost_1_39_0
GCC_VERSION := $(shell gcc -dumpversion)
GCC_SHORT_VERSION=44

####

# for 64 bit machines, please change the "-32" entries to "-64" and adjust 


CVC_PATH = cvc3
CVC_LIB  = $(CVC_PATH)/lib-linux-i686
# CVC_LIB  = $(CVC_PATH)/lib-linux-x86_64
CVC_INC  = $(CVC_PATH)/include

LIB_BOOST_PO =  $(BOOST_PATH)/bin.v2/libs/program_options/build/gcc-$(GCC_VERSION)/release/link-static/threading-multi/libboost_program_options-gcc$(GCC_SHORT_VERSION)-mt-1_$(BOOST_VERSION).a
# LIB_BOOST_PO = $(HOME)/boost_1_42_0/bin.v2/libs/program_options/build/gcc-4.4.1/release/link-static/threading-multi/libboost_program_options.a 

LIBCOCOA =$(HOME)/CoCoALib-0.9931/lib/libcocoa.a

LIB    = -L/opt/local/lib -lgmp -lgmpxx -Ldp -L$(CVC_LIB) -lcvc3 -L. $(LIBCOCOA)
BOOST_H = $(BOOST_PATH)

INCLUDE_DIRS = -I. -I$(CVC_INC) -I$(BOOST_H) -I$(HOME)/CoCoALib-0.9931/include	

CPU          = native
FLAGS        = -DWITH_PARAM -Wall -O2 -ggdb -march=$(CPU) -pipe $(INCLUDE_DIRS)
CXXFLAGS     = $(FLAGS)

################
# object files #
################

PARAMETRIC_OBJ := parametric/param.o \
	parametric/PASSStateExplorer.o \
	parametric/ProgramOptions.o \
	parametric/SparseMC.o \
	parametric/Statistics.o \
	parametric/TransProp.o \
	parametric/MayChange.o \
	parametric/StrongRefiner.o \
	parametric/Partition.o \
	parametric/Quotient.o \
	parametric/WeakRefiner.o \
	parametric/Refiner.o \
	parametric/Eliminator.o \
	parametric/BoundedIterator.o \
	infamation/Model2C-32.o \
	infamation/expr2c-32.o

RATIONALFUNCTION_OBJ := rationalFunction/Polynomial.o \
	rationalFunction/Geobucket.o \
	rationalFunction/RationalFunction.o \
	rationalFunction/RationalCmp.o \
	rationalFunction/Base.o \
	rationalFunction/CVC3Converter.o \
	rationalFunction/CancellatorCoCoA.o \

PARAM_LIBS :=  $(PARAMETRIC_OBJ) $(RATIONALFUNCTION_OBJ) $(LIB_BOOST_PO) -lfrontend-32 $(LIB) -ldl dp/SMT-32.o dp/CVC3SMT-32.o
param: $(PARAMETRIC_OBJ) $(RATIONALFUNCTION_OBJ) libfrontend-32.a dp/SMT-32.o dp/CVC3SMT-32.o
	$(CXX) $(FLAGS) -o param $(PARAM_LIBS)

###########
# cleanup #
###########
clean:
	# @if [ -e Makefile.dep ]; then rm Makefile.dep; fi
	@for obj in $(OBJ); do \
		(if [ -e $$obj ]; then rm $$obj; fi) \
		done
	@for dir in $(DIRS); do \
		(cd $$dir; \
		 rm -rf *.o lang/parser.tab.{hpp,cpp} lang/lex.yy.c .*.d *~;\
		 cd ..) \
		done

######################
# build dependencies #
######################
DIRS := rationalFunction parametric
Makefile.dep:
	@if [ ! -e Makefile.dep ]; then echo "# automatic dependencies" > Makefile.dep; fi
	@makedepend -w -a -Y -fMakefile.dep -- $(FLAGS) $(INCLUDE_DIRS) &> /dev/null
	@for dir in $(DIRS); do \
		(makedepend -w -a -Y -fMakefile.dep -- $(FLAGS) $(INCLUDE_DIRS) -- $$dir/*.hpp $$dir/*.h $$dir/*.cpp) \
	done &> /dev/null

depend:
	@if [ -e Makefile.dep ]; then rm Makefile.dep; fi
	make Makefile.dep

########################################
# automatically generated dependencies #
########################################
include Makefile.dep
