added some precautionary checks in bdecoder
[libtorrent.git] / m4 / ax_boost_date_time.m4
bloba6dd0394677bc3a59e9ba376231d13d4c3b01489
1 # ===========================================================================
2 #           http://autoconf-archive.cryp.to/ax_boost_date_time.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_BOOST_DATE_TIME
9 # DESCRIPTION
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>.
15 #   This macro calls:
17 #     AC_SUBST(BOOST_DATE_TIME_LIB)
19 #   And sets:
21 #     HAVE_BOOST_DATE_TIME
23 # LAST MODIFICATION
25 #   2008-04-12
27 # COPYLEFT
29 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
30 #   Copyright (c) 2008 Michael Tindal
32 #   Copying and distribution of this file, with or without modification, are
33 #   permitted in any medium without royalty provided the copyright notice
34 #   and this notice are preserved.
36 AC_DEFUN([AX_BOOST_DATE_TIME],
38         AC_ARG_WITH([boost-date-time],
39         AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
40                    [use the Date_Time library from boost - it is possible to specify a certain library for the linker
41                         e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
42         [
43         if test "$withval" = "no"; then
44                         want_boost="no"
45         elif test "$withval" = "yes"; then
46             want_boost="yes"
47             ax_boost_user_date_time_lib=""
48         else
49                     want_boost="yes"
50                 ax_boost_user_date_time_lib="$withval"
51                 fi
52         ],
53         [want_boost="yes"]
54         )
56         if test "x$want_boost" = "xyes"; then
57         AC_REQUIRE([AC_PROG_CC])
58                 CPPFLAGS_SAVED="$CPPFLAGS"
59                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
60                 export CPPFLAGS
62                 LDFLAGS_SAVED="$LDFLAGS"
63                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64                 export LDFLAGS
66         AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
67                                            ax_cv_boost_date_time,
68         [AC_LANG_PUSH([C++])
69                  AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
70                                    [[using namespace boost::gregorian; date d(2002,Jan,10);
71                                      return 0;
72                                    ]]),
73          ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
74          AC_LANG_POP([C++])
75                 ])
76                 if test "x$ax_cv_boost_date_time" = "xyes"; then
77                         AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
78             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
79             if test "x$ax_boost_user_date_time_lib" = "x"; then
80                 for libextension in `ls $BOOSTLIBDIR/libboost_date_time*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_date_time.*\)\.so.*$;\1;' -e 's;^lib\(boost_date_time.*\)\.a*$;\1;'` ; do
81                      ax_lib=${libextension}
82                                     AC_CHECK_LIB($ax_lib, exit,
83                                  [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
84                                  [link_date_time="no"])
85                                 done
86                 if test "x$link_date_time" != "xyes"; then
87                 for libextension in `ls $BOOSTLIBDIR/boost_date_time*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_date_time.*\)\.dll.*$;\1;' -e 's;^\(boost_date_time.*\)\.a*$;\1;'` ; do
88                      ax_lib=${libextension}
89                                     AC_CHECK_LIB($ax_lib, exit,
90                                  [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
91                                  [link_date_time="no"])
92                                 done
93                 fi
95             else
96                for ax_lib in $ax_boost_user_date_time_lib boost_date_time-$ax_boost_user_date_time_lib; do
97                                       AC_CHECK_LIB($ax_lib, main,
98                                    [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
99                                    [link_date_time="no"])
100                   done
102             fi
103                         if test "x$link_date_time" != "xyes"; then
104                                 AC_MSG_ERROR(Could not link against $ax_lib !)
105                         fi
106                 fi
108                 CPPFLAGS="$CPPFLAGS_SAVED"
109         LDFLAGS="$LDFLAGS_SAVED"
110         fi
112 # ===========================================================================
113 #           http://autoconf-archive.cryp.to/ax_boost_date_time.html
114 # ===========================================================================
116 # SYNOPSIS
118 #   AX_BOOST_DATE_TIME
120 # DESCRIPTION
122 #   Test for Date_Time library from the Boost C++ libraries. The macro
123 #   requires a preceding call to AX_BOOST_BASE. Further documentation is
124 #   available at <http://randspringer.de/boost/index.html>.
126 #   This macro calls:
128 #     AC_SUBST(BOOST_DATE_TIME_LIB)
130 #   And sets:
132 #     HAVE_BOOST_DATE_TIME
134 # LAST MODIFICATION
136 #   2008-04-12
138 # COPYLEFT
140 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
141 #   Copyright (c) 2008 Michael Tindal
143 #   Copying and distribution of this file, with or without modification, are
144 #   permitted in any medium without royalty provided the copyright notice
145 #   and this notice are preserved.
147 AC_DEFUN([AX_BOOST_DATE_TIME],
149         AC_ARG_WITH([boost-date-time],
150         AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@],
151                    [use the Date_Time library from boost - it is possible to specify a certain library for the linker
152                         e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]),
153         [
154         if test "$withval" = "no"; then
155                         want_boost="no"
156         elif test "$withval" = "yes"; then
157             want_boost="yes"
158             ax_boost_user_date_time_lib=""
159         else
160                     want_boost="yes"
161                 ax_boost_user_date_time_lib="$withval"
162                 fi
163         ],
164         [want_boost="yes"]
165         )
167         if test "x$want_boost" = "xyes"; then
168         AC_REQUIRE([AC_PROG_CC])
169                 CPPFLAGS_SAVED="$CPPFLAGS"
170                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
171                 export CPPFLAGS
173                 LDFLAGS_SAVED="$LDFLAGS"
174                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
175                 export LDFLAGS
177         AC_CACHE_CHECK(whether the Boost::Date_Time library is available,
178                                            ax_cv_boost_date_time,
179         [AC_LANG_PUSH([C++])
180                  AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include <boost/date_time/gregorian/gregorian_types.hpp>]],
181                                    [[using namespace boost::gregorian; date d(2002,Jan,10);
182                                      return 0;
183                                    ]]),
184          ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no)
185          AC_LANG_POP([C++])
186                 ])
187                 if test "x$ax_cv_boost_date_time" = "xyes"; then
188                         AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available])
189             BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
190             if test "x$ax_boost_user_date_time_lib" = "x"; then
191                 for libextension in `ls $BOOSTLIBDIR/libboost_date_time*.{so,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_date_time.*\)\.so.*$;\1;' -e 's;^lib\(boost_date_time.*\)\.a*$;\1;'` ; do
192                      ax_lib=${libextension}
193                                     AC_CHECK_LIB($ax_lib, exit,
194                                  [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
195                                  [link_date_time="no"])
196                                 done
197                 if test "x$link_date_time" != "xyes"; then
198                 for libextension in `ls $BOOSTLIBDIR/boost_date_time*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_date_time.*\)\.dll.*$;\1;' -e 's;^\(boost_date_time.*\)\.a*$;\1;'` ; do
199                      ax_lib=${libextension}
200                                     AC_CHECK_LIB($ax_lib, exit,
201                                  [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
202                                  [link_date_time="no"])
203                                 done
204                 fi
206             else
207                for ax_lib in $ax_boost_user_date_time_lib boost_date_time-$ax_boost_user_date_time_lib; do
208                                       AC_CHECK_LIB($ax_lib, main,
209                                    [BOOST_DATE_TIME_LIB="-l$ax_lib"; AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes"; break],
210                                    [link_date_time="no"])
211                   done
213             fi
214                         if test "x$link_date_time" != "xyes"; then
215                                 AC_MSG_ERROR(Could not link against $ax_lib !)
216                         fi
217                 fi
219                 CPPFLAGS="$CPPFLAGS_SAVED"
220         LDFLAGS="$LDFLAGS_SAVED"
221         fi