1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_boost_date_time.html
3 # ===========================================================================
11 # Test for Date_Time 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_DATE_TIME_LIB)
21 # HAVE_BOOST_DATE_TIME
25 # Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
26 # Copyright (c) 2008 Michael Tindal
28 # Copying and distribution of this file, with or without modification, are
29 # permitted in any medium without royalty provided the copyright notice
30 # and this notice are preserved. This file is offered as-is, without any
35 AC_DEFUN([AX_BOOST_DATE_TIME],
37 AC_ARG_WITH([boost-date-time],
38 AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
39 [use the Date_Time library from boost - it is possible to specify a certain library for the linker
40 e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
42 if test "$withval" = "no"; then
44 elif test "$withval" = "yes"; then
46 ax_boost_user_date_time_lib=""
49 ax_boost_user_date_time_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"
61 LDFLAGS_SAVED="$LDFLAGS"
62 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
65 AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
66 ax_cv_boost_date_time,
68 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
69 [[using namespace boost::gregorian; date d(2002,Jan,10);
72 ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
75 if test "x$ax_cv_boost_date_time" = "xyes"; then
76 AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
77 BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
78 if test "x$ax_boost_user_date_time_lib" = "x"; then
79 for libextension in `ls $BOOSTLIBDIR/libboost_date_time*.so* $BOOSTLIBDIR/libboost_date_time*.dylib* $BOOSTLIBDIR/libboost_date_time*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_date_time.*\)\.so.*$;\1;' -e 's;^lib\(boost_date_time.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_date_time.*\)\.a*$;\1;'` ; do
80 ax_lib=${libextension}
81 AC_CHECK_LIB($ax_lib, exit,
82 [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
83 [link_date_time="no"])
85 if test "x$link_date_time" != "xyes"; then
86 for libextension in `ls $BOOSTLIBDIR/boost_date_time*.dll* $BOOSTLIBDIR/boost_date_time*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_date_time.*\)\.dll.*$;\1;' -e 's;^\(boost_date_time.*\)\.a.*$;\1;'` ; do
87 ax_lib=${libextension}
88 AC_CHECK_LIB($ax_lib, exit,
89 [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
90 [link_date_time="no"])
95 for ax_lib in $ax_boost_user_date_time_lib boost_date_time-$ax_boost_user_date_time_lib; do
96 AC_CHECK_LIB($ax_lib, main,
97 [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
98 [link_date_time="no"])
102 if test "x$ax_lib" = "x"; then
103 AC_MSG_ERROR(Could not find a version of the boost date_time library!)
105 if test "x$link_date_time" != "xyes"; then
106 AC_MSG_ERROR(Could not link against $ax_lib !)
110 CPPFLAGS="$CPPFLAGS_SAVED"
111 LDFLAGS="$LDFLAGS_SAVED"