672d80ca7f32bd1074c7531e38b108b1f13e0cb7
[libdai.git] / Makefile
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=
34 # New/old matlab version?
35 NEW_MATLAB=true
36 # Windows or linux (default)?
37 WINDOWS=
38
39 # Directories
40 INC=include/dai
41 SRC=src
42 LIB=lib
43
44 # Extensions (library, object, executable extensions)
45 LE=.a
46 OE=.o
47 EE=
48
49 # Libraries
50 LIBS=-ldai
51
52 # We use the BOOST Program Options library
53 BOOSTLIBS=-lboost_program_options
54
55 # Compile using GNU C++ Compiler
56 CC=g++
57 # Output filename option
58 CCO=-o
59
60 # Flags for the C++ compiler
61 CCFLAGS=-Wno-deprecated -Wall -W -Wextra -fpic -I./include -Llib -O3 #-pg
62 ifdef DEBUG
63 CCFLAGS:=$(CCFLAGS) -g -DDAI_DEBUG
64 endif
65
66 ifdef WINDOWS
67 CCFLAGS=$(CCFLAGS) -DWINDOWS
68 endif
69
70 OBJECTS:=exactinf$(OE)
71 ifdef WITH_BP
72 CCFLAGS:=$(CCFLAGS) -DWITH_BP
73 OBJECTS:=$(OBJECTS) bp$(OE)
74 endif
75 ifdef WITH_MF
76 CCFLAGS:=$(CCFLAGS) -DWITH_MF
77 OBJECTS:=$(OBJECTS) mf$(OE)
78 endif
79 ifdef WITH_HAK
80 CCFLAGS:=$(CCFLAGS) -DWITH_HAK
81 OBJECTS:=$(OBJECTS) hak$(OE)
82 endif
83 ifdef WITH_LC
84 CCFLAGS:=$(CCFLAGS) -DWITH_LC
85 OBJECTS:=$(OBJECTS) lc$(OE)
86 endif
87 ifdef WITH_TREEEP
88 CCFLAGS:=$(CCFLAGS) -DWITH_TREEEP
89 OBJECTS:=$(OBJECTS) treeep$(OE)
90 endif
91 ifdef WITH_JTREE
92 CCFLAGS:=$(CCFLAGS) -DWITH_JTREE
93 OBJECTS:=$(OBJECTS) jtree$(OE)
94 endif
95 ifdef WITH_MR
96 CCFLAGS:=$(CCFLAGS) -DWITH_MR
97 OBJECTS:=$(OBJECTS) mr$(OE)
98 endif
99
100 ifdef WITH_MATLAB
101 # Replace the following by the directory where Matlab has been installed
102 MATLABDIR=/opt/matlab/bin
103 # Replace the following with the extension of compiled MEX files on this platform, e.g. .mexglx for x86
104 ME=.mexglx
105 MEX=$(MATLABDIR)/mex
106 MEXFLAGS=-I.
107 ifdef DEBUG
108 MEXFLAGS:=$(MEXFLAGS) -g -DDAI_DEBUG
109 endif
110 ifdef NEW_MATLAB
111 MEXFLAGS:=$(MEXFLAGS) -largeArrayDims
112 else
113 MEXFLAGS:=$(MEXFLAGS) -DSMALLMEM
114 endif
115 endif
116
117 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
118
119 TARGETS=tests utils $(LIB)/libdai$(LE) example$(EE) testregression doc
120 ifdef WITH_MATLAB
121 TARGETS:=$(TARGETS) matlabs
122 endif
123 all : $(TARGETS)
124 echo -e "\a"
125
126 matlabs : matlab/dai.$(ME) matlab/dai_readfg.$(ME) matlab/dai_writefg.$(ME) matlab/dai_potstrength.$(ME)
127
128 $(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 -mkdir -p lib
130 ar rcus $(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)
131
132 tests : tests/testdai$(EE)
133
134 utils : utils/createfg$(EE) utils/fg2dot$(EE) utils/fginfo$(EE)
135
136 testregression : tests/testdai
137 @echo Starting regression test...this can take a minute or so!
138 cd tests; time ./testregression; cd ..
139
140 doc : $(INC)/*.h $(SRC)/*.cpp doxygen.conf
141 -mkdir -p doc
142 doxygen doxygen.conf
143
144 .PHONY : clean
145 clean :
146 -rm *$(OE)
147 -rm matlab/*.$(ME) matlab/*$(OE)
148 -rm example$(EE) tests/testdai$(EE) utils/fg2dot$(EE) utils/createfg$(EE) utils/fginfo$(EE)
149 -rm -R doc
150 -rm -R lib
151
152 include Makefile.shared