From 4a7b8bad27698bc7a54b38605144e3df14641f69 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Sun, 17 Oct 2010 17:06:28 +0000 Subject: [PATCH] --with-boost no longer required, automatically finding boost --- base/Makefile.am | 4 +- configure.ac | 19 ++- examples/Makefile.am | 3 +- examples/vSLAMexample/Makefile.am | 3 +- geometry/Makefile.am | 4 +- inference/Makefile.am | 4 +- linear/Makefile.am | 4 +- m4/ax_boost_base.m4 | 257 ++++++++++++++++++++++++++++++ nonlinear/Makefile.am | 4 +- slam/Makefile.am | 4 +- tests/Makefile.am | 4 +- wrap/Makefile.am | 6 +- 12 files changed, 287 insertions(+), 29 deletions(-) create mode 100644 m4/ax_boost_base.m4 diff --git a/base/Makefile.am b/base/Makefile.am index 9745ae33d..e5830c632 100644 --- a/base/Makefile.am +++ b/base/Makefile.am @@ -50,7 +50,7 @@ base_HEADERS = $(headers) noinst_LTLIBRARIES = libbase.la libbase_la_SOURCES = $(sources) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(DenseQRInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(DenseQRInc) -I$(top_srcdir)/.. if USE_BLAS AM_CPPFLAGS += -DGT_USE_CBLAS @@ -66,7 +66,7 @@ endif #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) AM_DEFAULT_SOURCE_EXT = .cpp -AM_LDFLAGS = $(BOOST_LDFLAGS) $(boost_serialization) -L$(CCOLAMDLib) -lccolamd +AM_LDFLAGS = $(boost_serialization) -L$(CCOLAMDLib) -lccolamd LDADD = libbase.la ../CppUnitLite/libCppUnitLite.a if USE_BLAS_LINUX diff --git a/configure.ac b/configure.ac index ee5137e34..402edbc53 100644 --- a/configure.ac +++ b/configure.ac @@ -130,6 +130,9 @@ AC_TYPE_SIZE_T AC_FUNC_ERROR_AT_LINE AC_CHECK_FUNCS([pow sqrt]) +# Check for boost +AX_BOOST_BASE([1.40]) + # ask for toolbox directory AC_ARG_WITH([toolbox], [AS_HELP_STRING([--with-toolbox], @@ -141,14 +144,14 @@ AC_ARG_WITH([toolbox], AC_SUBST([toolbox]) # ask for boost directory -AC_ARG_WITH([boost], - [AS_HELP_STRING([--with-boost], - [specify the boost directory for installation (mandatory)])], - [boost=$withval], - [AC_MSG_FAILURE( - [--with-boost has to be specified]) - ]) -AC_SUBST([boost]) +#AC_ARG_WITH([boost], +# [AS_HELP_STRING([--with-boost], +# [specify the boost directory for installation (mandatory)])], +# [boost=$withval], +# [AC_MSG_FAILURE( +# [--with-boost has to be specified]) +# ]) +#AC_SUBST([boost]) # ask for ccolamd library include directory AC_ARG_WITH([ccolamd-inc], diff --git a/examples/Makefile.am b/examples/Makefile.am index cc5492be5..c84443b2f 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -19,8 +19,7 @@ noinst_PROGRAMS += PlanarSLAMSelfContained # Solves SLAM example from tutorial #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- -AM_LDFLAGS = $(BOOST_LDFLAGS) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(top_srcdir)/.. LDADD = ../libgtsam.la AM_DEFAULT_SOURCE_EXT = .cpp diff --git a/examples/vSLAMexample/Makefile.am b/examples/vSLAMexample/Makefile.am index fa254de8b..d851746b1 100644 --- a/examples/vSLAMexample/Makefile.am +++ b/examples/vSLAMexample/Makefile.am @@ -17,8 +17,7 @@ vSLAMexample_SOURCES = vSLAMexample.cpp Feature2D.cpp landmarkUtils.cpp #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- -AM_LDFLAGS = $(BOOST_LDFLAGS) -AM_CPPFLAGS = -I$(boost) -I$(SparseInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(SparseInc) -I$(top_srcdir)/.. LDADD = ../../libgtsam.la AM_DEFAULT_SOURCE_EXT = .cpp diff --git a/geometry/Makefile.am b/geometry/Makefile.am index 4f52cde2d..fe4211333 100644 --- a/geometry/Makefile.am +++ b/geometry/Makefile.am @@ -41,13 +41,13 @@ geometrydir = $(pkgincludedir)/geometry geometry_HEADERS = $(headers) noinst_LTLIBRARIES = libgeometry.la libgeometry_la_SOURCES = $(sources) -AM_CPPFLAGS = -I$(boost) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(top_srcdir)/.. #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) -AM_LDFLAGS = $(BOOST_LDFLAGS) $(boost_serialization) +AM_LDFLAGS = $(boost_serialization) LDADD = libgeometry.la ../base/libbase.la ../CppUnitLite/libCppUnitLite.a AM_DEFAULT_SOURCE_EXT = .cpp diff --git a/inference/Makefile.am b/inference/Makefile.am index f5c475e0b..c7f08255f 100644 --- a/inference/Makefile.am +++ b/inference/Makefile.am @@ -63,14 +63,14 @@ inferencedir = $(pkgincludedir)/inference inference_HEADERS = $(headers) noinst_LTLIBRARIES = libinference.la libinference_la_SOURCES = $(sources) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(top_srcdir)/.. AM_CXXFLAGS = #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) -AM_LDFLAGS = $(BOOST_LDFLAGS) $(boost_serialization) +AM_LDFLAGS = $(boost_serialization) LDADD = libinference.la ../base/libbase.la LDADD += ../CppUnitLite/libCppUnitLite.a AM_DEFAULT_SOURCE_EXT = .cpp diff --git a/linear/Makefile.am b/linear/Makefile.am index 30b5282bd..8512567a8 100644 --- a/linear/Makefile.am +++ b/linear/Makefile.am @@ -51,14 +51,14 @@ lineardir = $(pkgincludedir)/linear linear_HEADERS = $(headers) noinst_LTLIBRARIES = liblinear.la liblinear_la_SOURCES = $(sources) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(DenseQRInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(DenseQRInc) -I$(top_srcdir)/.. AM_CXXFLAGS = #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) -AM_LDFLAGS = $(BOOST_LDFLAGS) $(boost_serialization) +AM_LDFLAGS = $(boost_serialization) LDADD = liblinear.la ../inference/libinference.la ../base/libbase.la LDADD += ../CppUnitLite/libCppUnitLite.a AM_DEFAULT_SOURCE_EXT = .cpp diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4 new file mode 100644 index 000000000..ec23a0abb --- /dev/null +++ b/m4/ax_boost_base.m4 @@ -0,0 +1,257 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# DESCRIPTION +# +# Test for the Boost C++ libraries of a particular version (or newer) +# +# If no path to the installed boost library is given the macro searchs +# under /usr, /usr/local, /opt and /opt/local and evaluates the +# $BOOST_ROOT environment variable. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) +# +# And sets: +# +# HAVE_BOOST +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# Copyright (c) 2009 Peter Adolphs +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 18 + +AC_DEFUN([AX_BOOST_BASE], +[ +AC_ARG_WITH([boost], + [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], + [use Boost library from a standard location (ARG=yes), + from the specified location (ARG=), + or disable it (ARG=no) + @<:@ARG=yes@:>@ ])], + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ac_boost_path="" + else + want_boost="yes" + ac_boost_path="$withval" + fi + ], + [want_boost="yes"]) + + +AC_ARG_WITH([boost-libdir], + AS_HELP_STRING([--with-boost-libdir=LIB_DIR], + [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), + [ + if test -d "$withval" + then + ac_boost_lib_path="$withval" + else + AC_MSG_ERROR(--with-boost-libdir expected directory name) + fi + ], + [ac_boost_lib_path=""] +) + +if test "x$want_boost" = "xyes"; then + boost_lib_version_req=ifelse([$1], ,1.20.0,$1) + boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` + boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` + boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` + boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + if test "x$boost_lib_version_req_sub_minor" = "x" ; then + boost_lib_version_req_sub_minor="0" + fi + WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` + AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) + succeeded=no + + dnl On x86_64 systems check for system libraries in both lib64 and lib. + dnl The former is specified by FHS, but e.g. Debian does not adhere to + dnl this (as it rises problems for generic multi-arch support). + dnl The last entry in the list is chosen by default when no libraries + dnl are found, e.g. when only header-only libraries are installed! + libsubdirs="lib" + if test `uname -m` = x86_64; then + libsubdirs="lib64 lib lib64" + fi + + dnl first we check the system location for boost libraries + dnl this location ist chosen if boost libraries are installed with the --layout=system option + dnl or if you install boost with RPM + if test "$ac_boost_path" != ""; then + BOOST_CPPFLAGS="-I$ac_boost_path/include" + for ac_boost_path_tmp in $libsubdirs; do + if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then + BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" + break + fi + done + elif test "$cross_compiling" != yes; then + for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then + for libsubdir in $libsubdirs ; do + if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" + BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" + break; + fi + done + fi + + dnl overwrite ld flags if we have required special directory with + dnl --with-boost-libdir parameter + if test "$ac_boost_lib_path" != ""; then + BOOST_LDFLAGS="-L$ac_boost_lib_path" + fi + + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_REQUIRE([AC_PROG_CXX]) + AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= $WANT_BOOST_VERSION + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + succeeded=yes + found_system=yes + ],[ + ]) + AC_LANG_POP([C++]) + + + + dnl if we found no boost with system layout we search for boost libraries + dnl built and installed without the --layout=system option or for a staged(not installed) version + if test "x$succeeded" != "xyes"; then + _version=0 + if test "$ac_boost_path" != ""; then + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + V_CHECK=`expr $_version_tmp \> $_version` + if test "$V_CHECK" = "1" ; then + _version=$_version_tmp + fi + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` + BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" + done + fi + else + if test "$cross_compiling" != yes; then + for ac_boost_path in /usr /usr/local /opt /opt/local ; do + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + V_CHECK=`expr $_version_tmp \> $_version` + if test "$V_CHECK" = "1" ; then + _version=$_version_tmp + best_path=$ac_boost_path + fi + done + fi + done + + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` + BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" + if test "$ac_boost_lib_path" = ""; then + for libsubdir in $libsubdirs ; do + if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$best_path/$libsubdir" + fi + fi + + if test "x$BOOST_ROOT" != "x"; then + for libsubdir in $libsubdirs ; do + if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then + version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` + stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` + stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` + V_CHECK=`expr $stage_version_shorten \>\= $_version` + if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then + AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) + BOOST_CPPFLAGS="-I$BOOST_ROOT" + BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" + fi + fi + fi + fi + + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= $WANT_BOOST_VERSION + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + succeeded=yes + found_system=yes + ],[ + ]) + AC_LANG_POP([C++]) + fi + + if test "$succeeded" != "yes" ; then + if test "$_version" = "0" ; then + AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) + else + AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) + fi + # execute ACTION-IF-NOT-FOUND (if present): + ifelse([$3], , :, [$3]) + else + AC_SUBST(BOOST_CPPFLAGS) + AC_SUBST(BOOST_LDFLAGS) + AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) + # execute ACTION-IF-FOUND (if present): + ifelse([$2], , :, [$2]) + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" +fi + +]) diff --git a/nonlinear/Makefile.am b/nonlinear/Makefile.am index 34f38e543..d00b6cff4 100644 --- a/nonlinear/Makefile.am +++ b/nonlinear/Makefile.am @@ -38,14 +38,14 @@ nonlineardir = $(pkgincludedir)/nonlinear nonlinear_HEADERS = $(headers) noinst_LTLIBRARIES = libnonlinear.la libnonlinear_la_SOURCES = $(sources) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(top_srcdir)/.. AM_CXXFLAGS = #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) -AM_LDFLAGS = $(BOOST_LDFLAGS) $(boost_serialization) +AM_LDFLAGS = $(boost_serialization) LDADD = libnonlinear.la ../linear/liblinear.la ../inference/libinference.la ../base/libbase.la LDADD += ../CppUnitLite/libCppUnitLite.a AM_DEFAULT_SOURCE_EXT = .cpp diff --git a/slam/Makefile.am b/slam/Makefile.am index 7d0563e44..9f8236254 100644 --- a/slam/Makefile.am +++ b/slam/Makefile.am @@ -59,14 +59,14 @@ slamdir = $(pkgincludedir)/slam slam_HEADERS = $(headers) noinst_LTLIBRARIES = libslam.la libslam_la_SOURCES = $(sources) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(top_srcdir)/.. +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(top_srcdir)/.. #---------------------------------------------------------------------------------------------------- # rules to build local programs #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) AM_DEFAULT_SOURCE_EXT = .cpp -AM_LDFLAGS = $(BOOST_LDFLAGS) $(boost_serialization) -L$(CCOLAMDLib) -lccolamd +AM_LDFLAGS = $(boost_serialization) -L$(CCOLAMDLib) -lccolamd LDADD = libslam.la ../geometry/libgeometry.la ../nonlinear/libnonlinear.la ../linear/liblinear.la ../inference/libinference.la ../base/libbase.la LDADD += ../CppUnitLite/libCppUnitLite.a diff --git a/tests/Makefile.am b/tests/Makefile.am index 128427a3b..8c2dae5d7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -32,8 +32,8 @@ noinst_PROGRAMS = timeGaussianFactorGraph timeLinearOnDataset # rules to build unit tests #---------------------------------------------------------------------------------------------------- TESTS = $(check_PROGRAMS) -AM_CPPFLAGS = -I$(boost) -I$(CCOLAMDInc) -I$(top_srcdir)/.. -AM_LDFLAGS = $(BOOST_LDFLAGS) +AM_LDFLAGS = +AM_CPPFLAGS = -I$(CCOLAMDInc) -I$(top_srcdir)/.. if USE_ACCELERATE_MACOS AM_LDFLAGS += -Wl,/System/Library/Frameworks/Accelerate.framework/Accelerate diff --git a/wrap/Makefile.am b/wrap/Makefile.am index c5d793b31..8cd6ef967 100644 --- a/wrap/Makefile.am +++ b/wrap/Makefile.am @@ -9,7 +9,7 @@ interfacePath = $(top_srcdir) moduleName = gtsam toolboxpath = ../toolbox nameSpace = "gtsam" -mexFlags = "-I${boost} -I${prefix}/include -I${prefix}/include/gtsam -L${exec_prefix}/lib -lgtsam" +mexFlags = "${BOOST_CPPFLAGS} -I${prefix}/include -I${prefix}/include/gtsam -L${exec_prefix}/lib -lgtsam" all: ./wrap ${interfacePath} ${moduleName} ${toolboxpath} ${nameSpace} ${mexFlags} @@ -18,9 +18,9 @@ noinst_HEADERS = geometry.h utilities.h Argument.h Constructor.h Method.h Class. noinst_PROGRAMS = wrap wrap_SOURCES = ${common} wrap.cpp -AM_CPPFLAGS = -I$(boost) -I$(top_srcdir)/.. -DTOPSRCDIR="\"$(top_srcdir)\"" +AM_CPPFLAGS = -I$(top_srcdir)/.. -DTOPSRCDIR="\"$(top_srcdir)\"" AM_CXXFLAGS = -MMD -AM_LDFLAGS = -L../CppUnitLite -lCppUnitLite $(BOOST_LDFLAGS) +AM_LDFLAGS = -L../CppUnitLite -lCppUnitLite TESTS = $(check_PROGRAMS)