Fixed NAN related bugs for Visual C++.
[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 # For some reason, we have to set the library path, although it is in the environment
44 LIBS=/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"
45 # We use the BOOST Program Options library
46 BOOSTLIBS=/LIBPATH:C:\boost_1_36_0\stage\lib
47
48 # Compile using GNU C++ Compiler
49 CC=cl
50 OBJEXT=obj
51 LIBEXT=lib
52
53 # Flags for the C++ compiler
54 CCFLAGS=/I./include /IC:\boost_1_36_0 /EHsc /Ox
55 !IFDEF DEBUG
56 CCFLAGS=$(CCFLAGS) /Zi /DDAI_DEBUG
57 !ELSE
58 CCFLAGS=$(CCFLAGS)
59 !ENDIF
60
61 !IFDEF WINDOWS
62 CCFLAGS=$(CCFLAGS) /DWINDOWS
63 !ENDIF
64
65 !IFDEF WITH_BP
66 CCFLAGS=$(CCFLAGS) /DWITH_BP
67 OBJECTS=$(OBJECTS) bp.obj
68 !ENDIF
69 !IFDEF WITH_MF
70 CCFLAGS=$(CCFLAGS) /DWITH_MF
71 OBJECTS=$(OBJECTS) mf.obj
72 !ENDIF
73 !IFDEF WITH_HAK
74 CCFLAGS=$(CCFLAGS) /DWITH_HAK
75 OBJECTS=$(OBJECTS) hak.obj
76 !ENDIF
77 !IFDEF WITH_LC
78 CCFLAGS=$(CCFLAGS) /DWITH_LC
79 OBJECTS=$(OBJECTS) lc.obj
80 !ENDIF
81 !IFDEF WITH_TREEEP
82 CCFLAGS=$(CCFLAGS) /DWITH_TREEEP
83 OBJECTS=$(OBJECTS) treeep.obj
84 !ENDIF
85 !IFDEF WITH_JTREE
86 CCFLAGS=$(CCFLAGS) /DWITH_JTREE
87 OBJECTS=$(OBJECTS) jtree.obj
88 !ENDIF
89 !IFDEF WITH_MR
90 CCFLAGS=$(CCFLAGS) /DWITH_MR
91 OBJECTS=$(OBJECTS) mr.obj
92 !ENDIF
93
94 !IFDEF WITH_MATLAB
95 # Replace the following by the directory where Matlab has been installed
96 MATLABDIR = /opt/matlab/bin
97 # Replace the following with the extension of compiled MEX files on this platform, e.g. .mexglx for x86
98 MEXEXT = .mexglx
99 MEX = $(MATLABDIR)/mex
100 MEXFLAGS = -I.
101 !IFDEF DEBUG
102 MEXFLAGS = $(MEXFLAGS) -g /DDAI_DEBUG
103 !ENDIF
104 !IFDEF NEW_MATLAB
105 MEXFLAGS = $(MEXFLAGS) -largeArrayDims
106 !ELSE
107 MEXFLAGS = $(MEXFLAGS) /DSMALLMEM
108 !ENDIF
109 !ENDIF
110
111 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
112
113 TARGETS = tests utils $(LIB)/libdai.lib example.exe
114 # testregression disabled, it uses sh and awk
115 # doc disabled, it uses doxygen
116 !IFDEF WITH_MATLAB
117 TARGETS = $(TARGETS) matlabs
118 !ENDIF
119 all : $(TARGETS)
120
121 matlabs : matlab/dai.$(MEXEXT) matlab/dai_readfg.$(MEXEXT) matlab/dai_writefg.$(MEXEXT) matlab/dai_removeshortloops.$(MEXEXT) matlab/dai_potstrength.$(MEXEXT)
122
123 $(LIB)/libdai.lib : bipgraph.obj daialg.obj alldai.obj clustergraph.obj factorgraph.obj properties.obj regiongraph.obj util.obj weightedgraph.obj x2x.obj $(OBJECTS)
124 lib /out:$(LIB)/libdai.lib bipgraph.obj daialg.obj alldai.obj clustergraph.obj factorgraph.obj properties.obj regiongraph.obj util.obj weightedgraph.obj x2x.obj $(OBJECTS)
125
126 tests : tests/test.exe
127
128 utils : utils/createfg.exe utils/fg2dot.exe utils/remove_short_loops.exe utils/fginfo.exe
129
130 testregression : tests/test
131 echo Testing...this can take a while...
132 cd tests; time ./testregression; cd ..
133
134 doc : $(INC)/*.h $(SRC)/*.cpp doxygen.conf
135 doxygen doxygen.conf
136
137 clean :
138 del *.obj example.exe matlab\*.$(MEXEXT) matlab\*.obj tests\test.exe utils\fg2dot.exe utils\createfg.exe utils\remove_short_loops.exe utils\fginfo.exe $(LIB)\libdai.lib
139
140
141 bipgraph.obj : $(SRC)/bipgraph.cpp $(HEADERS)
142 $(CC) $(CCFLAGS) -c $(SRC)/bipgraph.cpp
143
144 daialg.obj : $(SRC)/daialg.cpp $(HEADERS)
145 $(CC) $(CCFLAGS) -c $(SRC)/daialg.cpp
146
147 bp.obj : $(SRC)/bp.cpp $(INC)/bp.h $(HEADERS)
148 $(CC) $(CCFLAGS) -c $(SRC)/bp.cpp
149
150 lc.obj : $(SRC)/lc.cpp $(INC)/lc.h $(HEADERS)
151 $(CC) $(CCFLAGS) -c $(SRC)/lc.cpp
152
153 mf.obj : $(SRC)/mf.cpp $(INC)/mf.h $(HEADERS)
154 $(CC) $(CCFLAGS) -c $(SRC)/mf.cpp
155
156 factorgraph.obj : $(SRC)/factorgraph.cpp $(INC)/factorgraph.h $(HEADERS)
157 $(CC) $(CCFLAGS) -c $(SRC)/factorgraph.cpp
158
159 util.obj : $(SRC)/util.cpp $(INC)/util.h $(HEADERS)
160 $(CC) $(CCFLAGS) -c $(SRC)/util.cpp
161
162 regiongraph.obj : $(SRC)/regiongraph.cpp $(INC)/regiongraph.h $(HEADERS)
163 $(CC) $(CCFLAGS) -c $(SRC)/regiongraph.cpp
164
165 hak.obj : $(SRC)/hak.cpp $(INC)/hak.h $(HEADERS) $(INC)/regiongraph.h
166 $(CC) $(CCFLAGS) -c $(SRC)/hak.cpp
167
168 clustergraph.obj : $(SRC)/clustergraph.cpp $(INC)/clustergraph.h $(HEADERS)
169 $(CC) $(CCFLAGS) -c $(SRC)/clustergraph.cpp
170
171 jtree.obj : $(SRC)/jtree.cpp $(INC)/jtree.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h
172 $(CC) $(CCFLAGS) -c $(SRC)/jtree.cpp
173
174 treeep.obj : $(SRC)/treeep.cpp $(INC)/treeep.h $(HEADERS) $(INC)/weightedgraph.h $(INC)/clustergraph.h $(INC)/regiongraph.h $(INC)/jtree.h
175 $(CC) $(CCFLAGS) -c $(SRC)/treeep.cpp
176
177 weightedgraph.obj : $(SRC)/weightedgraph.cpp $(INC)/weightedgraph.h $(HEADERS)
178 $(CC) $(CCFLAGS) -c $(SRC)/weightedgraph.cpp
179
180 mr.obj : $(SRC)/mr.cpp $(INC)/mr.h $(HEADERS)
181 $(CC) $(CCFLAGS) -c $(SRC)/mr.cpp
182
183 properties.obj : $(SRC)/properties.cpp $(HEADERS)
184 $(CC) $(CCFLAGS) -c $(SRC)/properties.cpp
185
186 alldai.obj : $(SRC)/alldai.cpp $(HEADERS)
187 $(CC) $(CCFLAGS) -c $(SRC)/alldai.cpp
188
189 x2x.obj : $(SRC)/x2x.cpp $(HEADERS)
190 $(CC) $(CCFLAGS) -c $(SRC)/x2x.cpp
191
192
193 # EXAMPLE
194 ##########
195
196 example.exe : example.cpp $(HEADERS) $(LIB)/libdai.lib
197 $(CC) $(CCFLAGS) /Feexample example.cpp /link $(LIB)/libdai.lib $(LIBS)
198
199
200 # TESTS
201 ########
202
203 tests/test.exe : tests/test.cpp $(HEADERS) $(LIB)/libdai.lib
204 $(CC) $(CCFLAGS) /Fetests/test tests/test.cpp /link $(LIB)/libdai.lib $(LIBS) $(BOOSTLIBS)
205
206
207 # MATLAB INTERFACE
208 ###################
209
210 matlab/dai.$(MEXEXT) : matlab/dai.cpp $(HEADERS) matlab/matlab.obj $(LIB)/libdai.lib
211 $(MEX) $(MEXFLAGS) -o matlab/dai matlab/dai.cpp matlab/matlab.obj $(LIB)/libdai.lib
212
213 matlab/dai_readfg.$(MEXEXT) : matlab/dai_readfg.cpp $(HEADERS) factorgraph.obj matlab/matlab.obj
214 $(MEX) $(MEXFLAGS) -o matlab/dai_readfg matlab/dai_readfg.cpp factorgraph.obj matlab/matlab.obj
215
216 matlab/dai_writefg.$(MEXEXT) : matlab/dai_writefg.cpp $(HEADERS) factorgraph.obj matlab/matlab.obj
217 $(MEX) $(MEXFLAGS) -o matlab/dai_writefg matlab/dai_writefg.cpp factorgraph.obj matlab/matlab.obj
218
219 matlab/dai_removeshortloops.$(MEXEXT) : matlab/dai_removeshortloops.cpp $(HEADERS) factorgraph.obj matlab/matlab.obj
220 $(MEX) $(MEXFLAGS) -o matlab/dai_removeshortloops matlab/dai_removeshortloops.cpp factorgraph.obj matlab/matlab.obj
221
222 matlab/dai_potstrength.$(MEXEXT) : matlab/dai_potstrength.cpp $(HEADERS) matlab/matlab.obj
223 $(MEX) $(MEXFLAGS) -o matlab/dai_potstrength matlab/dai_potstrength.cpp matlab/matlab.obj
224
225 matlab/matlab.obj : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
226 $(MEX) $(MEXFLAGS) -outdir matlab -c matlab/matlab.cpp
227
228
229 # UTILS
230 ########
231
232 utils/createfg.exe : utils/createfg.cpp $(HEADERS) factorgraph.obj weightedgraph.obj util.obj bipgraph.obj
233 $(CC) $(CCFLAGS) /Feutils/createfg utils/createfg.cpp factorgraph.obj weightedgraph.obj util.obj bipgraph.obj /link $(LIBS) $(BOOSTLIBS)
234
235 utils/fg2dot.exe : utils/fg2dot.cpp $(HEADERS) factorgraph.obj
236 $(CC) $(CCFLAGS) /Feutils/fg2dot utils/fg2dot.cpp factorgraph.obj /link $(LIBS)
237
238 utils/remove_short_loops.exe : utils/remove_short_loops.cpp $(HEADERS) factorgraph.obj
239 $(CC) $(CCFLAGS) /Feutils/remove_short_loops utils/remove_short_loops.cpp factorgraph.obj /link $(LIBS)
240
241 utils/fginfo.exe : utils/fginfo.cpp $(HEADERS) factorgraph.obj bipgraph.obj
242 $(CC) $(CCFLAGS) /Feutils/fginfo utils/fginfo.cpp factorgraph.obj bipgraph.obj /link $(LIBS)