~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to m4/ax_boost_base.m4

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ===========================================================================
 
2
#          http://www.nongnu.org/autoconf-archive/ax_boost_base.html
 
3
# ===========================================================================
 
4
#
 
5
# SYNOPSIS
 
6
#
 
7
#   AX_BOOST_BASE([MINIMUM-VERSION])
 
8
#
 
9
# DESCRIPTION
 
10
#
 
11
#   Test for the Boost C++ libraries of a particular version (or newer)
 
12
#
 
13
#   If no path to the installed boost library is given the macro searchs
 
14
#   under /usr, /usr/local, /opt and /opt/local and evaluates the
 
15
#   $BOOST_ROOT environment variable. Further documentation is available at
 
16
#   <http://randspringer.de/boost/index.html>.
 
17
#
 
18
#   This macro calls:
 
19
#
 
20
#     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
 
21
#
 
22
#   And sets:
 
23
#
 
24
#     HAVE_BOOST
 
25
#
 
26
#   EDIT: 2009-09-07 Cristian Greco <cristian.debian@gmail.com>
 
27
#     - Call AC_SUBST(BOOST_VERSION).
 
28
#
 
29
# LICENSE
 
30
#
 
31
#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
 
32
#
 
33
#   Copying and distribution of this file, with or without modification, are
 
34
#   permitted in any medium without royalty provided the copyright notice
 
35
#   and this notice are preserved.
 
36
 
 
37
AC_DEFUN([AX_BOOST_BASE],
 
38
[
 
39
AC_ARG_WITH([boost],
 
40
        AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
 
41
        [
 
42
    if test "x$withval" = "xno"; then
 
43
                want_boost="no"
 
44
    elif test "x$withval" = "xyes"; then
 
45
        want_boost="yes"
 
46
        ac_boost_path=""
 
47
    else
 
48
            want_boost="yes"
 
49
        ac_boost_path="$withval"
 
50
        fi
 
51
    ],
 
52
    [want_boost="yes"])
 
53
 
 
54
 
 
55
AC_ARG_WITH([boost-libdir],
 
56
        AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
 
57
        [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
 
58
        [
 
59
        if test -d $withval
 
60
        then
 
61
                ac_boost_lib_path="$withval"
 
62
        else
 
63
                AC_MSG_ERROR(--with-boost-libdir expected directory name)
 
64
        fi
 
65
        ],
 
66
        [ac_boost_lib_path=""]
 
67
)
 
68
 
 
69
if test "x$want_boost" = "xyes"; then
 
70
        boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
 
71
        boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
 
72
        boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
 
73
        boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
 
74
        boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
 
75
        if test "x$boost_lib_version_req_sub_minor" = "x" ; then
 
76
                boost_lib_version_req_sub_minor="0"
 
77
        fi
 
78
        WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
 
79
        AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
 
80
        succeeded=no
 
81
 
 
82
        dnl first we check the system location for boost libraries
 
83
        dnl this location ist chosen if boost libraries are installed with the --layout=system option
 
84
        dnl or if you install boost with RPM
 
85
        if test "x$ac_boost_path" != "x"; then
 
86
                BOOST_LDFLAGS="-L$ac_boost_path/lib"
 
87
                BOOST_CPPFLAGS="-I$ac_boost_path/include"
 
88
        else
 
89
                for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
 
90
                        if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
 
91
                                BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
 
92
                                BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
 
93
        BOOST_VERSION=`grep "define BOOST_LIB_VERSION" $ac_boost_path_tmp/include/boost/version.hpp | sed 's,^.*\"\([[0-9]][[_0-9]]*\)\"$,\1, ; s,_0$,, ; s,_,.,'`
 
94
                                break;
 
95
                        fi
 
96
                done
 
97
        fi
 
98
 
 
99
    dnl overwrite ld flags if we have required special directory with
 
100
    dnl --with-boost-libdir parameter
 
101
    if test "x$ac_boost_lib_path" != "x"; then
 
102
       BOOST_LDFLAGS="-L$ac_boost_lib_path"
 
103
    fi
 
104
 
 
105
        CPPFLAGS_SAVED="$CPPFLAGS"
 
106
        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
 
107
        export CPPFLAGS
 
108
 
 
109
        LDFLAGS_SAVED="$LDFLAGS"
 
110
        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
 
111
        export LDFLAGS
 
112
 
 
113
        AC_LANG_PUSH(C++)
 
114
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
115
        @%:@include <boost/version.hpp>
 
116
        ]], [[
 
117
        #if BOOST_VERSION >= $WANT_BOOST_VERSION
 
118
        // Everything is okay
 
119
        #else
 
120
        #  error Boost version is too old
 
121
        #endif
 
122
        ]])],[
 
123
        AC_MSG_RESULT(yes)
 
124
        succeeded=yes
 
125
        found_system=yes
 
126
        ],[
 
127
        ])
 
128
        AC_LANG_POP([C++])
 
129
 
 
130
 
 
131
 
 
132
        dnl if we found no boost with system layout we search for boost libraries
 
133
        dnl built and installed without the --layout=system option or for a staged(not installed) version
 
134
        if test "x$succeeded" != "xyes"; then
 
135
                _version=0
 
136
                if test "x$ac_boost_path" != "x"; then
 
137
                        if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
 
138
                                for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
 
139
                                        _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
 
140
                                        V_CHECK=`expr $_version_tmp \> $_version`
 
141
                                        if test "$V_CHECK" = "1" ; then
 
142
                                                _version=$_version_tmp
 
143
                                        fi
 
144
                                        VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
 
145
                                        BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
 
146
                                done
 
147
                        fi
 
148
                else
 
149
                        for ac_boost_path in /usr /usr/local /opt /opt/local ; do
 
150
                                if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
 
151
                                        for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
 
152
                                                _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
 
153
                                                V_CHECK=`expr $_version_tmp \> $_version`
 
154
                                                if test "$V_CHECK" = "1" ; then
 
155
                                                        _version=$_version_tmp
 
156
                                                        best_path=$ac_boost_path
 
157
                                                fi
 
158
                                        done
 
159
                                fi
 
160
                        done
 
161
 
 
162
                        VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
 
163
                        BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
 
164
            if test "x$ac_boost_lib_path" = "x"
 
165
            then
 
166
               BOOST_LDFLAGS="-L$best_path/lib"
 
167
            fi
 
168
 
 
169
                        if test "x$BOOST_ROOT" != "x"; then
 
170
                                if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
 
171
                                        version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
 
172
                                        stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
 
173
                                        stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
 
174
                                        V_CHECK=`expr $stage_version_shorten \>\= $_version`
 
175
                    if test "$V_CHECK" = "1" -a "x$ac_boost_lib_path" = "x" ; then
 
176
                                                AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
 
177
                                                BOOST_CPPFLAGS="-I$BOOST_ROOT"
 
178
                                                BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
 
179
                                        fi
 
180
                                fi
 
181
                        fi
 
182
                fi
 
183
 
 
184
                CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
 
185
                export CPPFLAGS
 
186
                LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
 
187
                export LDFLAGS
 
188
 
 
189
                AC_LANG_PUSH(C++)
 
190
                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 
191
                @%:@include <boost/version.hpp>
 
192
                ]], [[
 
193
                #if BOOST_VERSION >= $WANT_BOOST_VERSION
 
194
                // Everything is okay
 
195
                #else
 
196
                #  error Boost version is too old
 
197
                #endif
 
198
                ]])],[
 
199
                AC_MSG_RESULT(yes)
 
200
                succeeded=yes
 
201
                found_system=yes
 
202
                ],[
 
203
                ])
 
204
                AC_LANG_POP([C++])
 
205
        fi
 
206
 
 
207
        if test "x$succeeded" != "xyes" ; then
 
208
                if test "$_version" = "0" ; then
 
209
                        AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
 
210
                else
 
211
                        AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
 
212
                fi
 
213
        else
 
214
                AC_SUBST(BOOST_CPPFLAGS)
 
215
                AC_SUBST(BOOST_LDFLAGS)
 
216
    AC_SUBST(BOOST_VERSION)
 
217
                AC_DEFINE(HAVE_BOOST,[1],[define if the Boost library is available])
 
218
        fi
 
219
 
 
220
        CPPFLAGS="$CPPFLAGS_SAVED"
 
221
        LDFLAGS="$LDFLAGS_SAVED"
 
222
fi
 
223
 
 
224
])