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
45 NAMES
:=$(NAMES
) bp fbp trwbp mf hak lc treeep jtree mr gibbs bbp cbp bp_dual decmap glc
48 # Define standard libDAI header dependencies, source file names and object file names
49 HEADERS
=$(foreach name
,graph dag bipgraph index var factor varset smallset prob daialg properties alldai enum exceptions util
,$(INC
)/$(name
).h
)
50 SOURCES
:=$(foreach name
,$(NAMES
),$(SRC
)/$(name
).
cpp)
51 OBJECTS
:=$(foreach name
,$(NAMES
),$(name
)$(OE
))
53 # Setup final command for C++ compiler
55 CC
:=$(CC
) $(CCINC
) $(CCFLAGS
) $(WITHFLAGS
) $(CCLIB
)
57 CC
:=$(CC
) $(CCINC
) $(CCFLAGS
) $(WITHFLAGS
)
58 LIBS
:=$(LIBS
) $(CCLIB
)
61 # Setup final command for MEX
63 MEXFLAGS
:=$(MEXFLAGS
) -largeArrayDims
65 MEXFLAGS
:=$(MEXFLAGS
) -DSMALLMEM
67 MEX
:=$(MEX
) $(MEXINC
) $(MEXFLAGS
) $(WITHFLAGS
) $(MEXLIBS
) $(MEXLIB
)
75 @echo libDAI built successfully
!
77 EXAMPLES
=$(foreach name
,example example_bipgraph example_varset example_permute example_sprinkler example_sprinkler_em
,examples
/$(name
)$(EE
))
78 EXAMPLES
:=$(EXAMPLES
) examples
/example_sprinkler_gibbs
$(EE
)
80 EXAMPLES
:=$(EXAMPLES
) examples
/example_imagesegmentation
$(EE
)
82 examples
: $(EXAMPLES
)
84 matlabs
: matlab
/dai
$(ME
) matlab
/dai_readfg
$(ME
) matlab
/dai_writefg
$(ME
) matlab
/dai_potstrength
$(ME
) matlab
/dai_jtree
$(ME
)
86 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
)
87 @echo
'Running unit tests...'
89 tests
/unit
/var_test
$(EE
)
90 tests
/unit
/smallset_test
$(EE
)
91 tests
/unit
/varset_test
$(EE
)
92 tests
/unit
/graph_test
$(EE
)
93 tests
/unit
/dag_test
$(EE
)
94 tests
/unit
/bipgraph_test
$(EE
)
95 tests
/unit
/weightedgraph_test
$(EE
)
96 tests
/unit
/enum_test
$(EE
)
97 tests
/unit
/util_test
$(EE
)
98 tests
/unit
/exceptions_test
$(EE
)
99 tests
/unit
/properties_test
$(EE
)
100 tests
/unit
/index_test
$(EE
)
101 tests
/unit
/prob_test
$(EE
)
102 tests
/unit
/factor_test
$(EE
)
103 tests
/unit
/factorgraph_test
$(EE
)
104 tests
/unit
/clustergraph_test
$(EE
)
105 tests
/unit
/regiongraph_test
$(EE
)
106 tests
/unit
/daialg_test
$(EE
)
107 tests
/unit
/alldai_test
$(EE
)
109 @echo
'All unit tests completed successfully!'
112 tests
: tests
/testdai
$(EE
) tests
/testem
/testem
$(EE
) tests
/testbbp
$(EE
) $(unittests
)
114 utils
: utils
/createfg
$(EE
) utils
/fg2dot
$(EE
) utils
/fginfo
$(EE
) utils
/uai2fg
$(EE
)
116 lib
: $(LIB
)/libdai
$(LE
)
122 %$(OE
) : $(SRC
)/%.
cpp $(INC
)/%.h
$(HEADERS
)
125 bbp
$(OE
) : $(SRC
)/bbp.
cpp $(INC
)/bbp.h
$(INC
)/bp_dual.h
$(HEADERS
)
128 cbp
$(OE
) : $(SRC
)/cbp.
cpp $(INC
)/cbp.h
$(INC
)/bbp.h
$(INC
)/bp_dual.h
$(HEADERS
)
131 hak
$(OE
) : $(SRC
)/hak.
cpp $(INC
)/hak.h
$(HEADERS
) $(INC
)/regiongraph.h
134 jtree
$(OE
) : $(SRC
)/jtree.
cpp $(INC
)/jtree.h
$(HEADERS
) $(INC
)/weightedgraph.h
$(INC
)/clustergraph.h
$(INC
)/regiongraph.h
137 treeep
$(OE
) : $(SRC
)/treeep.
cpp $(INC
)/treeep.h
$(HEADERS
) $(INC
)/weightedgraph.h
$(INC
)/clustergraph.h
$(INC
)/regiongraph.h
$(INC
)/jtree.h
140 emalg
$(OE
) : $(SRC
)/emalg.
cpp $(INC
)/emalg.h
$(INC
)/evidence.h
$(HEADERS
)
143 decmap
$(OE
) : $(SRC
)/decmap.
cpp $(INC
)/decmap.h
$(HEADERS
)
146 glc
$(OE
) : $(SRC
)/glc.
cpp $(INC
)/glc.h
$(HEADERS
) $(INC
)/cobwebgraph.h
153 examples
/%$(EE
) : examples
/%.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
154 $(CC
) $(CCO
)$@
$< $(LIBS
)
156 examples
/example_sprinkler_gibbs
$(EE
) : examples
/example_sprinkler_gibbs.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
157 $(CC
) $(CCO
)$@
$< $(LIBS
)
159 examples
/example_imagesegmentation
$(EE
) : examples
/example_imagesegmentation.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
161 $(CC
) -DNEW_CIMG
$(CIMGINC
) $(CCO
)$@
$< $(LIBS
) $(CIMGLIBS
)
163 $(CC
) $(CIMGINC
) $(CCO
)$@
$< $(LIBS
) $(CIMGLIBS
)
170 tests
/unit
/%$(EE
) : tests
/unit
/%.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
171 ifneq ($(OS
),WINDOWS
)
172 $(CC
) -DBOOST_TEST_DYN_LINK
$(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_UTF
)
174 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_UTF
) /SUBSYSTEM
:CONSOLE
181 tests
/testdai
$(EE
) : tests
/testdai.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
182 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
183 tests
/testem
/testem
$(EE
) : tests
/testem
/testem.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
184 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
185 tests
/testbbp
$(EE
) : tests
/testbbp.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
186 $(CC
) $(CCO
)$@
$< $(LIBS
)
192 matlab
/dai
$(ME
) : $(SRC
)/matlab
/dai.
cpp $(HEADERS
) $(SOURCES
) $(SRC
)/matlab
/matlab.
cpp
193 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SOURCES
)
195 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
196 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
198 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
199 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/factorgraph.
cpp $(SRC
)/exceptions.
cpp $(SRC
)/bipgraph.
cpp $(SRC
)/graph.
cpp $(SRC
)/factor.
cpp $(SRC
)/util.
cpp
201 matlab
/dai_potstrength
$(ME
) : $(SRC
)/matlab
/dai_potstrength.
cpp $(HEADERS
) $(SRC
)/matlab
/matlab.
cpp $(SRC
)/exceptions.
cpp
202 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SRC
)/exceptions.
cpp
204 matlab
/dai_jtree
$(ME
) : $(SRC
)/matlab
/dai_jtree.
cpp $(HEADERS
) $(SOURCES
) $(SRC
)/matlab
/matlab.
cpp
205 $(MEX
) -output
$@
$< $(SRC
)/matlab
/matlab.
cpp $(SOURCES
)
211 utils
/createfg
$(EE
) : utils
/createfg.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
212 $(CC
) $(CCO
)$@
$< $(LIBS
) $(BOOSTLIBS_PO
)
214 utils
/fg2dot
$(EE
) : utils
/fg2dot.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
215 $(CC
) $(CCO
)$@
$< $(LIBS
)
217 utils
/fginfo
$(EE
) : utils
/fginfo.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
218 $(CC
) $(CCO
)$@
$< $(LIBS
)
220 utils
/uai2fg
$(EE
) : utils
/uai2fg.
cpp $(HEADERS
) $(LIB
)/libdai
$(LE
)
221 $(CC
) $(CCO
)$@
$< $(LIBS
)
227 ifneq ($(OS
),WINDOWS
)
228 $(LIB
)/libdai
$(LE
) : $(OBJECTS
)
230 ar rcus
$(LIB
)/libdai
$(LE
) $(OBJECTS
)
232 $(LIB
)/libdai
$(LE
) : $(OBJECTS
)
234 lib
/out
:$(LIB
)/libdai
$(LE
) $(OBJECTS
)
241 testregression
: tests
/testdai
$(EE
)
242 @echo Starting regression
test...this can take a minute or so
!
243 ifneq ($(OS
),WINDOWS
)
244 cd tests
&& .
/testregression
&& cd ..
246 cd tests
&& testregression.bat
&& cd ..
249 testem
: tests
/testem
/testem
$(EE
)
250 @echo Starting EM tests
251 ifneq ($(OS
),WINDOWS
)
252 cd tests
/testem
&& .
/runtests
&& cd ..
/..
254 cd tests
\testem
&& runtests
&& cd ..\..
261 doc
: $(INC
)/*.h
$(SRC
)/*.
cpp examples
/*.
cpp doxygen.conf
264 README
: doc scripts
/makeREADME Makefile
265 DAI_VERSION
=$(DAI_VERSION
) DAI_DATE
=$(DAI_DATE
) scripts
/makeREADME
268 etags src
/*.
cpp include/dai
/*.h tests
/*.
cpp utils
/*.
cpp
269 ctags src
/*.
cpp include/dai
/*.h tests
/*.
cpp utils
/*.
cpp
276 ifneq ($(OS
),WINDOWS
)
280 -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
)
281 -rm tests
/testdai
$(EE
) tests
/testem
/testem
$(EE
) tests
/testbbp
$(EE
)
282 -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
)
283 -rm factorgraph_test.fg alldai_test.aliases
284 -rm utils
/fg2dot
$(EE
) utils
/createfg
$(EE
) utils
/fginfo
$(EE
) utils
/uai2fg
$(EE
)
294 -del examples\
*$(EE
).manifest
298 -del tests\
*$(EE
).manifest
301 -del tests
\testem\
*$(EE
)
302 -del tests
\testem\
*$(EE
).manifest
303 -del tests
\testem\
*.pdb
304 -del tests
\testem\
*.ilk
306 -del utils\
*$(EE
).manifest
309 -del tests\unit\
*_test
$(EE
)
310 -del tests\unit\
*_test
$(EE
).manifest
311 -del tests\unit\
*_test.pdb
312 -del tests\unit\
*_test.ilk
313 -del factorgraph_test.fg
314 -del alldai_test.aliases
315 -del
$(LIB
)\libdai
$(LE
)