1 # This file is part of libDAI - http://www.libdai.org/
3 # libDAI is licensed under the terms of the GNU General Public License version
4 # 2, or (at your option) any later version. libDAI is distributed without any
5 # warranty. See the file COPYING for more details.
7 # Copyright (C) 2006-2010 Joris Mooij [joris dot mooij at libdai dot org]
8 # Copyright (C) 2006-2007 Radboud University Nijmegen, The Netherlands
11 # Load the platform independent build configuration file
14 # Load the local configuration from Makefile.conf
17 # Set version and date
19 DAI_DATE
="August 19, 2010"
21 # Directories of libDAI sources
22 # Location of libDAI headers
24 # Location of libDAI source files
26 # Destination directory of libDAI library
29 # Set final compiler flags
31 CCFLAGS
:=$(CCFLAGS
) $(CCDEBUGFLAGS
)
33 CCFLAGS
:=$(CCFLAGS
) $(CCNODEBUGFLAGS
)
36 # Define build targets
37 TARGETS
:=lib tests utils examples
39 TARGETS
:=$(TARGETS
) matlabs
41 TARGETS
:=$(TARGETS
) unittests testregression testem
43 TARGETS
:=$(TARGETS
) doc
46 # Define conditional build targets
47 NAMES
:=graph dag bipgraph varset daialg alldai clustergraph factor factorgraph properties regiongraph util weightedgraph exceptions exactinf evidence emalg io
49 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_BP
53 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_FBP
57 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_TRWBP
61 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_MF
65 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_HAK
69 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_LC
73 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_TREEEP
74 NAMES
:=$(NAMES
) treeep
77 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_JTREE
81 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_MR
85 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_GIBBS
89 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_CBP
90 NAMES
:=$(NAMES
) bbp cbp bp_dual
93 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_DECMAP
94 NAMES
:=$(NAMES
) decmap
97 # Define standard libDAI header dependencies, source file names and object file names
98 HEADERS
=$(foreach name
,graph dag bipgraph index var factor varset smallset prob daialg properties alldai enum exceptions util
,$(INC
)/$(name
).h
)
99 SOURCES
:=$(foreach name
,$(NAMES
),$(SRC
)/$(name
).
cpp)
100 OBJECTS
:=$(foreach name
,$(NAMES
),$(name
)$(OE
))
102 # Setup final command for C++ compiler
103 ifneq ($(OS
),WINDOWS
)
104 CC
:=$(CC
) $(CCINC
) $(CCFLAGS
) $(WITHFLAGS
) $(CCLIB
)
106 CC
:=$(CC
) $(CCINC
) $(CCFLAGS
) $(WITHFLAGS
)
107 LIBS
:=$(LIBS
) $(CCLIB
)
110 # Setup final command for MEX
112 MEXFLAGS
:=$(MEXFLAGS
) -largeArrayDims
114 MEXFLAGS
:=$(MEXFLAGS
) -DSMALLMEM
116 MEX
:=$(MEX
) $(MEXINC
) $(MEXFLAGS
) $(WITHFLAGS
) $(MEXLIB
)
124 @echo libDAI built successfully
!
126 EXAMPLES
=$(foreach name
,example example_bipgraph example_varset example_permute example_sprinkler example_sprinkler_em
,examples
/$(name
)$(EE
))
128 EXAMPLES
:=$(EXAMPLES
) examples
/example_sprinkler_gibbs
$(EE
)
131 EXAMPLES
:=$(EXAMPLES
) examples
/example_imagesegmentation
$(EE
)
133 examples
: $(EXAMPLES
)
135 matlabs
: matlab
/dai
$(ME
) matlab
/dai_readfg
$(ME
) matlab
/dai_writefg
$(ME
) matlab
/dai_potstrength
$(ME
)
137 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
)
138 @echo
'Running unit tests...(note: output containing "EXCEPTION" does not indicate an error)'
140 tests
/unit
/var_test
$(EE
)
141 tests
/unit
/smallset_test
$(EE
)
142 tests
/unit
/varset_test
$(EE
)
143 tests
/unit
/graph_test
$(EE
)
144 tests
/unit
/dag_test
$(EE
)
145 tests
/unit
/bipgraph_test
$(EE
)
146 tests
/unit
/weightedgraph_test
$(EE
)
147 tests
/unit
/enum_test
$(EE
)
148 tests
/unit
/util_test
$(EE
)
149 tests
/unit
/exceptions_test
$(EE
)
150 tests
/unit
/properties_test
$(EE
)
151 tests
/unit
/index_test
$(EE
)
152 tests
/unit
/prob_test
$(EE
)
153 tests
/unit
/factor_test
$(EE
)
154 tests
/unit
/factorgraph_test
$(EE
)
155 tests
/unit
/clustergraph_test
$(EE
)
156 tests
/unit
/regiongraph_test
$(EE
)
157 tests
/unit
/daialg_test
$(EE
)
158 tests
/unit
/alldai_test
$(EE
)
160 @echo
'All unit tests completed successfully!'
163 tests
: tests
/testdai
$(EE
) tests
/testem
/testem
$(EE
) tests
/testbbp
$(EE
) $(unittests
)
165 utils
: utils
/createfg
$(EE
) utils
/fg2dot
$(EE
) utils
/fginfo
$(EE
) utils
/uai2fg
$(EE
)
167 lib
: $(LIB
)/libdai
$(LE
)
173 %$(OE
) : $(SRC
)/%.
cpp $(INC
)/%.h
$(HEADERS
)
176 bbp
$(OE
) : $(SRC
)/bbp.
cpp $(INC
)/bbp.h
$(INC
)/bp_dual.h
$(HEADERS
)
179 cbp
$(OE
) : $(SRC
)/cbp.
cpp $(INC
)/cbp.h
$(INC
)/bbp.h
$(INC
)/bp_dual.h
$(HEADERS
)
182 hak
$(OE
) : $(SRC
)/hak.
cpp $(INC
)/hak.h
$(HEADERS
) $(INC
)/regiongraph.h
185 jtree
$(OE
) : $(SRC
)/jtree.
cpp $(INC
)/jtree.h
$(HEADERS
) $(INC
)/weightedgraph.h
$(INC
)/clustergraph.h
$(INC
)/regiongraph.h
188 treeep
$(OE
) : $(SRC
)/treeep.
cpp $(INC
)/treeep.h
$(HEADERS
) $(INC
)/weightedgraph.h
$(INC
)/clustergraph.h
$(INC
)/regiongraph.h
$(INC
)/jtree.h
191 emalg
$(OE
) : $(SRC
)/emalg.
cpp $(INC
)/emalg.h
$(INC
)/evidence.h
$(HEADERS
)
194 decmap
$(OE
) : $(SRC
)/decmap.
cpp $(INC
)/decmap.h
$(HEADERS
)
201 examples
/%$(EE
) : examples
/%.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
202 $(CC
) $(CCO
)$@
$< $(LIBS
)
204 examples
/example_sprinkler_gibbs
$(EE
) : examples
/example_sprinkler_gibbs.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
205 $(CC
) $(CCO
)$@
$< $(LIBS
)
207 examples
/example_imagesegmentation
$(EE
) : examples
/example_imagesegmentation.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
209 $(CC
) -DNEW_CIMG
$(CIMGINC
) $(CCO
)$@
$< $(LIBS
) $(CIMGLIBS
)
211 $(CC
) $(CIMGINC
) $(CCO
)$@
$< $(LIBS
) $(CIMGLIBS
)
218 tests
/unit
/%$(EE
) : tests
/unit
/%.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
219 ifneq ($(OS
),WINDOWS
)
220 $(CC
) -DBOOST_TEST_DYN_LINK
$(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_UTF
)
222 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_UTF
) /SUBSYSTEM
:CONSOLE
229 tests
/testdai
$(EE
) : tests
/testdai.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
230 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
231 tests
/testem
/testem
$(EE
) : tests
/testem
/testem.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
232 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
233 tests
/testbbp
$(EE
) : tests
/testbbp.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
235 $(CC
) $(CCO
)$@
$< $(LIBS
)
244 matlab
/dai
$(ME
) : $(SRC
)/matlab
/dai.
cpp $(HEADERS
) $(SOURCES
) $(SRC
)/matlab
/matlab.
cpp
245 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SOURCES
)
247 matlab
/dai_readfg
$(ME
) : $(SRC
)/matlab
/dai_readfg.
cpp $(HEADERS
) $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
248 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
250 matlab
/dai_writefg
$(ME
) : $(SRC
)/matlab
/dai_writefg.
cpp $(HEADERS
) $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
251 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
253 matlab
/dai_potstrength
$(ME
) : $(SRC
)/matlab
/dai_potstrength.
cpp $(HEADERS
) $(SRC
)/matlab
/matlab.
cpp $(SRC
)/exceptions.
cpp
254 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/exceptions.
cpp
260 utils
/createfg
$(EE
) : utils
/createfg.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
261 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
263 utils
/fg2dot
$(EE
) : utils
/fg2dot.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
264 $(CC
) $(CCO
)$@
$< $(LIBS
)
266 utils
/fginfo
$(EE
) : utils
/fginfo.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
267 $(CC
) $(CCO
)$@
$< $(LIBS
)
269 utils
/uai2fg
$(EE
) : utils
/uai2fg.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
270 $(CC
) $(CCO
)$@
$< $(LIBS
)
276 ifneq ($(OS
),WINDOWS
)
277 $(LIB
)/libdai
$(LE
) : $(OBJECTS
)
279 ar rcus
$(LIB
)/libdai
$(LE
) $(OBJECTS
)
281 $(LIB
)/libdai
$(LE
) : $(OBJECTS
)
283 lib
/out
:$(LIB
)/libdai
$(LE
) $(OBJECTS
)
290 testregression
: tests
/testdai
$(EE
)
291 @echo Starting regression
test...this can take a minute or so
!
292 ifneq ($(OS
),WINDOWS
)
293 cd tests
&& .
/testregression
&& cd ..
295 cd tests
&& testregression.bat
&& cd ..
298 testem
: tests
/testem
/testem
$(EE
)
299 @echo Starting EM tests
300 ifneq ($(OS
),WINDOWS
)
301 cd tests
/testem
&& .
/runtests
&& cd ..
/..
303 cd tests
\testem
&& runtests
&& cd ..\..
310 doc
: $(INC
)/*.h
$(SRC
)/*.
cpp examples
/*.
cpp doxygen.conf
313 README
: doc scripts
/makeREADME
314 DAI_VERSION
=$(DAI_VERSION
) DAI_DATE
=$(DAI_DATE
) scripts
/makeREADME
317 etags src
/*.
cpp include/dai
/*.h tests
/*.
cpp utils
/*.
cpp
318 ctags src
/*.
cpp include/dai
/*.h tests
/*.
cpp utils
/*.
cpp
325 ifneq ($(OS
),WINDOWS
)
329 -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
)
330 -rm tests
/testdai
$(EE
) tests
/testem
/testem
$(EE
) tests
/testbbp
$(EE
)
331 -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
)
332 -rm factorgraph_test.fg alldai_test.aliases
333 -rm utils
/fg2dot
$(EE
) utils
/createfg
$(EE
) utils
/fginfo
$(EE
) utils
/uai2fg
$(EE
)
343 -del examples\
*$(EE
).manifest
347 -del tests\
*$(EE
).manifest
350 -del tests
\testem\
*$(EE
)
351 -del tests
\testem\
*$(EE
).manifest
352 -del tests
\testem\
*.pdb
353 -del tests
\testem\
*.ilk
355 -del utils\
*$(EE
).manifest
358 -del tests\unit\
*_test
$(EE
)
359 -del tests\unit\
*_test
$(EE
).manifest
360 -del tests\unit\
*_test.pdb
361 -del tests\unit\
*_test.ilk
362 -del factorgraph_test.fg
363 -del alldai_test.aliases
364 -del
$(LIB
)\libdai
$(LE
)