
CC=g++
OPTIONS=-O3

object_files = CPT.o CPDTree.o BayesNet.o
unit_tests = test-CPT test-CPDTree test-BayesNet

all: ${object_files} ${unit_tests}
build:  clean all

clean:
	/bin/rm -rf ${unit_tests} *.o tmp_BN.* core
transfer:  clean

# object files
CPT.o:	probability.h CPD.h CPT.h CPT.cpp
	${CC} ${OPTIONS} -c CPT.cpp

CPDTree.o:	probability.h CPD.h CPDTree.h CPDTree.cpp
	${CC} ${OPTIONS} -c CPDTree.cpp

BayesNet.o:	probability.h CPD.h BayesNet.h BayesNet.cpp
	${CC} ${OPTIONS} -c BayesNet.cpp

OptionParser.o:  OptionParser.h OptionParser.cpp
	${CC} ${OPTIONS} -c OptionParser.cpp


# unit tests
test-CPT:	test-CPT.cpp CPT.o 
	${CC} ${OPTIONS} -o test-CPT test-CPT.cpp CPT.o

test-CPDTree:	test-CPDTree.cpp CPDTree.o CPT.o OptionParser.o
	${CC} ${OPTIONS} -o test-CPDTree test-CPDTree.cpp CPDTree.o CPT.o OptionParser.o

test-BayesNet:	test-BayesNet.cpp BayesNet.o CPT.o CPDTree.o
	${CC} ${OPTIONS} -o test-BayesNet test-BayesNet.cpp BayesNet.o CPT.o CPDTree.o



# optional usage: run the unit tests (some have temporary files, etc.)
run-test-CPDTree:	test-CPDTree
	test-CPDTree > tmp_BN.test-CPDTree.dot
	dot -Tps < tmp_BN.test-CPDTree.dot > tmp_BN.test-CPDTree.ps
	gv tmp_BN.test-CPDTree.ps &

run-test-BayesNet:	test-BayesNet
	test-BayesNet > tmp_BN.test-BayesNet.dot
	dot -Tps < tmp_BN.test-BayesNet.dot > tmp_BN.test-BayesNet.ps
	gv tmp_BN.test-BayesNet.ps &
