Updated copyrights
[libdai.git] / Makefile.win
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=true
34 # New/old matlab version?
35 NEW_MATLAB=true
36 # Windows or linux (default)?
37 WINDOWS=true
38
39 # Directories
40 INC=include/dai
41 SRC=src
42 LIB=lib
43
44 # Extensions (library, object, executable extensions)
45 LE=.lib
46 OE=.obj
47 EE=.exe
48
49 # Libraries (for some reason, we have to add the VC library path, although it is in the environment)
50 LIBS=/link $(LIB)/libdai$(LE) /LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB" /LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB" /LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib"
51
52 # We use the BOOST Program Options library
53 BOOSTLIBS=/LIBPATH:C:\boost_1_36_0\stage\lib
54
55 # Compile using GNU C++ Compiler
56 CC=cl
57
58 # Flags for the C++ compiler
59 CCFLAGS=/I./include /IC:\boost_1_36_0 /EHsc /Ox
60 !IFDEF DEBUG
61 CCFLAGS=$(CCFLAGS) /Zi /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)
118 # testregression disabled, it uses diff
119 # doc disabled, it uses doxygen
120 !IFDEF WITH_MATLAB
121 TARGETS = $(TARGETS) matlabs
122 !ENDIF
123 all : $(TARGETS)
124
125 matlabs : matlab/dai.$(ME) matlab/dai_readfg.$(ME) matlab/dai_writefg.$(ME) matlab/dai_potstrength.$(ME)
126
127 $(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 lib /out:$(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)
129
130 tests : tests/test$(EE)
131
132 utils : utils/createfg$(EE) utils/fg2dot$(EE) utils/fginfo$(EE)
133
134 testregression : tests/test
135 echo Testing...this can take a while...
136 cd tests; time ./testregression; cd ..
137
138 doc : $(INC)/*.h $(SRC)/*.cpp doxygen.conf
139 doxygen doxygen.conf
140
141 clean :
142 del *$(OE) *.ilk *.pdb *$(EE) matlab\*.$(ME) matlab\*$(OE) tests\test$(EE) tests\*.pdb tests\*.ilk utils\*$(EE) utils\*.pdb utils\*.ilk $(LIB)\libdai$(LE)
143
144
145 bipgraph$(OE) : $(SRC)/bipgraph.cpp $(HEADERS)
146 $(CC) $(CCFLAGS) -c $(SRC)/bipgraph.cpp
147
148 daialg$(OE) : $(SRC)/daialg.cpp $(HEADERS)
149 $(CC) $(CCFLAGS) -c $(SRC)/daialg.cpp
150
151 exactinf$(OE) : $(SRC)/exactinf.cpp $(INC)/exactinf.h $(HEADERS)
152 $(CC) $(CCFLAGS) -c $(SRC)/exactinf.cpp
153
154 bp$(OE) : $(SRC)/bp.cpp $(INC)/bp.h $(HEADERS)
155 $(CC) $(CCFLAGS) -c $(SRC)/bp.cpp
156
157 lc$(OE) : $(SRC)/lc.cpp $(INC)/lc.h $(HEADERS)
158 $(CC) $(CCFLAGS) -c $(SRC)/lc.cpp
159
160 mf$(OE) : $(SRC)/mf.cpp $(INC)/mf.h $(HEADERS)
161 $(CC) $(CCFLAGS) -c $(SRC)/mf.cpp
162
163 factorgraph$(OE) : $(SRC)/factorgraph.cpp $(INC)/factorgraph.h $(HEADERS)
164 $(CC) $(CCFLAGS) -c $(SRC)/factorgraph.cpp
165
166 util$(OE) : $(SRC)/util.cpp $(INC)/util.h $(HEADERS)
167 $(CC) $(CCFLAGS) -c $(SRC)/util.cpp
168
169 regiongraph$(OE) : $(SRC)/regiongraph.cpp $(INC)/regiongraph.h $(HEADERS)
170 $(CC) $(CCFLAGS) -c $(SRC)/regiongraph.cpp
171
172 hak$(OE) : $(SRC)/hak.cpp $(INC)/hak.h $(HEADERS) $(INC)/regiongraph.h
173 $(CC) $(CCFLAGS) -c $(SRC)/hak.cpp
174
175 clustergraph$(OE) : $(SRC)/clustergraph.cpp $(INC)/clustergraph.h $(HEADERS)
176 $(CC) $(CCFLAGS) -c $(SRC)/clustergraph.cpp
177
178 jtree$(OE) : $(SRC)/jtree.cpp $(INC)/jtree.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h
179 $(CC) $(CCFLAGS) -c $(SRC)/jtree.cpp
180
181 treeep$(OE) : $(SRC)/treeep.cpp $(INC)/treeep.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h $(INC)/jtree.h
182 $(CC) $(CCFLAGS) -c $(SRC)/treeep.cpp
183
184 weightedgraph$(OE) : $(SRC)/weightedgraph.cpp $(INC)/weightedgraph.h $(HEADERS)
185 $(CC) $(CCFLAGS) -c $(SRC)/weightedgraph.cpp
186
187 mr$(OE) : $(SRC)/mr.cpp $(INC)/mr.h $(HEADERS)
188 $(CC) $(CCFLAGS) -c $(SRC)/mr.cpp
189
190 properties$(OE) : $(SRC)/properties.cpp $(HEADERS)
191 $(CC) $(CCFLAGS) -c $(SRC)/properties.cpp
192
193 exceptions$(OE) : $(SRC)/exceptions.cpp $(HEADERS)
194 $(CC) $(CCFLAGS) -c $(SRC)/exceptions.cpp
195
196 alldai$(OE) : $(SRC)/alldai.cpp $(HEADERS)
197 $(CC) $(CCFLAGS) -c $(SRC)/alldai.cpp
198
199 varset$(OE) : $(SRC)/varset.cpp $(HEADERS)
200 $(CC) $(CCFLAGS) -c $(SRC)/varset.cpp
201
202
203 # EXAMPLE
204 ##########
205
206 example$(EE) : example.cpp $(HEADERS) $(LIB)/libdai$(LE)
207 $(CC) $(CCFLAGS) /Feexample example.cpp $(LIBS)
208
209
210 # TESTS
211 ########
212
213 tests/test$(EE) : tests/test.cpp $(HEADERS) $(LIB)/libdai$(LE)
214 $(CC) $(CCFLAGS) /Fetests/test tests/test.cpp $(LIBS) $(BOOSTLIBS)
215
216
217 # MATLAB INTERFACE
218 ###################
219
220 matlab/dai.$(ME) : matlab/dai.cpp $(HEADERS) matlab/matlab$(OE) $(LIB)/libdai$(LE)
221 $(MEX) $(MEXFLAGS) -o matlab/dai matlab/dai.cpp matlab/matlab$(OE) $(LIB)/libdai$(LE)
222
223 matlab/dai_readfg.$(ME) : matlab/dai_readfg.cpp $(HEADERS) factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE) varset$(OE)
224 $(MEX) $(MEXFLAGS) -o matlab/dai_readfg matlab/dai_readfg.cpp factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE) varset$(OE)
225
226 matlab/dai_writefg.$(ME) : matlab/dai_writefg.cpp $(HEADERS) factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE) varset$(OE)
227 $(MEX) $(MEXFLAGS) -o matlab/dai_writefg matlab/dai_writefg.cpp factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE) varset$(OE)
228
229 matlab/dai_potstrength.$(ME) : matlab/dai_potstrength.cpp $(HEADERS) matlab/matlab$(OE) exceptions$(OE) varset$(OE)
230 $(MEX) $(MEXFLAGS) -o matlab/dai_potstrength matlab/dai_potstrength.cpp matlab/matlab$(OE) exceptions$(OE) varset$(OE)
231
232 matlab/matlab$(OE) : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
233 $(MEX) $(MEXFLAGS) -outdir matlab -c matlab/matlab.cpp
234
235
236 # UTILS
237 ########
238
239 utils/createfg$(EE) : utils/createfg.cpp $(HEADERS) $(LIB)/libdai$(LE)
240 $(CC) $(CCFLAGS) /Feutils/createfg utils/createfg.cpp $(LIBS) $(BOOSTLIBS)
241
242 utils/fg2dot$(EE) : utils/fg2dot.cpp $(HEADERS) $(LIB)/libdai$(LE)
243 $(CC) $(CCFLAGS) /Feutils/fg2dot utils/fg2dot.cpp $(LIBS)
244
245 utils/fginfo$(EE) : utils/fginfo.cpp $(HEADERS) $(LIB)/libdai$(LE)
246 $(CC) $(CCFLAGS) /Feutils/fginfo utils/fginfo.cpp $(LIBS)