Initial commit of libDAI-0.2.1
[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 # We use the BOOST Program Options library
22 BOOSTFLAGS = -lboost_program_options
23
24 # Compile using GNU C++ Compiler
25 CC = g++
26
27 # Flags for the C++ compiler
28 CCFLAGS = -Wall -fpic -g -DDEBUG -I. -I$(HOME)/include -O3 #-static #-pg #-DVERBOSE
29
30 # To enable the Matlab interface, define WITH_MATLAB = yes
31 WITH_MATLAB =
32 ifdef WITH_MATLAB
33 # Replace the following by the directory where Matlab has been installed
34 MATLABDIR = /opt/matlab/bin
35 MEX = $(MATLABDIR)/mex
36 MEXFLAGS = -g -I. -DDEBUG -largeArrayDims #-g means debugging
37 endif
38
39 # Replace the following with the extension of compiled MEX files on this platform, e.g. .mexglx for x86
40 MEXEXT = .mexglx
41
42 HEADERS = bipgraph.h diffs.h index.h var.h factor.h varset.h prob.h daialg.h properties.h alldai.h enum.h x2x.h
43
44 # target matlabs is disabled by default since it only compiles with a very recent MatLab version
45 TARGETS = tests utils libdai.a example testregression
46 ifdef WITH_MATLAB
47 TARGETS := $(TARGETS) matlabs
48 endif
49 all : $(TARGETS)
50 echo -e "\a"
51
52 matlabs : matlab/dai.$(MEXEXT) matlab/dai_readfg.$(MEXEXT) matlab/dai_writefg.$(MEXEXT) matlab/dai_removeshortloops.$(MEXEXT) matlab/dai_potstrength.$(MEXEXT)
53
54 libdai.a : daialg.o alldai.o bp.o clustergraph.o factorgraph.o hak.o jtree.o lc.o mf.o mr.o properties.o regiongraph.o util.o treeep.o weightedgraph.o x2x.o
55 ar rcs libdai.a daialg.o alldai.o bp.o clustergraph.o factorgraph.o hak.o jtree.o lc.o mf.o mr.o properties.o regiongraph.o util.o treeep.o weightedgraph.o x2x.o
56
57 tests : tests/test
58
59 utils : utils/createfg utils/fg2dot utils/remove_short_loops utils/fginfo
60
61 testregression : tests/test
62 echo Testing...this can take a while...
63 cd tests; ./testregression; cd ..
64
65 doc : *.h *.cpp doxygen.conf
66 doxygen doxygen.conf
67
68 clean :
69 rm *.o *.$(MEXEXT) example matlab/*.$(MEXEXT) matlab/*.o tests/test utils/fg2dot utils/createfg utils/remove_short_loops utils/fginfo libdai.a; echo
70 rm -R doc; echo
71
72
73 daialg.o : daialg.cpp $(HEADERS)
74 $(CC) $(CCFLAGS) -c daialg.cpp
75
76 bp.o : bp.cpp bp.h $(HEADERS)
77 $(CC) $(CCFLAGS) -c bp.cpp
78
79 lc.o : lc.cpp lc.h $(HEADERS)
80 $(CC) $(CCFLAGS) -c lc.cpp
81
82 mf.o : mf.cpp mf.h $(HEADERS)
83 $(CC) $(CCFLAGS) -c mf.cpp
84
85 factorgraph.o : factorgraph.cpp factorgraph.h $(HEADERS)
86 $(CC) $(CCFLAGS) -c factorgraph.cpp
87
88 util.o : util.cpp util.h $(HEADERS)
89 $(CC) $(CCFLAGS) -c util.cpp
90
91 regiongraph.o : regiongraph.cpp regiongraph.h $(HEADERS)
92 $(CC) $(CCFLAGS) -c regiongraph.cpp
93
94 hak.o : hak.cpp hak.h $(HEADERS) regiongraph.h
95 $(CC) $(CCFLAGS) -c hak.cpp
96
97 clustergraph.o : clustergraph.cpp clustergraph.h $(HEADERS)
98 $(CC) $(CCFLAGS) -c clustergraph.cpp
99
100 jtree.o : jtree.cpp jtree.h $(HEADERS) weightedgraph.h clustergraph.h regiongraph.h
101 $(CC) $(CCFLAGS) -c jtree.cpp
102
103 treeep.o : treeep.cpp treeep.h $(HEADERS) weightedgraph.h clustergraph.h regiongraph.h jtree.h
104 $(CC) $(CCFLAGS) -c treeep.cpp
105
106 weightedgraph.o : weightedgraph.cpp weightedgraph.h $(HEADERS)
107 $(CC) $(CCFLAGS) -c weightedgraph.cpp
108
109 mr.o : mr.cpp mr.h $(HEADERS)
110 $(CC) $(CCFLAGS) -c mr.cpp
111
112 properties.o : properties.cpp $(HEADERS)
113 $(CC) $(CCFLAGS) -c properties.cpp
114
115 alldai.o : alldai.cpp $(HEADERS)
116 $(CC) $(CCFLAGS) -c alldai.cpp
117
118 x2x.o : x2x.cpp $(HEADERS)
119 $(CC) $(CCFLAGS) -c x2x.cpp
120
121 # EXAMPLE
122 ##########
123
124 example : example.cpp $(HEADERS) libdai.a
125 $(CC) $(CCFLAGS) -o example example.cpp -L. libdai.a
126
127 # TESTS
128 ########
129
130 tests/test : tests/test.cpp $(HEADERS) libdai.a
131 $(CC) $(CCFLAGS) -o tests/test tests/test.cpp -L. -ldai $(BOOSTFLAGS)
132
133
134 # MATLAB INTERFACE
135 ###################
136
137 matlab/dai.$(MEXEXT) : matlab/dai.cpp $(HEADERS) matlab/matlab.o daialg.o alldai.o bp.o clustergraph.o factorgraph.o hak.o jtree.o lc.o mf.o mr.o properties.o regiongraph.o util.o treeep.o weightedgraph.o x2x.o
138 $(MEX) $(MEXFLAGS) -o matlab/dai matlab/dai.cpp matlab/matlab.o daialg.o alldai.o bp.o clustergraph.o factorgraph.o hak.o jtree.o lc.o mf.o mr.o properties.o regiongraph.o util.o treeep.o weightedgraph.o x2x.o
139
140 matlab/dai_readfg.$(MEXEXT) : matlab/dai_readfg.cpp $(HEADERS) factorgraph.o matlab/matlab.o
141 $(MEX) $(MEXFLAGS) -o matlab/dai_readfg matlab/dai_readfg.cpp factorgraph.o matlab/matlab.o
142
143 matlab/dai_writefg.$(MEXEXT) : matlab/dai_writefg.cpp $(HEADERS) factorgraph.o matlab/matlab.o
144 $(MEX) $(MEXFLAGS) -o matlab/dai_writefg matlab/dai_writefg.cpp factorgraph.o matlab/matlab.o
145
146 matlab/dai_removeshortloops.$(MEXEXT) : matlab/dai_removeshortloops.cpp $(HEADERS) factorgraph.o matlab/matlab.o
147 $(MEX) $(MEXFLAGS) -o matlab/dai_removeshortloops matlab/dai_removeshortloops.cpp factorgraph.o matlab/matlab.o
148
149 matlab/dai_potstrength.$(MEXEXT) : matlab/dai_potstrength.cpp $(HEADERS) matlab/matlab.o
150 $(MEX) $(MEXFLAGS) -o matlab/dai_potstrength matlab/dai_potstrength.cpp matlab/matlab.o
151
152 matlab/matlab.o : matlab/matlab.cpp matlab/matlab.h $(HEADERS)
153 $(MEX) $(MEXFLAGS) -outdir matlab -c matlab/matlab.cpp
154
155
156 # UTILS
157 ########
158
159 utils/createfg : utils/createfg.cpp $(HEADERS) factorgraph.o weightedgraph.o util.o
160 $(CC) $(CCFLAGS) -o utils/createfg utils/createfg.cpp factorgraph.o weightedgraph.o util.o $(BOOSTFLAGS)
161
162 utils/fg2dot : utils/fg2dot.cpp $(HEADERS) factorgraph.o
163 $(CC) $(CCFLAGS) -o utils/fg2dot utils/fg2dot.cpp factorgraph.o
164
165 utils/remove_short_loops : utils/remove_short_loops.cpp $(HEADERS) factorgraph.o
166 $(CC) $(CCFLAGS) -o utils/remove_short_loops utils/remove_short_loops.cpp factorgraph.o
167
168 utils/fginfo : utils/fginfo.cpp $(HEADERS) factorgraph.o
169 $(CC) $(CCFLAGS) -o utils/fginfo utils/fginfo.cpp factorgraph.o