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