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