Merged prob.h, factorgraph.h, factograph.cpp from SVN head (broken!)
[libdai.git] / Makefile
1 # Copyright (C) 2006-2008 Joris Mooij [j dot mooij at science dot ru dot nl]
2 # Radboud University Nijmegen, The Netherlands
3 #
4 # This file is part of libDAI.
5 #
6 # libDAI is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # libDAI is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with libDAI; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20
21 # Enable/disable various approximate inference methods
22 WITH_BP=true
23 WITH_MF=true
24 WITH_HAK=true
25 WITH_LC=true
26 WITH_TREEEP=true
27 WITH_JTREE=true
28 WITH_MR=true
29 # Build with debug info?
30 DEBUG=true
31 # Build matlab interface?
32 WITH_MATLAB=
33 # New/old matlab version?
34 NEW_MATLAB=true
35 # Windows or linux (default)?
36 WINDOWS=
37
38 # Directories
39 INC=include/dai
40 SRC=src
41 LIB=lib
42
43 # Extensions (library, object, executable extensions)
44 LE=.a
45 OE=.o
46 EE=
47
48 # Libraries
49 LIBS=-ldai
50
51 # We use the BOOST Program Options library
52 BOOSTLIBS=-lboost_program_options
53
54 # Compile using GNU C++ Compiler
55 CC=g++
56
57 # Flags for the C++ compiler
58 CCFLAGS=-Wall -W -Wextra -fpic -I./include -Llib -O3 #-pg #-static #-DVERBOSE
59 ifdef DEBUG
60 CCFLAGS:=$(CCFLAGS) -g -DDAI_DEBUG
61 endif
62
63 ifdef WINDOWS
64 CCFLAGS=$(CCFLAGS) -DWINDOWS
65 endif
66
67 OBJECTS:=exactinf$(OE)
68 ifdef WITH_BP
69 CCFLAGS:=$(CCFLAGS) -DWITH_BP
70 OBJECTS:=$(OBJECTS) bp$(OE)
71 endif
72 ifdef WITH_MF
73 CCFLAGS:=$(CCFLAGS) -DWITH_MF
74 OBJECTS:=$(OBJECTS) mf$(OE)
75 endif
76 ifdef WITH_HAK
77 CCFLAGS:=$(CCFLAGS) -DWITH_HAK
78 OBJECTS:=$(OBJECTS) hak$(OE)
79 endif
80 ifdef WITH_LC
81 CCFLAGS:=$(CCFLAGS) -DWITH_LC
82 OBJECTS:=$(OBJECTS) lc$(OE)
83 endif
84 ifdef WITH_TREEEP
85 CCFLAGS:=$(CCFLAGS) -DWITH_TREEEP
86 OBJECTS:=$(OBJECTS) treeep$(OE)
87 endif
88 ifdef WITH_JTREE
89 CCFLAGS:=$(CCFLAGS) -DWITH_JTREE
90 OBJECTS:=$(OBJECTS) jtree$(OE)
91 endif
92 ifdef WITH_MR
93 CCFLAGS:=$(CCFLAGS) -DWITH_MR
94 OBJECTS:=$(OBJECTS) mr$(OE)
95 endif
96
97 ifdef WITH_MATLAB
98 # Replace the following by the directory where Matlab has been installed
99 MATLABDIR=/opt/matlab/bin
100 # Replace the following with the extension of compiled MEX files on this platform, e.g. .mexglx for x86
101 ME=.mexglx
102 MEX=$(MATLABDIR)/mex
103 MEXFLAGS=-I.
104 ifdef DEBUG
105 MEXFLAGS:=$(MEXFLAGS) -g -DDAI_DEBUG
106 endif
107 ifdef NEW_MATLAB
108 MEXFLAGS:=$(MEXFLAGS) -largeArrayDims
109 else
110 MEXFLAGS:=$(MEXFLAGS) -DSMALLMEM
111 endif
112 endif
113
114 HEADERS=$(INC)/bipgraph.h $(INC)/diffs.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/x2x.h $(INC)/exceptions.h
115
116 TARGETS=tests utils $(LIB)/libdai$(LE) example$(EE) testregression doc
117 ifdef WITH_MATLAB
118 TARGETS:=$(TARGETS) matlabs
119 endif
120 all : $(TARGETS)
121 echo -e "\a"
122
123 matlabs : matlab/dai.$(ME) matlab/dai_readfg.$(ME) matlab/dai_writefg.$(ME) matlab/dai_potstrength.$(ME)
124
125 $(LIB)/libdai$(LE) : bipgraph$(OE) daialg$(OE) alldai$(OE) clustergraph$(OE) factorgraph$(OE) properties$(OE) regiongraph$(OE) util$(OE) weightedgraph$(OE) x2x$(OE) exceptions$(OE) $(OBJECTS)
126 ar rcus $(LIB)/libdai$(LE) bipgraph$(OE) daialg$(OE) alldai$(OE) clustergraph$(OE) factorgraph$(OE) properties$(OE) regiongraph$(OE) util$(OE) weightedgraph$(OE) x2x$(OE) exceptions$(OE) $(OBJECTS)
127
128 tests : tests/test$(EE)
129
130 utils : utils/createfg$(EE) utils/fg2dot$(EE) utils/fginfo$(EE)
131
132 testregression : tests/test
133 echo Testing...this can take a while...
134 cd tests; time ./testregression; cd ..
135
136 doc : $(INC)/*.h $(SRC)/*.cpp doxygen.conf
137 doxygen doxygen.conf
138
139 clean :
140 rm *$(OE) example$(EE) matlab/*.$(ME) matlab/*$(OE) tests/test$(EE) utils/fg2dot$(EE) utils/createfg$(EE) utils/fginfo$(EE) $(LIB)/libdai$(LE); echo
141 rm -R doc; echo
142
143 bipgraph$(OE) : $(SRC)/bipgraph.cpp $(HEADERS)
144 $(CC) $(CCFLAGS) -c $(SRC)/bipgraph.cpp
145
146 daialg$(OE) : $(SRC)/daialg.cpp $(HEADERS)
147 $(CC) $(CCFLAGS) -c $(SRC)/daialg.cpp
148
149 exactinf$(OE) : $(SRC)/exactinf.cpp $(INC)/exactinf.h $(HEADERS)
150 $(CC) $(CCFLAGS) -c $(SRC)/exactinf.cpp
151
152 bp$(OE) : $(SRC)/bp.cpp $(INC)/bp.h $(HEADERS)
153 $(CC) $(CCFLAGS) -c $(SRC)/bp.cpp
154
155 lc$(OE) : $(SRC)/lc.cpp $(INC)/lc.h $(HEADERS)
156 $(CC) $(CCFLAGS) -c $(SRC)/lc.cpp
157
158 mf$(OE) : $(SRC)/mf.cpp $(INC)/mf.h $(HEADERS)
159 $(CC) $(CCFLAGS) -c $(SRC)/mf.cpp
160
161 factorgraph$(OE) : $(SRC)/factorgraph.cpp $(INC)/factorgraph.h $(HEADERS)
162 $(CC) $(CCFLAGS) -c $(SRC)/factorgraph.cpp
163
164 util$(OE) : $(SRC)/util.cpp $(INC)/util.h $(HEADERS)
165 $(CC) $(CCFLAGS) -c $(SRC)/util.cpp
166
167 regiongraph$(OE) : $(SRC)/regiongraph.cpp $(INC)/regiongraph.h $(HEADERS)
168 $(CC) $(CCFLAGS) -c $(SRC)/regiongraph.cpp
169
170 hak$(OE) : $(SRC)/hak.cpp $(INC)/hak.h $(HEADERS) $(INC)/regiongraph.h
171 $(CC) $(CCFLAGS) -c $(SRC)/hak.cpp
172
173 clustergraph$(OE) : $(SRC)/clustergraph.cpp $(INC)/clustergraph.h $(HEADERS)
174 $(CC) $(CCFLAGS) -c $(SRC)/clustergraph.cpp
175
176 jtree$(OE) : $(SRC)/jtree.cpp $(INC)/jtree.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h
177 $(CC) $(CCFLAGS) -c $(SRC)/jtree.cpp
178
179 treeep$(OE) : $(SRC)/treeep.cpp $(INC)/treeep.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h $(INC)/jtree.h
180 $(CC) $(CCFLAGS) -c $(SRC)/treeep.cpp
181
182 weightedgraph$(OE) : $(SRC)/weightedgraph.cpp $(INC)/weightedgraph.h $(HEADERS)
183 $(CC) $(CCFLAGS) -c $(SRC)/weightedgraph.cpp
184
185 mr$(OE) : $(SRC)/mr.cpp $(INC)/mr.h $(HEADERS)
186 $(CC) $(CCFLAGS) -c $(SRC)/mr.cpp
187
188 properties$(OE) : $(SRC)/properties.cpp $(HEADERS)
189 $(CC) $(CCFLAGS) -c $(SRC)/properties.cpp
190
191 exceptions$(OE) : $(SRC)/exceptions.cpp $(HEADERS)
192 $(CC) $(CCFLAGS) -c $(SRC)/exceptions.cpp
193
194 alldai$(OE) : $(SRC)/alldai.cpp $(HEADERS)
195 $(CC) $(CCFLAGS) -c $(SRC)/alldai.cpp
196
197 x2x$(OE) : $(SRC)/x2x.cpp $(HEADERS)
198 $(CC) $(CCFLAGS) -c $(SRC)/x2x.cpp
199
200
201 # EXAMPLE
202 ##########
203
204 example$(EE) : example.cpp $(HEADERS) $(LIB)/libdai$(LE)
205 $(CC) $(CCFLAGS) -o example$(EE) example.cpp $(LIBS)
206
207 # TESTS
208 ########
209
210 tests/test$(EE) : tests/test.cpp $(HEADERS) $(LIB)/libdai$(LE)
211 $(CC) $(CCFLAGS) -o tests/test$(EE) tests/test.cpp $(LIBS) $(BOOSTLIBS)
212
213
214 # MATLAB INTERFACE
215 ###################
216
217 matlab/dai.$(ME) : matlab/dai.cpp $(HEADERS) matlab/matlab$(OE) $(LIB)/libdai$(LE)
218 $(MEX) $(MEXFLAGS) -o matlab/dai matlab/dai.cpp matlab/matlab$(OE) $(LIB)/libdai$(LE)
219
220 matlab/dai_readfg.$(ME) : matlab/dai_readfg.cpp $(HEADERS) factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
221 $(MEX) $(MEXFLAGS) -o matlab/dai_readfg matlab/dai_readfg.cpp factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
222
223 matlab/dai_writefg.$(ME) : matlab/dai_writefg.cpp $(HEADERS) factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
224 $(MEX) $(MEXFLAGS) -o matlab/dai_writefg matlab/dai_writefg.cpp factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
225
226 matlab/dai_potstrength.$(ME) : matlab/dai_potstrength.cpp $(HEADERS) matlab/matlab$(OE) exceptions$(OE)
227 $(MEX) $(MEXFLAGS) -o matlab/dai_potstrength matlab/dai_potstrength.cpp matlab/matlab$(OE) exceptions$(OE)
228
229 matlab/matlab$(OE) : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
230 $(MEX) $(MEXFLAGS) -outdir matlab -c matlab/matlab.cpp
231
232
233 # UTILS
234 ########
235
236 utils/createfg$(EE) : utils/createfg.cpp $(HEADERS) $(LIB)/libdai$(LE)
237 $(CC) $(CCFLAGS) -o utils/createfg utils/createfg.cpp $(LIBS) $(BOOSTLIBS)
238
239 utils/fg2dot$(EE) : utils/fg2dot.cpp $(HEADERS) $(LIB)/libdai$(LE)
240 $(CC) $(CCFLAGS) -o utils/fg2dot utils/fg2dot.cpp $(LIBS)
241
242 utils/fginfo$(EE) : utils/fginfo.cpp $(HEADERS) $(LIB)/libdai$(LE)
243 $(CC) $(CCFLAGS) -o utils/fginfo utils/fginfo.cpp $(LIBS)