| 1 | # =========================================================================== |
|---|
| 2 | # https://www.gnu.org/software/autoconf-archive/ax_boost_serialization.html |
|---|
| 3 | # =========================================================================== |
|---|
| 4 | # |
|---|
| 5 | # SYNOPSIS |
|---|
| 6 | # |
|---|
| 7 | # AX_BOOST_SERIALIZATION |
|---|
| 8 | # |
|---|
| 9 | # DESCRIPTION |
|---|
| 10 | # |
|---|
| 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>. |
|---|
| 14 | # |
|---|
| 15 | # This macro calls: |
|---|
| 16 | # |
|---|
| 17 | # AC_SUBST(BOOST_SERIALIZATION_LIB) |
|---|
| 18 | # |
|---|
| 19 | # And sets: |
|---|
| 20 | # |
|---|
| 21 | # HAVE_BOOST_SERIALIZATION |
|---|
| 22 | # |
|---|
| 23 | # LICENSE |
|---|
| 24 | # |
|---|
| 25 | # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de> |
|---|
| 26 | # |
|---|
| 27 | # Copying and distribution of this file, with or without modification, are |
|---|
| 28 | # permitted in any medium without royalty provided the copyright notice |
|---|
| 29 | # and this notice are preserved. This file is offered as-is, without any |
|---|
| 30 | # warranty. |
|---|
| 31 | |
|---|
| 32 | #serial 22 |
|---|
| 33 | |
|---|
| 34 | AC_DEFUN([AX_BOOST_SERIALIZATION], |
|---|
| 35 | [ |
|---|
| 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 ]), |
|---|
| 40 | [ |
|---|
| 41 | if test "$withval" = "no"; then |
|---|
| 42 | want_boost="no" |
|---|
| 43 | elif test "$withval" = "yes"; then |
|---|
| 44 | want_boost="yes" |
|---|
| 45 | ax_boost_user_serialization_lib="" |
|---|
| 46 | else |
|---|
| 47 | want_boost="yes" |
|---|
| 48 | ax_boost_user_serialization_lib="$withval" |
|---|
| 49 | fi |
|---|
| 50 | ], |
|---|
| 51 | [want_boost="yes"] |
|---|
| 52 | ) |
|---|
| 53 | |
|---|
| 54 | if test "x$want_boost" = "xyes"; then |
|---|
| 55 | AC_REQUIRE([AC_PROG_CC]) |
|---|
| 56 | CPPFLAGS_SAVED="$CPPFLAGS" |
|---|
| 57 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
|---|
| 58 | AC_MSG_WARN(BOOST_CPPFLAGS $BOOST_CPPFLAGS) |
|---|
| 59 | export CPPFLAGS |
|---|
| 60 | |
|---|
| 61 | LDFLAGS_SAVED="$LDFLAGS" |
|---|
| 62 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
|---|
| 63 | export LDFLAGS |
|---|
| 64 | |
|---|
| 65 | AC_CACHE_CHECK(whether the Boost::Serialization library is available, |
|---|
| 66 | ax_cv_boost_serialization, |
|---|
| 67 | [AC_LANG_PUSH([C++]) |
|---|
| 68 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <fstream> |
|---|
| 69 | @%:@include <boost/archive/text_oarchive.hpp> |
|---|
| 70 | @%:@include <boost/archive/text_iarchive.hpp> |
|---|
| 71 | ]], |
|---|
| 72 | [[std::ofstream ofs("filename"); |
|---|
| 73 | boost::archive::text_oarchive oa(ofs); |
|---|
| 74 | return 0; |
|---|
| 75 | ]])], |
|---|
| 76 | ax_cv_boost_serialization=yes, ax_cv_boost_serialization=no) |
|---|
| 77 | AC_LANG_POP([C++]) |
|---|
| 78 | ]) |
|---|
| 79 | if test "x$ax_cv_boost_serialization" = "xyes"; then |
|---|
| 80 | AC_DEFINE(HAVE_BOOST_SERIALIZATION,,[define if the Boost::Serialization library is available]) |
|---|
| 81 | BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` |
|---|
| 82 | if test "x$ax_boost_user_serialization_lib" = "x"; then |
|---|
| 83 | for libextension in `ls $BOOSTLIBDIR/libboost_serialization*.so* $BOOSTLIBDIR/libboost_serialization*.dylib* $BOOSTLIBDIR/libboost_serialization*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_serialization.*\)\.so.*$;\1;' -e 's;^lib\(boost_serialization.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_serialization.*\)\.a*$;\1;'` ; do |
|---|
| 84 | ax_lib=${libextension} |
|---|
| 85 | AC_CHECK_LIB($ax_lib, exit, |
|---|
| 86 | [BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break], |
|---|
| 87 | [link_serialization="no"]) |
|---|
| 88 | done |
|---|
| 89 | if test "x$link_serialization" != "xyes"; then |
|---|
| 90 | for libextension in `ls $BOOSTLIBDIR/boost_serialization*.dll* $BOOSTLIBDIR/boost_serialization*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_serialization.*\)\.dll.*$;\1;' -e 's;^\(boost_serialization.*\)\.a.*$;\1;'` ; do |
|---|
| 91 | ax_lib=${libextension} |
|---|
| 92 | AC_CHECK_LIB($ax_lib, exit, |
|---|
| 93 | [BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break], |
|---|
| 94 | [link_serialization="no"]) |
|---|
| 95 | done |
|---|
| 96 | fi |
|---|
| 97 | |
|---|
| 98 | else |
|---|
| 99 | for ax_lib in $ax_boost_user_serialization_lib boost_serialization-$ax_boost_user_serialization_lib; do |
|---|
| 100 | AC_CHECK_LIB($ax_lib, main, |
|---|
| 101 | [BOOST_SERIALIZATION_LIB="-l$ax_lib"; AC_SUBST(BOOST_SERIALIZATION_LIB) link_serialization="yes"; break], |
|---|
| 102 | [link_serialization="no"]) |
|---|
| 103 | done |
|---|
| 104 | |
|---|
| 105 | fi |
|---|
| 106 | if test "x$ax_lib" = "x"; then |
|---|
| 107 | AC_MSG_ERROR(Could not find a version of the library!) |
|---|
| 108 | fi |
|---|
| 109 | if test "x$link_serialization" != "xyes"; then |
|---|
| 110 | AC_MSG_ERROR(Could not link against $ax_lib !) |
|---|
| 111 | fi |
|---|
| 112 | fi |
|---|
| 113 | |
|---|
| 114 | CPPFLAGS="$CPPFLAGS_SAVED" |
|---|
| 115 | LDFLAGS="$LDFLAGS_SAVED" |
|---|
| 116 | fi |
|---|
| 117 | ]) |
|---|