]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - _build/ax_boost_timer.m4
Adjust the name of the library to match upstream
[ext/sigc++-2.0.git] / _build / ax_boost_timer.m4
1 # ===========================================================================
2 #      http://www.gnu.org/software/autoconf-archive/ax_boost_timer.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 #   AX_BOOST_TIMER
8 #
9 # DESCRIPTION
10 #
11 #   Test for System library from the Boost C++ libraries. The macro requires
12 #   a preceding call to AX_BOOST_BASE. Further documentation is available at
13 #   <http://randspringer.de/boost/index.html>.
14 #
15 #   This macro calls:
16 #
17 #     AC_SUBST(BOOST_TIMER_LIB)
18 #
19 #   And sets:
20 #
21 #     HAVE_BOOST_TIMER
22 #
23 # LICENSE
24 #
25 #   Copyright (c) 2012 Xiyue Deng <manphiz@gmail.com>
26 #   Copyright (c) 2012 Murray Cumming <murrayc@openismus.com>
27 #
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
31 #   warranty.
32
33 #serial 2 (based on serial 1 of ax_boost_locale.m4 with some simple find/replace by Murray Cumming)
34
35 AC_DEFUN([AX_BOOST_TIMER],
36 [
37         AC_ARG_WITH([boost-timer],
38         AS_HELP_STRING([--with-boost-timer@<:@=special-lib@:>@],
39                    [use the Timer library from boost - it is possible to specify a certain library for the linker
40                         e.g. --with-boost-timer=boost_timer-gcc-mt ]),
41         [
42         if test "$withval" = "no"; then
43                         want_boost="no"
44         elif test "$withval" = "yes"; then
45             want_boost="yes"
46             ax_boost_user_timer_lib=""
47         else
48                     want_boost="yes"
49                 ax_boost_user_timer_lib="$withval"
50                 fi
51         ],
52         [want_boost="yes"]
53         )
54
55         if test "x$want_boost" = "xyes"; then
56         AC_REQUIRE([AC_PROG_CC])
57         AC_REQUIRE([AC_CANONICAL_BUILD])
58                 CPPFLAGS_SAVED="$CPPFLAGS"
59                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60                 export CPPFLAGS
61
62                 LDFLAGS_SAVED="$LDFLAGS"
63                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64                 export LDFLAGS
65
66         AC_CACHE_CHECK(whether the Boost::Timer library is available,
67                                            ax_cv_boost_timer,
68         [AC_LANG_PUSH([C++])
69                          CXXFLAGS_SAVE=$CXXFLAGS
70
71                          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/timer/timer.hpp>]],
72                                    [[boost::timer::cpu_timer().stop();]])],
73                    ax_cv_boost_timer=yes, ax_cv_boost_timer=no)
74                          CXXFLAGS=$CXXFLAGS_SAVE
75              AC_LANG_POP([C++])
76                 ])
77                 if test "x$ax_cv_boost_timer" = "xyes"; then
78                         AC_SUBST(BOOST_CPPFLAGS)
79
80                         AC_DEFINE(HAVE_BOOST_TIMER,,[define if the Boost::Timer library is available])
81             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
82
83                         LDFLAGS_SAVE=$LDFLAGS
84             if test "x$ax_boost_user_timer_lib" = "x"; then
85                 for libextension in `ls $BOOSTLIBDIR/libboost_timer*.so* $BOOSTLIBDIR/libboost_timer*.dylib* $BOOSTLIBDIR/libboost_timer*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_timer.*\)\.so.*$;\1;' -e 's;^lib\(boost_timer.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_timer.*\)\.a.*$;\1;'` ; do
86                      ax_lib=${libextension}
87                                     AC_CHECK_LIB($ax_lib, exit,
88                                  [BOOST_TIMER_LIB="-l$ax_lib"; AC_SUBST(BOOST_TIMER_LIB) link_timer="yes"; break],
89                                  [link_timer="no"])
90                                 done
91                 if test "x$link_timer" != "xyes"; then
92                 for libextension in `ls $BOOSTLIBDIR/boost_timer*.dll* $BOOSTLIBDIR/boost_timer*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_timer.*\)\.dll.*$;\1;' -e 's;^\(boost_timer.*\)\.a.*$;\1;'` ; do
93                      ax_lib=${libextension}
94                                     AC_CHECK_LIB($ax_lib, exit,
95                                  [BOOST_TIMER_LIB="-l$ax_lib"; AC_SUBST(BOOST_TIMER_LIB) link_timer="yes"; break],
96                                  [link_timer="no"])
97                                 done
98                 fi
99
100             else
101                for ax_lib in $ax_boost_user_timer_lib boost_timer-$ax_boost_user_timer_lib; do
102                                       AC_CHECK_LIB($ax_lib, exit,
103                                    [BOOST_TIMER_LIB="-l$ax_lib"; AC_SUBST(BOOST_TIMER_LIB) link_timer="yes"; break],
104                                    [link_timer="no"])
105                   done
106
107             fi
108             if test "x$ax_lib" = "x"; then
109                 AC_MSG_ERROR(Could not find a version of the library!)
110             fi
111                         if test "x$link_timer" = "xno"; then
112                                 AC_MSG_ERROR(Could not link against $ax_lib !)
113                         fi
114                 fi
115
116                 CPPFLAGS="$CPPFLAGS_SAVED"
117         LDFLAGS="$LDFLAGS_SAVED"
118         fi
119 ])