1 # This file is part of libDAI - http://www.libdai.org/
3 # Copyright (c) 2006-2011, The libDAI authors. All rights reserved.
5 # Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
8 # Load the platform independent build configuration file
11 # Load the local configuration from Makefile.conf
14 # Set version and date
15 DAI_VERSION
="git HEAD"
16 DAI_DATE
="September 17, 2012 - or later"
18 # Directories of libDAI sources
19 # Location of libDAI headers
21 # Location of libDAI source files
23 # Destination directory of libDAI library
26 # Set final compiler flags
28 CCFLAGS
:=$(CCFLAGS
) $(CCDEBUGFLAGS
)
30 CCFLAGS
:=$(CCFLAGS
) $(CCNODEBUGFLAGS
)
33 # Define build targets
34 TARGETS
:=lib tests utils examples
36 TARGETS
:=$(TARGETS
) matlabs
38 TARGETS
:=$(TARGETS
) unittests testregression testem
40 TARGETS
:=$(TARGETS
) doc
43 # Define conditional build targets
44 NAMES
:=graph dag bipgraph varset daialg alldai clustergraph factor factorgraph properties regiongraph cobwebgraph util weightedgraph exceptions exactinf evidence emalg io
46 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_BP
50 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_FBP
54 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_TRWBP
58 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_MF
62 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_HAK
66 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_LC
70 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_TREEEP
71 NAMES
:=$(NAMES
) treeep
74 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_JTREE
78 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_MR
82 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_GIBBS
86 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_CBP
87 NAMES
:=$(NAMES
) bbp cbp bp_dual
90 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_DECMAP
91 NAMES
:=$(NAMES
) decmap
94 WITHFLAGS
:=$(WITHFLAGS
) -DDAI_WITH_GLC
99 # Define standard libDAI header dependencies, source file names and object file names
100 HEADERS
=$(foreach name
,graph dag bipgraph index var factor varset smallset prob daialg properties alldai enum exceptions util
,$(INC
)/$(name
).h
)
101 SOURCES
:=$(foreach name
,$(NAMES
),$(SRC
)/$(name
).
cpp)
102 OBJECTS
:=$(foreach name
,$(NAMES
),$(name
)$(OE
))
104 # Setup final command for C++ compiler
105 ifneq ($(OS
),WINDOWS
)
106 CC
:=$(CC
) $(CCINC
) $(CCFLAGS
) $(WITHFLAGS
) $(CCLIB
)
108 CC
:=$(CC
) $(CCINC
) $(CCFLAGS
) $(WITHFLAGS
)
109 LIBS
:=$(LIBS
) $(CCLIB
)
112 # Setup final command for MEX
114 MEXFLAGS
:=$(MEXFLAGS
) -largeArrayDims
116 MEXFLAGS
:=$(MEXFLAGS
) -DSMALLMEM
118 MEX
:=$(MEX
) $(MEXINC
) $(MEXFLAGS
) $(WITHFLAGS
) $(MEXLIBS
) $(MEXLIB
)
126 @echo libDAI built successfully
!
128 EXAMPLES
=$(foreach name
,example example_bipgraph example_varset example_permute example_sprinkler example_sprinkler_em
,examples
/$(name
)$(EE
))
130 EXAMPLES
:=$(EXAMPLES
) examples
/example_sprinkler_gibbs
$(EE
)
133 EXAMPLES
:=$(EXAMPLES
) examples
/example_imagesegmentation
$(EE
)
135 examples
: $(EXAMPLES
)
137 matlabs
: matlab
/dai
$(ME
) matlab
/dai_readfg
$(ME
) matlab
/dai_writefg
$(ME
) matlab
/dai_potstrength
$(ME
) matlab
/dai_jtree
$(ME
)
139 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
)
140 @echo
'Running unit tests...'
142 tests
/unit
/var_test
$(EE
)
143 tests
/unit
/smallset_test
$(EE
)
144 tests
/unit
/varset_test
$(EE
)
145 tests
/unit
/graph_test
$(EE
)
146 tests
/unit
/dag_test
$(EE
)
147 tests
/unit
/bipgraph_test
$(EE
)
148 tests
/unit
/weightedgraph_test
$(EE
)
149 tests
/unit
/enum_test
$(EE
)
150 tests
/unit
/util_test
$(EE
)
151 tests
/unit
/exceptions_test
$(EE
)
152 tests
/unit
/properties_test
$(EE
)
153 tests
/unit
/index_test
$(EE
)
154 tests
/unit
/prob_test
$(EE
)
155 tests
/unit
/factor_test
$(EE
)
156 tests
/unit
/factorgraph_test
$(EE
)
157 tests
/unit
/clustergraph_test
$(EE
)
158 tests
/unit
/regiongraph_test
$(EE
)
159 tests
/unit
/daialg_test
$(EE
)
160 tests
/unit
/alldai_test
$(EE
)
162 @echo
'All unit tests completed successfully!'
165 tests
: tests
/testdai
$(EE
) tests
/testem
/testem
$(EE
) tests
/testbbp
$(EE
) $(unittests
)
167 utils
: utils
/createfg
$(EE
) utils
/fg2dot
$(EE
) utils
/fginfo
$(EE
) utils
/uai2fg
$(EE
)
169 lib
: $(LIB
)/libdai
$(LE
)
175 %$(OE
) : $(SRC
)/%.
cpp $(INC
)/%.h
$(HEADERS
)
178 bbp
$(OE
) : $(SRC
)/bbp.
cpp $(INC
)/bbp.h
$(INC
)/bp_dual.h
$(HEADERS
)
181 cbp
$(OE
) : $(SRC
)/cbp.
cpp $(INC
)/cbp.h
$(INC
)/bbp.h
$(INC
)/bp_dual.h
$(HEADERS
)
184 hak
$(OE
) : $(SRC
)/hak.
cpp $(INC
)/hak.h
$(HEADERS
) $(INC
)/regiongraph.h
187 jtree
$(OE
) : $(SRC
)/jtree.
cpp $(INC
)/jtree.h
$(HEADERS
) $(INC
)/weightedgraph.h
$(INC
)/clustergraph.h
$(INC
)/regiongraph.h
190 treeep
$(OE
) : $(SRC
)/treeep.
cpp $(INC
)/treeep.h
$(HEADERS
) $(INC
)/weightedgraph.h
$(INC
)/clustergraph.h
$(INC
)/regiongraph.h
$(INC
)/jtree.h
193 emalg
$(OE
) : $(SRC
)/emalg.
cpp $(INC
)/emalg.h
$(INC
)/evidence.h
$(HEADERS
)
196 decmap
$(OE
) : $(SRC
)/decmap.
cpp $(INC
)/decmap.h
$(HEADERS
)
199 glc
$(OE
) : $(SRC
)/glc.
cpp $(INC
)/glc.h
$(HEADERS
) $(INC
)/cobwebgraph.h
206 examples
/%$(EE
) : examples
/%.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
207 $(CC
) $(CCO
)$@
$< $(LIBS
)
209 examples
/example_sprinkler_gibbs
$(EE
) : examples
/example_sprinkler_gibbs.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
210 $(CC
) $(CCO
)$@
$< $(LIBS
)
212 examples
/example_imagesegmentation
$(EE
) : examples
/example_imagesegmentation.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
214 $(CC
) -DNEW_CIMG
$(CIMGINC
) $(CCO
)$@
$< $(LIBS
) $(CIMGLIBS
)
216 $(CC
) $(CIMGINC
) $(CCO
)$@
$< $(LIBS
) $(CIMGLIBS
)
223 tests
/unit
/%$(EE
) : tests
/unit
/%.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
224 ifneq ($(OS
),WINDOWS
)
225 $(CC
) -DBOOST_TEST_DYN_LINK
$(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_UTF
)
227 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_UTF
) /SUBSYSTEM
:CONSOLE
234 tests
/testdai
$(EE
) : tests
/testdai.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
235 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
236 tests
/testem
/testem
$(EE
) : tests
/testem
/testem.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
237 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
238 tests
/testbbp
$(EE
) : tests
/testbbp.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
240 $(CC
) $(CCO
)$@
$< $(LIBS
)
249 matlab
/dai
$(ME
) : $(SRC
)/matlab
/dai.
cpp $(HEADERS
) $(SOURCES
) $(SRC
)/matlab
/matlab.
cpp
250 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SOURCES
)
252 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
253 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
255 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
256 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
258 matlab
/dai_potstrength
$(ME
) : $(SRC
)/matlab
/dai_potstrength.
cpp $(HEADERS
) $(SRC
)/matlab
/matlab.
cpp $(SRC
)/exceptions.
cpp
259 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/exceptions.
cpp
261 matlab
/dai_jtree
$(ME
) : $(SRC
)/matlab
/dai_jtree.
cpp $(HEADERS
) $(SOURCES
) $(SRC
)/matlab
/matlab.
cpp
262 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SOURCES
)
268 utils
/createfg
$(EE
) : utils
/createfg.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
269 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
271 utils
/fg2dot
$(EE
) : utils
/fg2dot.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
272 $(CC
) $(CCO
)$@
$< $(LIBS
)
274 utils
/fginfo
$(EE
) : utils
/fginfo.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
275 $(CC
) $(CCO
)$@
$< $(LIBS
)
277 utils
/uai2fg
$(EE
) : utils
/uai2fg.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
278 $(CC
) $(CCO
)$@
$< $(LIBS
)
284 ifneq ($(OS
),WINDOWS
)
285 $(LIB
)/libdai
$(LE
) : $(OBJECTS
)
287 ar rcus
$(LIB
)/libdai
$(LE
) $(OBJECTS
)
289 $(LIB
)/libdai
$(LE
) : $(OBJECTS
)
291 lib
/out
:$(LIB
)/libdai
$(LE
) $(OBJECTS
)
298 testregression
: tests
/testdai
$(EE
)
299 @echo Starting regression
test...this can take a minute or so
!
300 ifneq ($(OS
),WINDOWS
)
301 cd tests
&& .
/testregression
&& cd ..
303 cd tests
&& testregression.bat
&& cd ..
306 testem
: tests
/testem
/testem
$(EE
)
307 @echo Starting EM tests
308 ifneq ($(OS
),WINDOWS
)
309 cd tests
/testem
&& .
/runtests
&& cd ..
/..
311 cd tests
\testem
&& runtests
&& cd ..\..
318 doc
: $(INC
)/*.h
$(SRC
)/*.
cpp examples
/*.
cpp doxygen.conf
321 README
: doc scripts
/makeREADME Makefile
322 DAI_VERSION
=$(DAI_VERSION
) DAI_DATE
=$(DAI_DATE
) scripts
/makeREADME
325 etags src
/*.
cpp include/dai
/*.h tests
/*.
cpp utils
/*.
cpp
326 ctags src
/*.
cpp include/dai
/*.h tests
/*.
cpp utils
/*.
cpp
333 ifneq ($(OS
),WINDOWS
)
337 -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
)
338 -rm tests
/testdai
$(EE
) tests
/testem
/testem
$(EE
) tests
/testbbp
$(EE
)
339 -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
)
340 -rm factorgraph_test.fg alldai_test.aliases
341 -rm utils
/fg2dot
$(EE
) utils
/createfg
$(EE
) utils
/fginfo
$(EE
) utils
/uai2fg
$(EE
)
351 -del examples\
*$(EE
).manifest
355 -del tests\
*$(EE
).manifest
358 -del tests
\testem\
*$(EE
)
359 -del tests
\testem\
*$(EE
).manifest
360 -del tests
\testem\
*.pdb
361 -del tests
\testem\
*.ilk
363 -del utils\
*$(EE
).manifest
366 -del tests\unit\
*_test
$(EE
)
367 -del tests\unit\
*_test
$(EE
).manifest
368 -del tests\unit\
*_test.pdb
369 -del tests\unit\
*_test.ilk
370 -del factorgraph_test.fg
371 -del alldai_test.aliases
372 -del
$(LIB
)\libdai
$(LE
)