
# Specify the commands
CC      = gcc
CPP	= g++
#CC = icc
#CPP = icpc
#CC	= g++ -g
RM	= /bin/rm -f
#CFLAGS = -O3
CFLAGS	= -g3 -O3 -malign-double
#CFLAGS = -axiMKW -O3 
#CFLAGS	= -g3 
#LDFLAGS = -Xlinker -stack_size -Xlinker 1000000
#LDFLAGS = -Xlinker -stack_addr -Xlinker c0000000

DOC = doc++
DOC_DIR = doc
SRC = src
GEN_SRC = gen_src

# Specify the path and the library
INCS	= -I../comp590/cudd-2.3.1/include -I${GEN_SRC} -I${SRC}
LIBS	= -L../comp590/cudd-2.3.1/libgcc -lobj -lcudd -ldddmp -lmtr \
	-lst -lutil -lepd

PLAT = ${OS}-${CC}

TARGET	= ${PLAT}/bddksat
RAWOBJS	= FormulaAlg.o FormulaDAG.o Formula.o globals.o cluster.o \
KSATChecker.o KSATImage.o lwblex.o lwb.o main.o ProfileLogger.o \
tptplex.o tptp.o VarOrder.o TransitionRelation.o graph.o

OBJS = ${RAWOBJS:%.o=${PLAT}/%.o}

# Rules for generating the target

all: ${PLAT} ${GEN_SRC} ${TARGET} 
${PLAT}:
	mkdir ${PLAT}

${GEN_SRC}:
	mkdir ${GEN_SRC}

${TARGET}:${OBJS}
	${CPP} ${CFLAGS} -o ${TARGET} ${OBJS} ${LIBS} ${LDFLAGS}
	rm ksat
	ln -s ${TARGET} ksat

${PLAT}/%.o : ${SRC}/%.cc
	${CPP} ${CFLAGS} ${INCS} -o $@ -c $<

${PLAT}/%.o : ${GEN_SRC}/%.c
	${CC} ${CFLAGS} ${INCS} -o $@ -c $<

${GEN_SRC}/%.c ${GEN_SRC}/%.h ${GEN_SRC}/%lex.c: ${SRC}/%.y ${SRC}/%.l 
	${YACC} -o${GEN_SRC}/$*.c -d -p$* ${SRC}/$*.y
	${LEX} -o${GEN_SRC}/$*lex.c -P$* ${SRC}/$*.l 

.PHONY: doc clean depend

doc:
	rm -rf ${DOC_DIR}
	mkdir ${DOC_DIR}
	${DOC} -d ${DOC_DIR} -m ${SRC}/*.cc ${SRC}/*.h

clean:
	${RM} core *.o ${TARGET} ${PLAT}/* *~ *.bak ${DOC_DIR}/* \
	${MYLIBS}/*.o ${MYLIBS}/lib${MYLIBS}.a

depend:
	makedepend ${INCS} ${GEN_SRC}/*.c ${SRC}/*.cc


# DO NOT DELETE

