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