Removed x2x
[libdai.git] / Makefile.win
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=true
33 # New/old matlab version?
34 NEW_MATLAB=true
35 # Windows or linux (default)?
36 WINDOWS=true
37
38 # Directories
39 INC=include/dai
40 SRC=src
41 LIB=lib
42
43 # Extensions (library, object, executable extensions)
44 LE=.lib
45 OE=.obj
46 EE=.exe
47
48 # Libraries (for some reason, we have to add the VC library path, although it is in the environment)
49 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"
50
51 # We use the BOOST Program Options library
52 BOOSTLIBS=/LIBPATH:C:\boost_1_36_0\stage\lib
53
54 # Compile using GNU C++ Compiler
55 CC=cl
56
57 # Flags for the C++ compiler
58 CCFLAGS=/I./include /IC:\boost_1_36_0 /EHsc /Ox
59 !IFDEF DEBUG
60 CCFLAGS=$(CCFLAGS) /Zi /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)/exceptions.h
115
116 TARGETS=tests utils $(LIB)/libdai$(LE) example$(EE)
117 # testregression disabled, it uses diff
118 # doc disabled, it uses doxygen
119 !IFDEF WITH_MATLAB
120 TARGETS = $(TARGETS) matlabs
121 !ENDIF
122 all : $(TARGETS)
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) $(OBJECTS)
127 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) $(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 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)
142
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
199 # EXAMPLE
200 ##########
201
202 example$(EE) : example.cpp $(HEADERS) $(LIB)/libdai$(LE)
203 $(CC) $(CCFLAGS) /Feexample example.cpp $(LIBS)
204
205
206 # TESTS
207 ########
208
209 tests/test$(EE) : tests/test.cpp $(HEADERS) $(LIB)/libdai$(LE)
210 $(CC) $(CCFLAGS) /Fetests/test tests/test.cpp $(LIBS) $(BOOSTLIBS)
211
212
213 # MATLAB INTERFACE
214 ###################
215
216 matlab/dai.$(ME) : matlab/dai.cpp $(HEADERS) matlab/matlab$(OE) $(LIB)/libdai$(LE)
217 $(MEX) $(MEXFLAGS) -o matlab/dai matlab/dai.cpp matlab/matlab$(OE) $(LIB)/libdai$(LE)
218
219 matlab/dai_readfg.$(ME) : matlab/dai_readfg.cpp $(HEADERS) factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
220 $(MEX) $(MEXFLAGS) -o matlab/dai_readfg matlab/dai_readfg.cpp factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
221
222 matlab/dai_writefg.$(ME) : matlab/dai_writefg.cpp $(HEADERS) factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
223 $(MEX) $(MEXFLAGS) -o matlab/dai_writefg matlab/dai_writefg.cpp factorgraph$(OE) matlab/matlab$(OE) exceptions$(OE)
224
225 matlab/dai_potstrength.$(ME) : matlab/dai_potstrength.cpp $(HEADERS) matlab/matlab$(OE) exceptions$(OE)
226 $(MEX) $(MEXFLAGS) -o matlab/dai_potstrength matlab/dai_potstrength.cpp matlab/matlab$(OE) exceptions$(OE)
227
228 matlab/matlab$(OE) : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
229 $(MEX) $(MEXFLAGS) -outdir matlab -c matlab/matlab.cpp
230
231
232 # UTILS
233 ########
234
235 utils/createfg$(EE) : utils/createfg.cpp $(HEADERS) $(LIB)/libdai$(LE)
236 $(CC) $(CCFLAGS) /Feutils/createfg utils/createfg.cpp $(LIBS) $(BOOSTLIBS)
237
238 utils/fg2dot$(EE) : utils/fg2dot.cpp $(HEADERS) $(LIB)/libdai$(LE)
239 $(CC) $(CCFLAGS) /Feutils/fg2dot utils/fg2dot.cpp $(LIBS)
240
241 utils/fginfo$(EE) : utils/fginfo.cpp $(HEADERS) $(LIB)/libdai$(LE)
242 $(CC) $(CCFLAGS) /Feutils/fginfo utils/fginfo.cpp $(LIBS)