1 ##### http://autoconf-archive.cryp.to/ax_boost_serialization.html
5 # AX_BOOST_SERIALIZATION
9 # Test for Serialization library from the Boost C++ libraries. The
10 # macro requires a preceding call to AX_BOOST_BASE. Further
11 # documentation is available at
12 # <http://randspringer.de/boost/index.html>.
16 # AC_SUBST(BOOST_SERIALIZATION_LIB)
20 # HAVE_BOOST_SERIALIZATION
28 # Copyright (c) 2006 Thomas Porschberg <thomas@randspringer.de>
30 # Copying and distribution of this file, with or without
31 # modification, are permitted in any medium without royalty provided
32 # the copyright notice and this notice are preserved.
34 AC_DEFUN([AX_BOOST_SERIALIZATION],
36 AC_ARG_WITH([boost-serialization],
37 AS_HELP_STRING([--with-boost-serialization@<:@=special-lib@:>@],
38 [use the Serialization library from boost - it is possible to specify a certain library for the linker
39 e.g. --with-boost-serialization=boost_serialization-gcc-mt-d-1_33_1 ]),
41 if test "$withval" = "no"; then
43 elif test "$withval" = "yes"; then
45 ax_boost_user_serialization_lib=""
48 ax_boost_user_serialization_lib="$withval"
54 if test "x$want_boost" = "xyes"; then
55 AC_REQUIRE([AC_PROG_CC])
56 CPPFLAGS_SAVED="$CPPFLAGS"
57 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60 LDFLAGS_SAVED="$LDFLAGS"
61 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64 AC_CACHE_CHECK(whether the Boost::Serialization library is available,
65 ax_cv_boost_serialization,
67 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <fstream>
68 @%:@include <boost/archive/text_oarchive.hpp>
69 @%:@include <boost/archive/text_iarchive.hpp>
71 [[std::ofstream ofs("filename");
72 boost::archive::text_oarchive oa(ofs);
75 ax_cv_boost_serialization=yes, ax_cv_boost_serialization=no)
78 if test "x$ax_cv_boost_serialization" = "xyes"; then
79 AC_DEFINE(HAVE_BOOST_SERIALIZATION,,[define if the Boost::Serialization library is available])
80 BN=boost_serialization
81 if test "x$ax_boost_user_serialization_lib" = "x"; then
82 for ax_lib in $BN $BN-$CC $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \
83 lib$BN lib$BN-$CC lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \
84 $BN-mgw $BN-mgw $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do
85 AC_CHECK_LIB($ax_lib, main,
86 [BOOST_SERIALIZATION_LIB="-l$ax_lib" AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes" break],
87 [link_serialization="no"])
90 for ax_lib in $ax_boost_user_serialization_lib $BN-$ax_boost_user_serialization_lib; do
91 AC_CHECK_LIB($ax_lib, main,
92 [BOOST_SERIALIZATION_LIB="-l$ax_lib" AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes" break],
93 [link_serialization="no"])
97 if test "x$link_serialization" = "xno"; then
98 AC_MSG_ERROR(Could not link against $ax_lib !)
102 CPPFLAGS="$CPPFLAGS_SAVED"
103 LDFLAGS="$LDFLAGS_SAVED"