1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_boost_serialization.html
3 # ===========================================================================
7 # AX_BOOST_SERIALIZATION
11 # Test for Serialization library from the Boost C++ libraries. The macro
12 # requires a preceding call to AX_BOOST_BASE. Further documentation is
13 # available at <http://randspringer.de/boost/index.html>.
17 # AC_SUBST(BOOST_SERIALIZATION_LIB)
21 # HAVE_BOOST_SERIALIZATION
29 # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
31 # Copying and distribution of this file, with or without modification, are
32 # permitted in any medium without royalty provided the copyright notice
33 # and this notice are preserved.
35 AC_DEFUN([AX_BOOST_SERIALIZATION],
37 AC_ARG_WITH([boost-serialization],
38 AS_HELP_STRING([--with-boost-serialization@<:@=special-lib@:>@],
39 [use the Serialization library from boost - it is possible to specify a certain library for the linker
40 e.g. --with-boost-serialization=boost_serialization-gcc-mt-d-1_33_1 ]),
42 if test "$withval" = "no"; then
44 elif test "$withval" = "yes"; then
46 ax_boost_user_serialization_lib=""
49 ax_boost_user_serialization_lib="$withval"
55 if test "x$want_boost" = "xyes"; then
56 AC_REQUIRE([AC_PROG_CC])
57 CPPFLAGS_SAVED="$CPPFLAGS"
58 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
59 AC_MSG_WARN(BOOST_CPPFLAGS $BOOST_CPPFLAGS)
62 LDFLAGS_SAVED="$LDFLAGS"
63 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
66 AC_CACHE_CHECK(whether the Boost::Serialization library is available,
67 ax_cv_boost_serialization,
69 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <fstream>
70 @%:@include <boost/archive/text_oarchive.hpp>
71 @%:@include <boost/archive/text_iarchive.hpp>
73 [[std::ofstream ofs("filename");
74 boost::archive::text_oarchive oa(ofs);
77 ax_cv_boost_serialization=yes, ax_cv_boost_serialization=no)
80 if test "x$ax_cv_boost_serialization" = "xyes"; then
81 AC_DEFINE(HAVE_BOOST_SERIALIZATION,,[define if the Boost::Serialization library is available])
82 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
83 if test "x$ax_boost_user_serialization_lib" = "x"; then
84 for libextension in `ls $BOOSTLIBDIR/libboost_serialization*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_serialization.*\)\.so.*$;\1;' -e 's;^lib\(boost_serialization.*\)\.a*$;\1;'` ; do
85 ax_lib=${libextension}
86 AC_CHECK_LIB($ax_lib, exit,
87 [BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break],
88 [link_serialization="no"])
90 if test "x$link_serialization" != "xyes"; then
91 for libextension in `ls $BOOSTLIBDIR/boost_serialization*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_serialization.*\)\.dll.*$;\1;' -e 's;^\(boost_serialization.*\)\.a*$;\1;'` ; do
92 ax_lib=${libextension}
93 AC_CHECK_LIB($ax_lib, exit,
94 [BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break],
95 [link_serialization="no"])
100 for ax_lib in $ax_boost_user_serialization_lib boost_serialization-$ax_boost_user_serialization_lib; do
101 AC_CHECK_LIB($ax_lib, main,
102 [BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break],
103 [link_serialization="no"])
107 if test "x$link_serialization" != "xyes"; then
108 AC_MSG_ERROR(Could not link against $ax_lib !)
112 CPPFLAGS="$CPPFLAGS_SAVED"
113 LDFLAGS="$LDFLAGS_SAVED"