# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# Choose OS from {LINUX, WINDOWS, CYGWIN, MACOSX}
-# LINUX: GNU/Linux and other UNIX variants
-# WINDOWS: Visual C++ with GNU Make
-# CYGWIN: CygWin
-# MACOSX: MacOSX
-OS=LINUX
-
-# Enable/disable various approximate inference methods
-WITH_BP=true
-WITH_MF=true
-WITH_HAK=true
-WITH_LC=true
-WITH_TREEEP=true
-WITH_JTREE=true
-WITH_MR=true
-WITH_GIBBS=true
-
-# Build with debug info?
-DEBUG=true
-
-# Build matlab interface?
-WITH_MATLAB=
-# New/old matlab version?
-NEW_MATLAB=true
-
-# Directories
-# Location libDAI headers
+# Load the local configuration from Makefile.conf
+include Makefile.conf
+
+# Directories of libDAI sources
+# Location libDAI headers
INC=include/dai
-# Location of libDAI source files
+# Location of libDAI source files
SRC=src
-# Destination directory of libDAI library
+# Destination directory of libDAI library
LIB=lib
-# Additional iclude paths for C compiler
-CCINC=-Iinclude
-
-# Extensions (library, object, executable, matlab compiled MEX file)
-ifneq ($(OS),WINDOWS)
- LE=.a
- OE=.o
- EE=
- ME=.mexglx
-else
- LE=.lib
- OE=.obj
- EE=.exe
- ME=.mexglx
-endif
-
-# Libraries
-ifneq ($(OS),WINDOWS)
- LIBS=-ldai
- # Additional library paths for linker
- CCLIB=-Llib
-else
- # For some reason, we have to add the VC library path, although it is in the environment
- 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"
-endif
-
-# Tell the linker to link with the BOOST Program Options library
-ifeq ($(OS),CYGWIN)
- BOOSTLIBS=-lboost_program_options-gcc34-mt
-endif
-ifeq ($(OS),MACOSX)
- BOOSTLIBS=-lboost_program_options-mt
-endif
-ifeq ($(OS),LINUX)
- BOOSTLIBS=-lboost_program_options-mt
-endif
-ifeq ($(OS),WINDOWS)
- BOOSTLIBS=/LIBPATH:C:\boost_1_36_0\stage\lib
-endif
-
-# Compiler specific options
-ifneq ($(OS),WINDOWS)
- # Compile using GNU C++ Compiler
- CC=g++
- # Output filename option of the compiler
- CCO=-o
-else
- # Compile using Visual C++ Compiler
- CC=cl
- # Output filename option
- CCO=/Fe
-endif
-
-# Flags for the C++ compiler
-ifneq ($(OS),WINDOWS)
- CCFLAGS=-O3 -Wno-deprecated -Wall -W -Wextra -fpic
- CCDEBUGFLAGS=-g -DDAI_DEBUG
-else
- CCFLAGS=/Iinclude /IC:\boost_1_36_0 /EHsc /Ox
- CCDEBUGFLAGS=/Zi -DDAI_DEBUG
-endif
-
-ifeq ($(OS),CYGWIN)
- CCINC:=$(CCINC) -I/usr/local/include/boost-1_37
- # dynamic linking of Boost libraries seems not to work on Cygwin
- CCFLAGS:=$(CCFLAGS) -DCYGWIN -static
-endif
-ifeq ($(OS),MACOSX)
- # indicate where your boost headers and libraries are (likely where macports installs libraries)
- CCINC:=$(CCINC) -I/opt/local/include
- CCLIB:=$(CCLIB) -L/opt/local/lib
-endif
-# Build targets
+# Define build targets
TARGETS=tests utils lib examples testregression
-ifneq ($(OS),WINDOWS)
+ifdef WITH_DOC
TARGETS:=$(TARGETS) doc
endif
-
-ifdef WITH_MATLAB
- ifneq ($(OS),WINDOWS)
- # Replace the following by the directory where Matlab has been installed
- MATLABDIR=/agbs/share/sw/matlab
- MEX=$(MATLABDIR)/bin/mex
- MEXFLAGS=CXX\#$(CC) CXXFLAGS\#'$(CCFLAGS)'
- else
- # Replace the following by the directory where Matlab has been installed
- MATLABDIR=c:\matlab
- MEX=$(MATLABDIR)\bin\mex
- MEXFLAGS=-Iinclude CXX\#$(CC) CXXFLAGS\#"/EHsc /Ox"
- endif
-endif
-
-
-ifdef DEBUG
- CCFLAGS:=$(CCFLAGS) $(CCDEBUGFLAGS)
-endif
-ifeq ($(OS),WINDOWS)
- CCFLAGS:=$(CCFLAGS) -DWINDOWS
-endif
ifdef WITH_MATLAB
TARGETS:=$(TARGETS) matlabs
ifdef NEW_MATLAB
endif
endif
-
+# Define conditional build targets
OBJECTS:=exactinf$(OE)
ifdef WITH_BP
CCFLAGS:=$(CCFLAGS) -DDAI_WITH_BP
OBJECTS:=$(OBJECTS) gibbs$(OE)
endif
-
+# Define standard libDAI header dependencies
HEADERS=$(INC)/bipgraph.h $(INC)/index.h $(INC)/var.h $(INC)/factor.h $(INC)/varset.h $(INC)/smallset.h $(INC)/prob.h $(INC)/daialg.h $(INC)/properties.h $(INC)/alldai.h $(INC)/enum.h $(INC)/exceptions.h
-
-CC:=$(CC) $(CCINC) $(CCLIB) $(CCFLAGS)
+# Setup final command for C++ compiler and MEX
+ifdef DEBUG
+ CCFLAGS:=$(CCFLAGS) $(CCDEBUGFLAGS)
+endif
+ifneq ($(OS),WINDOWS)
+ CC:=$(CC) $(CCINC) $(CCFLAGS) $(CCLIB)
+else
+ CC:=$(CC) $(CCINC) $(CCFLAGS)
+ LIBS:=$(LIBS) $(CCLIB)
+endif
MEX:=$(MEX) $(CCLIB) $(CCINC) $(MEXFLAGS)
--- /dev/null
+# This template contains configurations for compiling libDAI under CygWin
+#
+# To use it, simply copy this file to 'Makefile.conf' and adapt 'Makefile.conf'
+# to your local setup
+#
+# A boolean variable VAR can be set to true ("VAR=true") or to false ("VAR=")
+
+# COMPILATION AND BUILD FLAGS
+# Enable/disable various approximate inference methods
+WITH_BP=true
+WITH_MF=true
+WITH_HAK=true
+WITH_LC=true
+WITH_TREEEP=true
+WITH_JTREE=true
+WITH_MR=true
+WITH_GIBBS=true
+# Build doxygen documentation?
+WITH_DOC=true
+# Build with debug info?
+DEBUG=true
+# Build matlab interface?
+WITH_MATLAB=
+# New/old matlab version?
+NEW_MATLAB=true
+
+# OPERATING SYSTEM
+# Choose OS from {LINUX, WINDOWS, CYGWIN, MACOSX}
+OS=CYGWIN
+
+# FILE EXTENSIONS
+# Static library
+LE=.a
+# Object file
+OE=.o
+# Binary executable
+EE=
+# MatLab compiled MEX file
+ME=.mexglx
+
+# COMPILER
+# Compile using GNU C++ Compiler
+CC=g++
+# Output filename option of the compiler
+CCO=-o
+# Flags for the C++ compiler
+# (dynamic linking of Boost libraries seems not to work on Cygwin)
+CCFLAGS=-O3 -Wno-deprecated -Wall -W -Wextra -DCYGWIN -static
+# Flags to add in debugging mode (if DEBUG=true)
+CCDEBUGFLAGS=-g -DDAI_DEBUG
+# Standard include directories
+CCINC=-Iinclude -I/usr/local/include/boost-1_37
+
+# LINKER
+# Standard libraries to include
+LIBS=-ldai
+# For linking with the BOOST Program Options library
+BOOSTLIBS=-lboost_program_options-gcc34-mt
+# Additional library search paths for linker
+CCLIB=-Llib
+
+# MATLAB
+# Replace the following by the directory where MatLab has been installed
+MATLABDIR=/agbs/share/sw/matlab
+# The following should resolve to the MatLab mex compile command
+MEX=$(MATLABDIR)/bin/mex
+# Specify the same C++ compiler and flags to mex
+MEXFLAGS=CXX\#$(CC) CXXFLAGS\#'$(CCFLAGS)'
--- /dev/null
+# This template contains configurations for compiling libDAI under GNU/Linux
+# and other UNIX variants
+#
+# To use it, simply copy this file to 'Makefile.conf' and adapt 'Makefile.conf'
+# to your local setup
+#
+# A boolean variable VAR can be set to true ("VAR=true") or to false ("VAR=")
+
+# COMPILATION AND BUILD FLAGS
+# Enable/disable various approximate inference methods
+WITH_BP=true
+WITH_MF=true
+WITH_HAK=true
+WITH_LC=true
+WITH_TREEEP=true
+WITH_JTREE=true
+WITH_MR=true
+WITH_GIBBS=true
+# Build doxygen documentation?
+WITH_DOC=true
+# Build with debug info?
+DEBUG=true
+# Build matlab interface?
+WITH_MATLAB=
+# New/old matlab version?
+NEW_MATLAB=true
+
+# OPERATING SYSTEM
+# Choose OS from {LINUX, WINDOWS, CYGWIN, MACOSX}
+OS=LINUX
+
+# FILE EXTENSIONS
+# Static library
+LE=.a
+# Object file
+OE=.o
+# Binary executable
+EE=
+# MatLab compiled MEX file
+ME=.mexglx
+
+# COMPILER
+# Compile using GNU C++ Compiler
+CC=g++
+# Output filename option of the compiler
+CCO=-o
+# Flags for the C++ compiler
+CCFLAGS=-O3 -Wno-deprecated -Wall -W -Wextra -fpic
+# Flags to add in debugging mode (if DEBUG=true)
+CCDEBUGFLAGS=-g -DDAI_DEBUG
+# Standard include directories
+CCINC=-Iinclude
+
+# LINKER
+# Standard libraries to include
+LIBS=-ldai
+# For linking with the BOOST Program Options library
+BOOSTLIBS=-lboost_program_options-mt
+# Additional library search paths for linker
+CCLIB=-Llib
+
+# MATLAB
+# Replace the following by the directory where MatLab has been installed
+MATLABDIR=/agbs/share/sw/matlab
+# The following should resolve to the MatLab mex compile command
+MEX=$(MATLABDIR)/bin/mex
+# Specify the same C++ compiler and flags to mex
+MEXFLAGS=CXX\#$(CC) CXXFLAGS\#'$(CCFLAGS)'
--- /dev/null
+# This template contains configurations for compiling libDAI under Mac OS X
+#
+# To use it, simply copy this file to 'Makefile.conf' and adapt 'Makefile.conf'
+# to your local setup
+#
+# A boolean variable VAR can be set to true ("VAR=true") or to false ("VAR=")
+
+# COMPILATION AND BUILD FLAGS
+# Enable/disable various approximate inference methods
+WITH_BP=true
+WITH_MF=true
+WITH_HAK=true
+WITH_LC=true
+WITH_TREEEP=true
+WITH_JTREE=true
+WITH_MR=true
+WITH_GIBBS=true
+# Build doxygen documentation?
+WITH_DOC=true
+# Build with debug info?
+DEBUG=true
+# Build matlab interface?
+WITH_MATLAB=
+# New/old matlab version?
+NEW_MATLAB=true
+
+# OPERATING SYSTEM
+# Choose OS from {LINUX, WINDOWS, CYGWIN, MACOSX}
+OS=MACOSX
+
+# FILE EXTENSIONS
+# Static library
+LE=.a
+# Object file
+OE=.o
+# Binary executable
+EE=
+# MatLab compiled MEX file
+ME=.mexglx
+
+# COMPILER
+# Compile using GNU C++ Compiler
+CC=g++
+# Output filename option of the compiler
+CCO=-o
+# Flags for the C++ compiler
+CCFLAGS=-O3 -Wno-deprecated -Wall -W -Wextra -fpic
+# Flags to add in debugging mode (if DEBUG=true)
+CCDEBUGFLAGS=-g -DDAI_DEBUG
+# Standard include directories
+CCINC=-Iinclude -I/opt/local/include
+
+# LINKER
+# Standard libraries to include
+LIBS=-ldai
+# For linking with the BOOST Program Options library
+BOOSTLIBS=-lboost_program_options-mt
+# Additional library search paths for linker
+CCLIB=-Llib -L/opt/local/lib
+
+# MATLAB
+# Replace the following by the directory where MatLab has been installed
+MATLABDIR=/agbs/share/sw/matlab
+# The following should resolve to the MatLab mex compile command
+MEX=$(MATLABDIR)/bin/mex
+# Specify the same C++ compiler and flags to mex
+MEXFLAGS=CXX\#$(CC) CXXFLAGS\#'$(CCFLAGS)'
--- /dev/null
+# This template contains configurations for compiling libDAI with Visual C++
+# under Windows (and GNU Make)
+#
+# To use it, simply copy this file to 'Makefile.conf' and adapt 'Makefile.conf'
+# to your local setup
+#
+# A boolean variable VAR can be set to true ("VAR=true") or to false ("VAR=")
+
+# COMPILATION AND BUILD FLAGS
+# Enable/disable various approximate inference methods
+WITH_BP=true
+WITH_MF=true
+WITH_HAK=true
+WITH_LC=true
+WITH_TREEEP=true
+WITH_JTREE=true
+WITH_MR=true
+WITH_GIBBS=true
+# Build doxygen documentation?
+WITH_DOC=
+# Build with debug info?
+DEBUG=true
+# Build matlab interface?
+WITH_MATLAB=
+# New/old matlab version?
+NEW_MATLAB=true
+
+# OPERATING SYSTEM
+# Choose OS from {LINUX, WINDOWS, CYGWIN, MACOSX}
+OS=WINDOWS
+
+# FILE EXTENSIONS
+# Static library
+LE=.lib
+# Object file
+OE=.obj
+# Binary executable
+EE=.exe
+# MatLab compiled MEX file
+ME=.mexglx
+
+# COMPILER
+# Compile using Visual C++ Compiler
+CC=cl
+# Output filename option of the compiler
+CCO=/Fe
+# Flags for the C++ compiler
+CCFLAGS=/EHsc /Ox -DWINDOWS
+# Flags to add in debugging mode (if DEBUG=true)
+CCDEBUGFLAGS=/Zi -DDAI_DEBUG
+# Standard include directories
+CCINC=/Iinclude /IC:\boost_1_36_0
+
+# LINKER
+# Standard libraries to include
+LIBS=/link $(LIB)/libdai$(LE)
+# For linking with the BOOST Program Options library
+BOOSTLIBS=/LIBPATH:C:\boost_1_36_0\stage\lib
+# Additional library search paths for linker
+# (For some reason, we have to add the VC library path, although it is in the environment)
+CCLIB=/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"
+
+# MATLAB
+# Replace the following by the directory where MatLab has been installed
+MATLABDIR=c:\matlab
+# The following should resolve to the MatLab mex compile command
+MEX=$(MATLABDIR)\bin\mex
+# Specify the same C++ compiler and flags to mex
+MEXFLAGS=CXX\#$(CC) CXXFLAGS\#"$(CCFLAGS)"
Claudio Lima
Jiuxiang Hu
Peter Gober
+Patrick Pletscher
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
-SCIENTISTS: please be aware that the fact that this program is released as Free
-Software does not excuse you from scientific propriety, which obligates you to
-give appropriate credit. If you write a scientific paper describing research
-that made substantive use of this program, it is your moral obligation as a
-scientist to (a) mention the fashion in which this software was used, including
-the version number, with a citation to the literature, to allow replication;
-(b) mention this software in the Acknowledgements section. The appropriate
-citation is:
+SCIENTISTS: If you write a scientific paper describing research that made
+substantive use of this program, please (a) mention the fashion in which
+this software was used, including the version number, with a citation
+to the literature, to allow replication; (b) mention this software in the
+Acknowledgements section. The appropriate citation is:
J. M. Mooij (2008) "libDAI 0.2.2: A free/open source C++ library for Discrete
Approximate Inference methods", http://mloss.org/software/view/77/.
- GNU make
- doxygen
- graphviz
-- recent boost C++ libraries (at least version 1.34 or 1.37 for cygwin)
+- recent boost C++ libraries (at least version 1.34, or 1.37 for cygwin)
On Debian/Ubuntu, you can easily install all these packages with a single command:
"apt-get install g++ make doxygen graphviz libboost-dev libboost-graph-dev libboost-program-options-dev"
make install
-To build the libDAI source, edit the Makefile and adapt it to your local setup.
-At least one should specify the OS and possibly adapt some directories to match
-the local setup. Then, run
+To build the libDAI source, first copy a template Makefile.* to Makefile.conf
+(for example, copy Makefile.LINUX to Makefile.conf if you use GNU/Linux).
+Then, edit the Makefile.conf template to adapt it to your local setup.
+Especially directories may change from system to system. Finally, run
make
For the regression test, you need:
- GNU diff, GNU sed (can be obtained from http://gnuwin32.sourceforge.net)
-To build the source, edit the Makefile and adapt it to your local setup. Then, run (from the command line)
+To build the source, copy Makefile.WINDOWS to Makefile.conf. Then, edit
+Makefile.conf to adapt it to your local setup. Finally, run (from the command line)
- make -f Makefile.win
+ make
If the build was successful, you can test the example program: