Added some unit tests that I forgot earlier
[libdai.git] / Makefile
index 07ed794..d76c56f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,10 +16,10 @@ include Makefile.conf
 
 # Set version and date
 DAI_VERSION="git HEAD"
-DAI_DATE="April 1, 2010 - or later"
+DAI_DATE="May 12, 2010, or later"
 
 # Directories of libDAI sources
-# Location libDAI headers
+# Location of libDAI headers
 INC=include/dai
 # Location of libDAI source files
 SRC=src
@@ -34,20 +34,17 @@ else
 endif
 
 # Define build targets
-TARGETS:=tests utils lib examples
-ifneq ($(OS),WINDOWS)
-  TARGETS:=$(TARGETS) unittests
+TARGETS:=lib tests utils examples
+ifdef WITH_MATLAB
+  TARGETS:=$(TARGETS) matlabs
 endif
-TARGETS:=$(TARGETS) testregression testem
+TARGETS:=$(TARGETS) unittests testregression testem
 ifdef WITH_DOC
   TARGETS:=$(TARGETS) doc
 endif
-ifdef WITH_MATLAB
-  TARGETS:=$(TARGETS) matlabs
-endif
 
 # Define conditional build targets
-NAMES:=bipgraph graph varset daialg alldai clustergraph factor factorgraph properties regiongraph util weightedgraph exceptions exactinf evidence emalg
+NAMES:=graph dag bipgraph varset daialg alldai clustergraph factor factorgraph properties regiongraph util weightedgraph exceptions exactinf evidence emalg
 ifdef WITH_BP
   WITHFLAGS:=$(WITHFLAGS) -DDAI_WITH_BP
   NAMES:=$(NAMES) bp
@@ -92,9 +89,13 @@ ifdef WITH_CBP
   WITHFLAGS:=$(WITHFLAGS) -DDAI_WITH_CBP
   NAMES:=$(NAMES) bbp cbp bp_dual
 endif
+ifdef WITH_DECMAP
+  WITHFLAGS:=$(WITHFLAGS) -DDAI_WITH_DECMAP
+  NAMES:=$(NAMES) decmap
+endif
 
 # Define standard libDAI header dependencies, source file names and object file names
-HEADERS=$(foreach name,bipgraph graph index var factor varset smallset prob daialg properties alldai enum exceptions util,$(INC)/$(name).h)
+HEADERS=$(foreach name,graph dag bipgraph index var factor varset smallset prob daialg properties alldai enum exceptions util,$(INC)/$(name).h)
 SOURCES:=$(foreach name,$(NAMES),$(SRC)/$(name).cpp)
 OBJECTS:=$(foreach name,$(NAMES),$(name)$(OE))
 
@@ -119,35 +120,37 @@ MEX:=$(MEX) $(MEXINC) $(MEXFLAGS) $(WITHFLAGS) $(MEXLIB)
 ###############
 
 all : $(TARGETS)
+       @echo libDAI built successfully!
 
-examples : examples/example$(EE) examples/example_bipgraph$(EE) examples/example_varset$(EE) examples/example_permute$(EE) examples/example_sprinkler$(EE) examples/example_sprinkler_gibbs$(EE) examples/example_sprinkler_em$(EE)
+examples : examples/example$(EE) examples/example_bipgraph$(EE) examples/example_varset$(EE) examples/example_permute$(EE) examples/example_sprinkler$(EE) examples/example_sprinkler_gibbs$(EE) examples/example_sprinkler_em$(EE) examples/example_imagesegmentation$(EE)
 
 matlabs : matlab/dai$(ME) matlab/dai_readfg$(ME) matlab/dai_writefg$(ME) matlab/dai_potstrength$(ME)
 
-unittests : tests/unit/var$(EE) tests/unit/smallset$(EE) tests/unit/varset$(EE) tests/unit/graph$(EE) tests/unit/bipgraph$(EE) tests/unit/weightedgraph$(EE) tests/unit/enum$(EE) tests/unit/enum$(EE) tests/unit/util$(EE) tests/unit/exceptions$(EE) tests/unit/properties$(EE) tests/unit/index$(EE) tests/unit/prob$(EE) tests/unit/factor$(EE) tests/unit/factorgraph$(EE) tests/unit/clustergraph$(EE) tests/unit/regiongraph$(EE) tests/unit/daialg$(EE) tests/unit/alldai$(EE)
+unittests : tests/unit/var_test$(EE) tests/unit/smallset_test$(EE) tests/unit/varset_test$(EE) tests/unit/graph_test$(EE) tests/unit/dag_test$(EE) tests/unit/bipgraph_test$(EE) tests/unit/weightedgraph_test$(EE) tests/unit/enum_test$(EE) tests/unit/enum_test$(EE) tests/unit/util_test$(EE) tests/unit/exceptions_test$(EE) tests/unit/properties_test$(EE) tests/unit/index_test$(EE) tests/unit/prob_test$(EE) tests/unit/factor_test$(EE) tests/unit/factorgraph_test$(EE) tests/unit/clustergraph_test$(EE) tests/unit/regiongraph_test$(EE) tests/unit/daialg_test$(EE) tests/unit/alldai_test$(EE)
        echo Running unit tests...
-       tests/unit/var$(EE)
-       tests/unit/smallset$(EE)
-       tests/unit/varset$(EE)
-       tests/unit/graph$(EE)
-       tests/unit/bipgraph$(EE)
-       tests/unit/weightedgraph$(EE)
-       tests/unit/enum$(EE)
-       tests/unit/util$(EE)
-       tests/unit/exceptions$(EE)
-       tests/unit/properties$(EE)
-       tests/unit/index$(EE)
-       tests/unit/prob$(EE)
-       tests/unit/factor$(EE)
-       tests/unit/factorgraph$(EE)
-       tests/unit/clustergraph$(EE)
-       tests/unit/regiongraph$(EE)
-       tests/unit/daialg$(EE)
-       tests/unit/alldai$(EE)
+       tests/unit/var_test$(EE)
+       tests/unit/smallset_test$(EE)
+       tests/unit/varset_test$(EE)
+       tests/unit/graph_test$(EE)
+       tests/unit/dag_test$(EE)
+       tests/unit/bipgraph_test$(EE)
+       tests/unit/weightedgraph_test$(EE)
+       tests/unit/enum_test$(EE)
+       tests/unit/util_test$(EE)
+       tests/unit/exceptions_test$(EE)
+       tests/unit/properties_test$(EE)
+       tests/unit/index_test$(EE)
+       tests/unit/prob_test$(EE)
+       tests/unit/factor_test$(EE)
+       tests/unit/factorgraph_test$(EE)
+       tests/unit/clustergraph_test$(EE)
+       tests/unit/regiongraph_test$(EE)
+       tests/unit/daialg_test$(EE)
+       tests/unit/alldai_test$(EE)
 
 tests : tests/testdai$(EE) tests/testem/testem$(EE) tests/testbbp$(EE) $(unittests)
 
-utils : utils/createfg$(EE) utils/fg2dot$(EE) utils/fginfo$(EE)
+utils : utils/createfg$(EE) utils/fg2dot$(EE) utils/fginfo$(EE) utils/uai2fg$(EE)
 
 lib: $(LIB)/libdai$(LE)
 
@@ -176,6 +179,9 @@ treeep$(OE) : $(SRC)/treeep.cpp $(INC)/treeep.h $(HEADERS) $(INC)/weightedgraph.
 emalg$(OE) : $(SRC)/emalg.cpp $(INC)/emalg.h $(INC)/evidence.h $(HEADERS)
        $(CC) -c $<
 
+decmap$(OE) : $(SRC)/decmap.cpp $(INC)/decmap.h $(HEADERS)
+       $(CC) -c $<
+
 
 # EXAMPLES
 ###########
@@ -183,12 +189,26 @@ emalg$(OE) : $(SRC)/emalg.cpp $(INC)/emalg.h $(INC)/evidence.h $(HEADERS)
 examples/%$(EE) : examples/%.cpp $(HEADERS) $(LIB)/libdai$(LE)
        $(CC) $(CCO)$@ $< $(LIBS)
 
+examples/example_sprinkler_gibbs$(EE) : examples/example_sprinkler_gibbs.cpp $(HEADERS) $(LIB)/libdai$(LE)
+ifdef WITH_GIBBS
+       $(CC) $(CCO)$@ $< $(LIBS)
+else
+       @echo Skipping $@
+endif
+
+examples/example_imagesegmentation$(EE) : examples/example_imagesegmentation.cpp $(HEADERS) $(LIB)/libdai$(LE)
+       -$(CC) $(CIMGINC) $(CCO)$@ $< $(LIBS) $(CIMGLIBS)
+
 
 # UNIT TESTS
 #############
 
 tests/unit/%$(EE) : tests/unit/%.cpp $(HEADERS) $(LIB)/libdai$(LE)
-       $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_UTF)
+ifneq ($(OS),WINDOWS)
+       $(CC) -DBOOST_TEST_DYN_LINK $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_UTF)
+else
+       $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_UTF) /SUBSYSTEM:CONSOLE
+endif
 
 
 # TESTS
@@ -198,9 +218,11 @@ tests/testdai$(EE) : tests/testdai.cpp $(HEADERS) $(LIB)/libdai$(LE)
        $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_PO)
 tests/testem/testem$(EE) : tests/testem/testem.cpp $(HEADERS) $(LIB)/libdai$(LE)
        $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_PO)
-ifdef WITH_CBP
 tests/testbbp$(EE) : tests/testbbp.cpp $(HEADERS) $(LIB)/libdai$(LE)
+ifdef WITH_CBP
        $(CC) $(CCO)$@ $< $(LIBS)
+else
+       @echo Skipping $@
 endif
 
 
@@ -232,6 +254,9 @@ utils/fg2dot$(EE) : utils/fg2dot.cpp $(HEADERS) $(LIB)/libdai$(LE)
 utils/fginfo$(EE) : utils/fginfo.cpp $(HEADERS) $(LIB)/libdai$(LE)
        $(CC) $(CCO)$@ $< $(LIBS)
 
+utils/uai2fg$(EE) : utils/uai2fg.cpp $(HEADERS) $(LIB)/libdai$(LE)
+       $(CC) $(CCO)$@ $< $(LIBS)
+
 
 # LIBRARY
 ##########
@@ -289,11 +314,11 @@ ifneq ($(OS),WINDOWS)
 clean :
        -rm $(OBJECTS)
        -rm matlab/*$(ME)
-       -rm examples/example$(EE) examples/example_bipgraph$(EE) examples/example_varset$(EE) examples/example_permute$(EE) examples/example_sprinkler$(EE) examples/example_sprinkler_gibbs$(EE) examples/example_sprinkler_em$(EE)
+       -rm examples/example$(EE) examples/example_bipgraph$(EE) examples/example_varset$(EE) examples/example_permute$(EE) examples/example_sprinkler$(EE) examples/example_sprinkler_gibbs$(EE) examples/example_sprinkler_em$(EE) examples/example_imagesegmentation$(EE)
        -rm tests/testdai$(EE) tests/testem/testem$(EE) tests/testbbp$(EE)
-       -rm tests/unit/var$(EE) tests/unit/smallset$(EE) tests/unit/varset$(EE) tests/unit/graph$(EE) tests/unit/bipgraph$(EE) tests/unit/weightedgraph$(EE) tests/unit/enum$(EE) tests/unit/util$(EE) tests/unit/exceptions$(EE) tests/unit/properties$(EE) tests/unit/index$(EE) tests/unit/prob$(EE) tests/unit/factor$(EE) tests/unit/factorgraph$(EE) tests/unit/clustergraph$(EE) tests/unit/regiongraph$(EE) tests/unit/daialg$(EE) tests/unit/alldai$(EE)
+       -rm tests/unit/var_test$(EE) tests/unit/smallset_test$(EE) tests/unit/varset_test$(EE) tests/unit/graph_test$(EE) tests/unit/dag_test$(EE) tests/unit/bipgraph_test$(EE) tests/unit/weightedgraph_test$(EE) tests/unit/enum_test$(EE) tests/unit/util_test$(EE) tests/unit/exceptions_test$(EE) tests/unit/properties_test$(EE) tests/unit/index_test$(EE) tests/unit/prob_test$(EE) tests/unit/factor_test$(EE) tests/unit/factorgraph_test$(EE) tests/unit/clustergraph_test$(EE) tests/unit/regiongraph_test$(EE) tests/unit/daialg_test$(EE) tests/unit/alldai_test$(EE)
        -rm factorgraph_test.fg alldai_test.aliases
-       -rm utils/fg2dot$(EE) utils/createfg$(EE) utils/fginfo$(EE)
+       -rm utils/fg2dot$(EE) utils/createfg$(EE) utils/fginfo$(EE) utils/uai2fg$(EE)
        -rm -R doc
        -rm -R lib
 else
@@ -306,40 +331,22 @@ clean :
        -del examples\*$(EE).manifest
        -del examples\*.ilk
        -del examples\*.pdb
-       -del tests\testdai$(EE)
-       -del tests\testbbp$(EE)
-       -del tests\testdai$(EE).manifest
-       -del tests\testbbp$(EE).manifest
-       -del tests\testem\testem$(EE)
-       -del tests\testem\testem$(EE).manifest
+       -del tests\*$(EE)
+       -del tests\*$(EE).manifest
        -del tests\*.pdb
        -del tests\*.ilk
+       -del tests\testem\*$(EE)
+       -del tests\testem\*$(EE).manifest
        -del tests\testem\*.pdb
        -del tests\testem\*.ilk
        -del utils\*$(EE)
        -del utils\*$(EE).manifest
        -del utils\*.pdb
        -del utils\*.ilk
-       -del tests\unit\*.ilk
-       -del tests\unit\*.pdb
-       -del tests\unit\var$(EE)
-       -del tests\unit\smallset$(EE)
-       -del tests\unit\varset$(EE)
-       -del tests\unit\graph$(EE)
-       -del tests\unit\bipgraph$(EE)
-       -del tests\unit\weightedgraph$(EE)
-       -del tests\unit\enum$(EE)
-       -del tests\unit\util$(EE)
-       -del tests\unit\exceptions$(EE)
-       -del tests\unit\properties$(EE)
-       -del tests\unit\index$(EE)
-       -del tests\unit\prob$(EE)
-       -del tests\unit\factor$(EE)
-       -del tests\unit\factorgraph$(EE)
-       -del tests\unit\clustergraph$(EE)
-       -del tests\unit\regiongraph$(EE)
-       -del tests\unit\daialg$(EE)
-       -del tests\unit\alldai$(EE)
+       -del tests\unit\*_test$(EE)
+       -del tests\unit\*_test$(EE).manifest
+       -del tests\unit\*_test.pdb
+       -del tests\unit\*_test.ilk
        -del factorgraph_test.fg
        -del alldai_test.aliases
        -del $(LIB)\libdai$(LE)