Added unit tests for VarSet
[libdai.git] / Makefile
1 # This file is part of libDAI - http://www.libdai.org/
2 #
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.
6 #
7 # Copyright (C) 2006-2010 Joris Mooij [joris dot mooij at libdai dot org]
8 # Copyright (C) 2006-2007 Radboud University Nijmegen, The Netherlands
9
10
11 # Load the platform independent build configuration file
12 include Makefile.ALL
13
14 # Load the local configuration from Makefile.conf
15 include Makefile.conf
16
17 # Set version and date
18 DAI_VERSION="git HEAD"
19 DAI_DATE="February 11, 2010 - or later"
20
21 # Directories of libDAI sources
22 # Location libDAI headers
23 INC=include/dai
24 # Location of libDAI source files
25 SRC=src
26 # Destination directory of libDAI library
27 LIB=lib
28
29 # Set final compiler flags
30 ifdef DEBUG
31 CCFLAGS:=$(CCFLAGS) $(CCDEBUGFLAGS)
32 else
33 CCFLAGS:=$(CCFLAGS) $(CCNODEBUGFLAGS)
34 endif
35
36 # Define build targets
37 TARGETS=tests utils lib examples unittests testregression testem
38 ifdef WITH_DOC
39 TARGETS:=$(TARGETS) doc
40 endif
41 ifdef WITH_MATLAB
42 TARGETS:=$(TARGETS) matlabs
43 # Specify the same C++ compiler and flags to mex
44 ifneq ($(OS),WINDOWS)
45 MEXFLAGS=CXX\#$(CC) CXXFLAGS\#'$(CCFLAGS)'
46 else
47 MEXFLAGS=CXX\#$(CC) CXXFLAGS\#"$(CCFLAGS)"
48 endif
49 ifdef NEW_MATLAB
50 MEXFLAGS:=$(MEXFLAGS) -largeArrayDims
51 else
52 MEXFLAGS:=$(MEXFLAGS) -DSMALLMEM
53 endif
54 endif
55
56 # Define conditional build targets
57 OBJECTS:=exactinf$(OE) evidence$(OE) emalg$(OE)
58 ifdef WITH_BP
59 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_BP
60 OBJECTS:=$(OBJECTS) bp$(OE)
61 endif
62 ifdef WITH_FBP
63 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_FBP
64 OBJECTS:=$(OBJECTS) fbp$(OE)
65 endif
66 ifdef WITH_TRWBP
67 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_TRWBP
68 OBJECTS:=$(OBJECTS) trwbp$(OE)
69 endif
70 ifdef WITH_MF
71 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_MF
72 OBJECTS:=$(OBJECTS) mf$(OE)
73 endif
74 ifdef WITH_HAK
75 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_HAK
76 OBJECTS:=$(OBJECTS) hak$(OE)
77 endif
78 ifdef WITH_LC
79 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_LC
80 OBJECTS:=$(OBJECTS) lc$(OE)
81 endif
82 ifdef WITH_TREEEP
83 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_TREEEP
84 OBJECTS:=$(OBJECTS) treeep$(OE)
85 endif
86 ifdef WITH_JTREE
87 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_JTREE
88 OBJECTS:=$(OBJECTS) jtree$(OE)
89 endif
90 ifdef WITH_MR
91 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_MR
92 OBJECTS:=$(OBJECTS) mr$(OE)
93 endif
94 ifdef WITH_GIBBS
95 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_GIBBS
96 OBJECTS:=$(OBJECTS) gibbs$(OE)
97 endif
98 ifdef WITH_CBP
99 CCFLAGS:=$(CCFLAGS) -DDAI_WITH_CBP
100 OBJECTS:=$(OBJECTS) bbp$(OE) cbp$(OE) bp_dual$(OE)
101 endif
102
103 # Define standard libDAI header dependencies
104 HEADERS=$(INC)/bipgraph.h $(INC)/graph.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/smallset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/exceptions.h $(INC)/util.h
105
106 # Setup final command for C++ compiler and MEX
107 ifneq ($(OS),WINDOWS)
108 CC:=$(CC) $(CCINC) $(CCFLAGS) $(CCLIB)
109 else
110 CC:=$(CC) $(CCINC) $(CCFLAGS)
111 LIBS:=$(LIBS) $(CCLIB)
112 endif
113 MEX:=$(MEX) $(CCLIB) $(CCINC) $(MEXFLAGS)
114
115
116 # META TARGETS
117 ###############
118
119 all : $(TARGETS)
120
121 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)
122
123 matlabs : matlab/dai$(ME) matlab/dai_readfg$(ME) matlab/dai_writefg$(ME) matlab/dai_potstrength$(ME)
124
125 unittests : tests/unit/var$(EE) tests/unit/smallset$(EE) tests/unit/varset$(EE)
126 echo Running unit tests...
127 tests/unit/var
128 tests/unit/smallset
129 tests/unit/varset
130
131 tests : tests/testdai$(EE) tests/testem/testem$(EE) tests/testbbp$(EE) $(unittests)
132
133 utils : utils/createfg$(EE) utils/fg2dot$(EE) utils/fginfo$(EE)
134
135 lib: $(LIB)/libdai$(LE)
136
137
138 # OBJECTS
139 ##########
140
141 %$(OE) : $(SRC)/%.cpp $(INC)/%.h $(HEADERS)
142 $(CC) -c $< -o $@
143
144 bbp$(OE) : $(SRC)/bbp.cpp $(INC)/bbp.h $(INC)/bp_dual.h $(HEADERS)
145 $(CC) -c $<
146
147 cbp$(OE) : $(SRC)/cbp.cpp $(INC)/cbp.h $(INC)/bbp.h $(INC)/bp_dual.h $(HEADERS)
148 $(CC) -c $<
149
150 hak$(OE) : $(SRC)/hak.cpp $(INC)/hak.h $(HEADERS) $(INC)/regiongraph.h
151 $(CC) -c $<
152
153 jtree$(OE) : $(SRC)/jtree.cpp $(INC)/jtree.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h
154 $(CC) -c $<
155
156 treeep$(OE) : $(SRC)/treeep.cpp $(INC)/treeep.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h $(INC)/jtree.h
157 $(CC) -c $<
158
159 emalg$(OE) : $(SRC)/emalg.cpp $(INC)/emalg.h $(INC)/evidence.h $(HEADERS)
160 $(CC) -c $<
161
162
163 # EXAMPLES
164 ###########
165
166 examples/example$(EE) : examples/example.cpp $(HEADERS) $(LIB)/libdai$(LE)
167 $(CC) $(CCO)$@ $< $(LIBS)
168
169 examples/example_bipgraph$(EE) : examples/example_bipgraph.cpp $(HEADERS) $(LIB)/libdai$(LE)
170 $(CC) $(CCO)$@ $< $(LIBS)
171
172 examples/example_varset$(EE) : examples/example_varset.cpp $(HEADERS) $(LIB)/libdai$(LE)
173 $(CC) $(CCO)$@ $< $(LIBS)
174
175 examples/example_permute$(EE) : examples/example_permute.cpp $(HEADERS) $(LIB)/libdai$(LE)
176 $(CC) $(CCO)$@ $< $(LIBS)
177
178 examples/example_sprinkler$(EE) : examples/example_sprinkler.cpp $(HEADERS) $(LIB)/libdai$(LE)
179 $(CC) $(CCO)$@ $< $(LIBS)
180
181 examples/example_sprinkler_gibbs$(EE) : examples/example_sprinkler_gibbs.cpp $(HEADERS) $(LIB)/libdai$(LE)
182 $(CC) $(CCO)$@ $< $(LIBS)
183
184 examples/example_sprinkler_em$(EE) : examples/example_sprinkler_em.cpp $(HEADERS) $(LIB)/libdai$(LE)
185 $(CC) $(CCO)$@ $< $(LIBS)
186
187
188 # UNIT TESTS
189 #############
190
191 tests/unit/var$(EE) : tests/unit/var.cpp $(HEADERS) $(LIB)/libdai$(LE)
192 $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_UTF)
193 tests/unit/smallset$(EE) : tests/unit/smallset.cpp $(HEADERS) $(LIB)/libdai$(LE)
194 $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_UTF)
195 tests/unit/varset$(EE) : tests/unit/varset.cpp $(HEADERS) $(LIB)/libdai$(LE)
196 $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_UTF)
197
198
199 # TESTS
200 ########
201
202 tests/testdai$(EE) : tests/testdai.cpp $(HEADERS) $(LIB)/libdai$(LE)
203 $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_PO)
204 tests/testem/testem$(EE) : tests/testem/testem.cpp $(HEADERS) $(LIB)/libdai$(LE)
205 $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_PO)
206
207 tests/testbbp$(EE) : tests/testbbp.cpp $(HEADERS) $(LIB)/libdai$(LE)
208 $(CC) $(CCO)$@ $< $(LIBS)
209
210
211 # MATLAB INTERFACE
212 ###################
213
214 matlab/dai$(ME) : $(SRC)/matlab/dai.cpp $(HEADERS) matlab$(OE) $(LIB)/libdai$(LE)
215 $(MEX) -o$@ $< matlab$(OE) $(LIB)/libdai$(LE)
216
217 matlab/dai_readfg$(ME) : $(SRC)/matlab/dai_readfg.cpp $(HEADERS) factorgraph$(OE) matlab$(OE) exceptions$(OE) bipgraph$(OE)
218 $(MEX) -o$@ $< factorgraph$(OE) matlab$(OE) exceptions$(OE) bipgraph$(OE)
219
220 matlab/dai_writefg$(ME) : $(SRC)/matlab/dai_writefg.cpp $(HEADERS) factorgraph$(OE) matlab$(OE) exceptions$(OE) bipgraph$(OE)
221 $(MEX) -o$@ $< factorgraph$(OE) matlab$(OE) exceptions$(OE) bipgraph$(OE)
222
223 matlab/dai_potstrength$(ME) : $(SRC)/matlab/dai_potstrength.cpp $(HEADERS) matlab$(OE) exceptions$(OE)
224 $(MEX) -o$@ $< matlab$(OE) exceptions$(OE)
225
226 matlab$(OE) : $(SRC)/matlab/matlab.cpp $(INC)/matlab/matlab.h $(HEADERS)
227 $(MEX) -c $<
228
229
230 # UTILS
231 ########
232
233 utils/createfg$(EE) : utils/createfg.cpp $(HEADERS) $(LIB)/libdai$(LE)
234 $(CC) $(CCO)$@ $< $(LIBS) $(BOOSTLIBS_PO)
235
236 utils/fg2dot$(EE) : utils/fg2dot.cpp $(HEADERS) $(LIB)/libdai$(LE)
237 $(CC) $(CCO)$@ $< $(LIBS)
238
239 utils/fginfo$(EE) : utils/fginfo.cpp $(HEADERS) $(LIB)/libdai$(LE)
240 $(CC) $(CCO)$@ $< $(LIBS)
241
242
243 # LIBRARY
244 ##########
245
246 OBJECTS:=bipgraph$(OE) graph$(OE) varset$(OE) daialg$(OE) alldai$(OE) clustergraph$(OE) factor$(OE) factorgraph$(OE) properties$(OE) regiongraph$(OE) util$(OE) weightedgraph$(OE) exceptions$(OE) $(OBJECTS)
247
248 ifneq ($(OS),WINDOWS)
249 $(LIB)/libdai$(LE) : $(OBJECTS)
250 -mkdir -p lib
251 ar rcus $(LIB)/libdai$(LE) $(OBJECTS)
252 else
253 $(LIB)/libdai$(LE) : $(OBJECTS)
254 -mkdir lib
255 lib /out:$(LIB)/libdai$(LE) $(OBJECTS)
256 endif
257
258
259 # REGRESSION TESTS
260 ###################
261
262 testregression : tests/testdai$(EE)
263 @echo Starting regression test...this can take a minute or so!
264 ifneq ($(OS),WINDOWS)
265 cd tests && ./testregression && cd ..
266 else
267 cd tests && testregression.bat && cd ..
268 endif
269
270 testem : tests/testem/testem$(EE)
271 @echo Starting EM tests
272 ifneq ($(OS),WINDOWS)
273 cd tests/testem && ./runtests && cd ../..
274 else
275 cd tests\testem && runtests && cd ..\..
276 endif
277
278
279 # DOCUMENTATION
280 ################
281
282 doc : $(INC)/*.h $(SRC)/*.cpp examples/*.cpp doxygen.conf
283 doxygen doxygen.conf
284
285 README : doc scripts/makeREADME
286 DAI_VERSION=$(DAI_VERSION) DAI_DATE=$(DAI_DATE) scripts/makeREADME
287
288 TAGS :
289 etags src/*.cpp include/dai/*.h tests/*.cpp utils/*.cpp
290 ctags src/*.cpp include/dai/*.h tests/*.cpp utils/*.cpp
291
292
293 # CLEAN
294 ########
295
296 ifneq ($(OS),WINDOWS)
297 .PHONY : clean
298 clean :
299 -rm *$(OE)
300 -rm matlab/*$(ME)
301 -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)
302 -rm tests/testdai$(EE) tests/testem/testem$(EE) tests/testbbp$(EE)
303 -rm tests/unit/var$(EE) tests/unit/smallset$(EE) tests/unit/varset$(EE)
304 -rm utils/fg2dot$(EE) utils/createfg$(EE) utils/fginfo$(EE)
305 -rm -R doc
306 -rm -R lib
307 else
308 .PHONY : clean
309 clean :
310 -del *$(OE)
311 -del *.ilk
312 -del *.pdb
313 -del *$(EE)
314 -del matlab\*$(ME)
315 -del examples\*$(EE)
316 -del examples\*.ilk
317 -del examples\*.pdb
318 -del tests\testdai$(EE)
319 -del tests\testbbp$(EE)
320 -del tests\testem\testem$(EE)
321 -del tests\*.pdb
322 -del tests\*.ilk
323 -del tests\testem\*.pdb
324 -del tests\testem\*.ilk
325 -del utils\*$(EE)
326 -del utils\*.pdb
327 -del utils\*.ilk
328 -del tests\unit\*.pdk
329 -del tests\unit\*.ilk
330 -del tests\unit\var$(EE)
331 -del tests\unit\smallset$(EE)
332 -del tests\unit\varset$(EE)
333 -del $(LIB)\libdai$(LE)
334 -rmdir lib
335 endif