1
# boost.m4: Locate Boost headers and libraries for autoconf-based projects.
2
# Copyright (C) 2007, 2008, 2009, 2010, 2011  Benoit Sigoure <tsuna@lrde.epita.fr>
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# Additional permission under section 7 of the GNU General Public
10
# License, version 3 ("GPLv3"):
11
#
12
# If you convey this file as part of a work that contains a
13
# configuration script generated by Autoconf, you may do so under
14
# terms of your choice.
15
#
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
# GNU General Public License for more details.
20
#
21
# You should have received a copy of the GNU General Public License
22
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
24
m4_define([_BOOST_SERIAL], [m4_translit([
25
# serial 16
26
], [#
27
], [])])
28
29
# Original sources can be found at http://github.com/tsuna/boost.m4
30
# You can fetch the latest version of the script by doing:
31
#   wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4
32
33
# ------ #
34
# README #
35
# ------ #
36
37
# This file provides several macros to use the various Boost libraries.
38
# The first macro is BOOST_REQUIRE.  It will simply check if it's possible to
39
# find the Boost headers of a given (optional) minimum version and it will
40
# define BOOST_CPPFLAGS accordingly.  It will add an option --with-boost to
41
# your configure so that users can specify non standard locations.
42
# If the user's environment contains BOOST_ROOT and --with-boost was not
43
# specified, --with-boost=$BOOST_ROOT is implicitly used.
44
# For more README and documentation, go to http://github.com/tsuna/boost.m4
45
# Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL.  If you don't, don't worry,
46
# simply read the README, it will show you what to do step by step.
47
48
m4_pattern_forbid([^_?(BOOST|Boost)_])
49
50
51
# _BOOST_SED_CPP(SED-PROGRAM, PROGRAM,
52
#                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
53
# --------------------------------------------------------
54
# Same as AC_EGREP_CPP, but leave the result in conftest.i.
55
#
56
# SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP.  It is expanded
57
# in double-quotes, so escape your double quotes.
58
#
59
# It could be useful to turn this into a macro which extracts the
60
# value of any macro.
61
m4_define([_BOOST_SED_CPP],
62
[AC_LANG_PREPROC_REQUIRE()dnl
63
AC_REQUIRE([AC_PROG_SED])dnl
64
AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
65
AS_IF([dnl eval is necessary to expand ac_cpp.
66
dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
67
dnl Beware of Windows end-of-lines, for instance if we are running
68
dnl some Windows programs under Wine.  In that case, boost/version.hpp
69
dnl is certainly using "\r\n", but the regular Unix shell will only
70
dnl strip `\n' with backquotes, not the `\r'.  This results in
71
dnl boost_cv_lib_version='1_37\r' for instance, which breaks
72
dnl everything else.
73
dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK
74
(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
75
  tr -d '\r' |
76
  $SED -n -e "$1" >conftest.i 2>&1],
77
  [$3],
78
  [$4])
79
rm -rf conftest*
80
])# AC_EGREP_CPP
81
82
83
84
# BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND])
85
# -----------------------------------------------
86
# Look for Boost.  If version is given, it must either be a literal of the form
87
# "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a
88
# variable "$var".
89
# Defines the value BOOST_CPPFLAGS.  This macro only checks for headers with
90
# the required version, it does not check for any of the Boost libraries.
91
# On # success, defines HAVE_BOOST.  On failure, calls the optional
92
# ACTION-IF-NOT-FOUND action if one was supplied.
93
# Otherwise aborts with an error message.
94
AC_DEFUN([BOOST_REQUIRE],
95
[AC_REQUIRE([AC_PROG_CXX])dnl
96
AC_REQUIRE([AC_PROG_GREP])dnl
97
echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD
98
boost_save_IFS=$IFS
99
boost_version_req=$1
100
IFS=.
101
set x $boost_version_req 0 0 0
102
IFS=$boost_save_IFS
103
shift
104
boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"`
105
boost_version_req_string=$[1].$[2].$[3]
106
AC_ARG_WITH([boost],
107
   [AS_HELP_STRING([--with-boost=DIR],
108
                   [prefix of Boost $1 @<:@guess@:>@])])dnl
109
AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl
110
# If BOOST_ROOT is set and the user has not provided a value to
111
# --with-boost, then treat BOOST_ROOT as if it the user supplied it.
112
if test x"$BOOST_ROOT" != x; then
113
  if test x"$with_boost" = x; then
114
    AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT])
115
    with_boost=$BOOST_ROOT
116
  else
117
    AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost])
118
  fi
119
fi
120
AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],
121
         ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl
122
boost_save_CPPFLAGS=$CPPFLAGS
123
  AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string],
124
    [boost_cv_inc_path],
125
    [boost_cv_inc_path=no
126
AC_LANG_PUSH([C++])dnl
127
m4_pattern_allow([^BOOST_VERSION$])dnl
128
    AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <boost/version.hpp>
129
#if !defined BOOST_VERSION
130
# error BOOST_VERSION is not defined
131
#elif BOOST_VERSION < $boost_version_req
132
# error Boost headers version < $boost_version_req
133
#endif
134
]])])
135
    # If the user provided a value to --with-boost, use it and only it.
136
    case $with_boost in #(
137
      ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \
138
                 /usr/include C:/Boost/include;; #(
139
      *)      set x "$with_boost/include" "$with_boost";;
140
    esac
141
    shift
142
    for boost_dir
143
    do
144
    # Without --layout=system, Boost (or at least some versions) installs
145
    # itself in <prefix>/include/boost-<version>.  This inner loop helps to
146
    # find headers in such directories.
147
    #
148
    # Any ${boost_dir}/boost-x_xx directories are searched in reverse version
149
    # order followed by ${boost_dir}.  The final '.' is a sentinel for
150
    # searching $boost_dir" itself.  Entries are whitespace separated.
151
    #
152
    # I didn't indent this loop on purpose (to avoid over-indented code)
153
    boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \
154
        && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \
155
        && echo .`
156
    for boost_inc in $boost_layout_system_search_list
157
    do
158
      if test x"$boost_inc" != x.; then
159
        boost_inc="$boost_dir/$boost_inc"
160
      else
161
        boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list
162
      fi
163
      if test x"$boost_inc" != x; then
164
        # We are going to check whether the version of Boost installed
165
        # in $boost_inc is usable by running a compilation that
166
        # #includes it.  But if we pass a -I/some/path in which Boost
167
        # is not installed, the compiler will just skip this -I and
168
        # use other locations (either from CPPFLAGS, or from its list
169
        # of system include directories).  As a result we would use
170
        # header installed on the machine instead of the /some/path
171
        # specified by the user.  So in that precise case (trying
172
        # $boost_inc), make sure the version.hpp exists.
173
        #
174
        # Use test -e as there can be symlinks.
175
        test -e "$boost_inc/boost/version.hpp" || continue
176
        CPPFLAGS="$CPPFLAGS -I$boost_inc"
177
      fi
178
      AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no])
179
      if test x"$boost_cv_inc_path" = xyes; then
180
        if test x"$boost_inc" != x; then
181
          boost_cv_inc_path=$boost_inc
182
        fi
183
        break 2
184
      fi
185
    done
186
    done
187
AC_LANG_POP([C++])dnl
188
    ])
189
    case $boost_cv_inc_path in #(
190
      no)
191
        boost_errmsg="cannot find Boost headers version >= $boost_version_req_string"
192
        m4_if([$2], [],  [AC_MSG_ERROR([$boost_errmsg])],
193
                        [AC_MSG_NOTICE([$boost_errmsg])])
194
        $2
195
        ;;#(
196
      yes)
197
        BOOST_CPPFLAGS=
198
        ;;#(
199
      *)
200
        AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl
201
        ;;
202
    esac
203
  if test x"$boost_cv_inc_path" != xno; then
204
  AC_DEFINE([HAVE_BOOST], [1],
205
            [Defined if the requested minimum BOOST version is satisfied])
206
  AC_CACHE_CHECK([for Boost's header version],
207
    [boost_cv_lib_version],
208
    [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl
209
     _BOOST_SED_CPP([/^boost-lib-version = /{s///;s/\"//g;p;q;}],
210
                    [#include <boost/version.hpp>
211
boost-lib-version = BOOST_LIB_VERSION],
212
    [boost_cv_lib_version=`cat conftest.i`])])
213
    # e.g. "134" for 1_34_1 or "135" for 1_35
214
    boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'`
215
    case $boost_major_version in #(
216
      '' | *[[!0-9]]*)
217
        AC_MSG_ERROR([invalid value: boost_major_version=$boost_major_version])
218
        ;;
219
    esac
220
fi
221
CPPFLAGS=$boost_save_CPPFLAGS
222
])# BOOST_REQUIRE
223
224
# BOOST_STATIC()
225
# --------------
226
# Add the "--enable-static-boost" configure argument. If this argument is given
227
# on the command line, static versions of the libraries will be looked up.
228
AC_DEFUN([BOOST_STATIC],
229
  [AC_ARG_ENABLE([static-boost],
230
     [AC_HELP_STRING([--enable-static-boost],
231
               [Prefer the static boost libraries over the shared ones [no]])],
232
     [enable_static_boost=yes],
233
     [enable_static_boost=no])])# BOOST_STATIC
234
235
# BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND])
236
# --------------------------------------------------------------------------
237
# Wrapper around AC_CHECK_HEADER for Boost headers.  Useful to check for
238
# some parts of the Boost library which are only made of headers and don't
239
# require linking (such as Boost.Foreach).
240
#
241
# Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be
242
# found in the first place, in which case by default a notice is issued to the
243
# user.  Presumably if we haven't died already it's because it's OK to not have
244
# Boost, which is why only a notice is issued instead of a hard error.
245
#
246
# Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_<HEADER-NAME> in
247
# case of success # (where HEADER-NAME is written LIKE_THIS, e.g.,
248
# HAVE_BOOST_FOREACH_HPP).
249
AC_DEFUN([BOOST_FIND_HEADER],
250
[AC_REQUIRE([BOOST_REQUIRE])dnl
251
if test x"$boost_cv_inc_path" = xno; then
252
  m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])])
253
else
254
AC_LANG_PUSH([C++])dnl
255
boost_save_CPPFLAGS=$CPPFLAGS
256
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
257
AC_CHECK_HEADER([$1],
258
  [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1],
259
                               [Define to 1 if you have <$1>])])],
260
  [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])])
261
CPPFLAGS=$boost_save_CPPFLAGS
262
AC_LANG_POP([C++])dnl
263
fi
264
])# BOOST_FIND_HEADER
265
266
267
# BOOST_FIND_LIB([LIB-NAME], [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST],
268
#                [CXX-PROLOGUE])
269
# -------------------------------------------------------------------------
270
# Look for the Boost library LIB-NAME (e.g., LIB-NAME = `thread', for
271
# libboost_thread).  Check that HEADER-NAME works and check that
272
# libboost_LIB-NAME can link with the code CXX-TEST.  The optional argument
273
# CXX-PROLOGUE can be used to include some C++ code before the `main'
274
# function.
275
#
276
# Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above).
277
#
278
# Boost libraries typically come compiled with several flavors (with different
279
# runtime options) so PREFERRED-RT-OPT is the preferred suffix.  A suffix is one
280
# or more of the following letters: sgdpn (in that order).  s = static
281
# runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build,
282
# n = (unsure) STLPort build without iostreams from STLPort (it looks like `n'
283
# must always be used along with `p').  Additionally, PREFERRED-RT-OPT can
284
# start with `mt-' to indicate that there is a preference for multi-thread
285
# builds.  Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp
286
# ...  If you want to make sure you have a specific version of Boost
287
# (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro.
288
AC_DEFUN([BOOST_FIND_LIB],
289
[AC_REQUIRE([BOOST_REQUIRE])dnl
290
AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl
291
AC_REQUIRE([BOOST_STATIC])dnl
292
AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl
293
if test x"$boost_cv_inc_path" = xno; then
294
  AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library])
295
else
296
dnl The else branch is huge and wasn't intended on purpose.
297
AC_LANG_PUSH([C++])dnl
298
AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl
299
AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl
300
AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl
301
AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl
302
BOOST_FIND_HEADER([$3])
303
boost_save_CPPFLAGS=$CPPFLAGS
304
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
305
# Now let's try to find the library.  The algorithm is as follows: first look
306
# for a given library name according to the user's PREFERRED-RT-OPT.  For each
307
# library name, we prefer to use the ones that carry the tag (toolset name).
308
# Each library is searched through the various standard paths were Boost is
309
# usually installed.  If we can't find the standard variants, we try to
310
# enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist
311
# but there's -obviously- libboost_threads-mt.dylib).
312
AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib],
313
  [Boost_lib=no
314
  case "$2" in #(
315
    mt | mt-) boost_mt=-mt; boost_rtopt=;; #(
316
    mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$2" : 'Xmt-*\(.*\)'`;; #(
317
    *) boost_mt=; boost_rtopt=$2;;
318
  esac
319
  if test $enable_static_boost = yes; then
320
    boost_rtopt="s$boost_rtopt"
321
  fi
322
  # Find the proper debug variant depending on what we've been asked to find.
323
  case $boost_rtopt in #(
324
    *d*) boost_rt_d=$boost_rtopt;; #(
325
    *[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn')
326
      boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #(
327
    *) boost_rt_d='-d';;
328
  esac
329
  # If the PREFERRED-RT-OPT are not empty, prepend a `-'.
330
  test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt"
331
  $boost_guess_use_mt && boost_mt=-mt
332
  # Look for the abs path the static archive.
333
  # $libext is computed by Libtool but let's make sure it's non empty.
334
  test -z "$libext" &&
335
    AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?])
336
  boost_save_ac_objext=$ac_objext
337
  # Generate the test file.
338
  AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$3>
339
$5], [$4])])
340
dnl Optimization hacks: compiling C++ is slow, especially with Boost.  What
341
dnl we're trying to do here is guess the right combination of link flags
342
dnl (LIBS / LDFLAGS) to use a given library.  This can take several
343
dnl iterations before it succeeds and is thus *very* slow.  So what we do
344
dnl instead is that we compile the code first (and thus get an object file,
345
dnl typically conftest.o).  Then we try various combinations of link flags
346
dnl until we succeed to link conftest.o in an executable.  The problem is
347
dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always
348
dnl remove all the temporary files including conftest.o.  So the trick here
349
dnl is to temporarily change the value of ac_objext so that conftest.o is
350
dnl preserved accross tests.  This is obviously fragile and I will burn in
351
dnl hell for not respecting Autoconf's documented interfaces, but in the
352
dnl mean time, it optimizes the macro by a factor of 5 to 30.
353
dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left
354
dnl empty because the test file is generated only once above (before we
355
dnl start the for loops).
356
  AC_COMPILE_IFELSE([],
357
    [ac_objext=do_not_rm_me_plz],
358
    [AC_MSG_ERROR([cannot compile a test that uses Boost $1])])
359
  ac_objext=$boost_save_ac_objext
360
  boost_failed_libs=
361
# Don't bother to ident the 6 nested for loops, only the 2 innermost ones
362
# matter.
363
for boost_tag_ in -$boost_cv_lib_tag ''; do
364
for boost_ver_ in -$boost_cv_lib_version ''; do
365
for boost_mt_ in $boost_mt -mt ''; do
366
for boost_rtopt_ in $boost_rtopt '' -d; do
367
  for boost_lib in \
368
    boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \
369
    boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \
370
    boost_$1$boost_tag_$boost_mt_$boost_ver_ \
371
    boost_$1$boost_tag_$boost_ver_
372
  do
373
    # Avoid testing twice the same lib
374
    case $boost_failed_libs in #(
375
      *@$boost_lib@*) continue;;
376
    esac
377
    # If with_boost is empty, we'll search in /lib first, which is not quite
378
    # right so instead we'll try to a location based on where the headers are.
379
    boost_tmp_lib=$with_boost/lib
380
    test x"$with_boost" = x && boost_tmp_lib="${boost_cv_inc_path%/include} \
381
        /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \
382
        "$with_boost" C:/Boost/lib /lib*"
383
384
    for boost_ldpath in $boost_tmp_lib
385
    do
386
      test -e "$boost_ldpath" || continue
387
      boost_save_LDFLAGS=$LDFLAGS
388
      # Are we looking for a static library?
389
      case $boost_ldpath:$boost_rtopt_ in #(
390
        *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt)
391
          Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext"
392
          test -e "$Boost_lib_LIBS" || continue;; #(
393
        *) # No: use -lboost_foo to find the shared library.
394
          Boost_lib_LIBS="-l$boost_lib";;
395
      esac
396
      boost_save_LIBS=$LIBS
397
      LIBS="$Boost_lib_LIBS $LIBS"
398
      test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath"
399
dnl First argument of AC_LINK_IFELSE left empty because the test file is
400
dnl generated only once above (before we start the for loops).
401
      _BOOST_AC_LINK_IFELSE([],
402
                            [Boost_lib=yes], [Boost_lib=no])
403
      ac_objext=$boost_save_ac_objext
404
      LDFLAGS=$boost_save_LDFLAGS
405
      LIBS=$boost_save_LIBS
406
      if test x"$Boost_lib" = xyes; then
407
        Boost_lib_LDFLAGS="-L$boost_ldpath -Wl,-rpath $boost_ldpath"
408
        Boost_lib_LDPATH="$boost_ldpath"
409
        break 6
410
      else
411
        boost_failed_libs="$boost_failed_libs@$boost_lib@"
412
      fi
413
    done
414
  done
415
done
416
done
417
done
418
done
419
rm -f conftest.$ac_objext
420
])
421
case $Boost_lib in #(
422
  no) _AC_MSG_LOG_CONFTEST
423
    AC_MSG_ERROR([cannot find the flags to link with Boost $1])
424
    ;;
425
esac
426
AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl
427
AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl
428
AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl
429
AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl
430
CPPFLAGS=$boost_save_CPPFLAGS
431
AS_VAR_POPDEF([Boost_lib])dnl
432
AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl
433
AS_VAR_POPDEF([Boost_lib_LDPATH])dnl
434
AS_VAR_POPDEF([Boost_lib_LIBS])dnl
435
AC_LANG_POP([C++])dnl
436
fi
437
])# BOOST_FIND_LIB
438
439
440
# --------------------------------------- #
441
# Checks for the various Boost libraries. #
442
# --------------------------------------- #
443
444
# List of boost libraries: http://www.boost.org/libs/libraries.htm
445
# The page http://beta.boost.org/doc/libs is useful: it gives the first release
446
# version of each library (among other things).
447
448
# BOOST_DEFUN(LIBRARY, CODE)
449
# --------------------------
450
# Define BOOST_<LIBRARY-UPPERCASE> as a macro that runs CODE.
451
#
452
# Use indir to avoid the warning on underquoted macro name given to AC_DEFUN.
453
m4_define([BOOST_DEFUN],
454
[m4_indir([AC_DEFUN],
455
          m4_toupper([BOOST_$1]),
456
[m4_pushdef([BOOST_Library], [$1])dnl
457
$2
458
m4_popdef([BOOST_Library])dnl
459
])
460
])
461
462
# BOOST_ARRAY()
463
# -------------
464
# Look for Boost.Array
465
BOOST_DEFUN([Array],
466
[BOOST_FIND_HEADER([boost/array.hpp])])
467
468
469
# BOOST_ASIO()
470
# ------------
471
# Look for Boost.Asio (new in Boost 1.35).
472
BOOST_DEFUN([Asio],
473
[AC_REQUIRE([BOOST_SYSTEM])dnl
474
BOOST_FIND_HEADER([boost/asio.hpp])])
475
476
477
# BOOST_BIND()
478
# ------------
479
# Look for Boost.Bind
480
BOOST_DEFUN([Bind],
481
[BOOST_FIND_HEADER([boost/bind.hpp])])
482
483
484
# BOOST_CONVERSION()
485
# ------------------
486
# Look for Boost.Conversion (cast / lexical_cast)
487
BOOST_DEFUN([Conversion],
488
[BOOST_FIND_HEADER([boost/cast.hpp])
489
BOOST_FIND_HEADER([boost/lexical_cast.hpp])
490
])# BOOST_CONVERSION
491
492
493
# BOOST_DATE_TIME([PREFERRED-RT-OPT])
494
# -----------------------------------
495
# Look for Boost.Date_Time.  For the documentation of PREFERRED-RT-OPT, see the
496
# documentation of BOOST_FIND_LIB above.
497
BOOST_DEFUN([Date_Time],
498
[BOOST_FIND_LIB([date_time], [$1],
499
                [boost/date_time/posix_time/posix_time.hpp],
500
                [boost::posix_time::ptime t;])
501
])# BOOST_DATE_TIME
502
503
504
# BOOST_FILESYSTEM([PREFERRED-RT-OPT])
505
# ------------------------------------
506
# Look for Boost.Filesystem.  For the documentation of PREFERRED-RT-OPT, see
507
# the documentation of BOOST_FIND_LIB above.
508
# Do not check for boost/filesystem.hpp because this file was introduced in
509
# 1.34.
510
BOOST_DEFUN([Filesystem],
511
[# Do we have to check for Boost.System?  This link-time dependency was
512
# added as of 1.35.0.  If we have a version <1.35, we must not attempt to
513
# find Boost.System as it didn't exist by then.
514
if test $boost_major_version -ge 135; then
515
BOOST_SYSTEM([$1])
516
fi # end of the Boost.System check.
517
boost_filesystem_save_LIBS=$LIBS
518
boost_filesystem_save_LDFLAGS=$LDFLAGS
519
m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl
520
LIBS="$LIBS $BOOST_SYSTEM_LIBS"
521
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS"
522
BOOST_FIND_LIB([filesystem], [$1],
523
                [boost/filesystem/path.hpp], [boost::filesystem::path p;])
524
if test $enable_static_boost = yes && test $boost_major_version -ge 135; then
525
    AC_SUBST([BOOST_FILESYSTEM_LIBS], ["$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS"])
526
fi
527
LIBS=$boost_filesystem_save_LIBS
528
LDFLAGS=$boost_filesystem_save_LDFLAGS
529
])# BOOST_FILESYSTEM
530
531
532
# BOOST_FOREACH()
533
# ---------------
534
# Look for Boost.Foreach
535
BOOST_DEFUN([Foreach],
536
[BOOST_FIND_HEADER([boost/foreach.hpp])])
537
538
539
# BOOST_FORMAT()
540
# --------------
541
# Look for Boost.Format
542
# Note: we can't check for boost/format/format_fwd.hpp because the header isn't
543
# standalone.  It can't be compiled because it triggers the following error:
544
# boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std'
545
#                                                  does not name a type
546
BOOST_DEFUN([Format],
547
[BOOST_FIND_HEADER([boost/format.hpp])])
548
549
550
# BOOST_FUNCTION()
551
# ----------------
552
# Look for Boost.Function
553
BOOST_DEFUN([Function],
554
[BOOST_FIND_HEADER([boost/function.hpp])])
555
556
557
# BOOST_GRAPH([PREFERRED-RT-OPT])
558
# -------------------------------
559
# Look for Boost.Graphs.  For the documentation of PREFERRED-RT-OPT, see the
560
# documentation of BOOST_FIND_LIB above.
561
BOOST_DEFUN([Graph],
562
[BOOST_FIND_LIB([graph], [$1],
563
                [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;])
564
])# BOOST_GRAPH
565
566
567
# BOOST_IOSTREAMS([PREFERRED-RT-OPT])
568
# -----------------------------------
569
# Look for Boost.IOStreams.  For the documentation of PREFERRED-RT-OPT, see the
570
# documentation of BOOST_FIND_LIB above.
571
BOOST_DEFUN([IOStreams],
572
[BOOST_FIND_LIB([iostreams], [$1],
573
                [boost/iostreams/device/file_descriptor.hpp],
574
                [boost::iostreams::file_descriptor fd; fd.close();])
575
])# BOOST_IOSTREAMS
576
577
578
# BOOST_HASH()
579
# ------------
580
# Look for Boost.Functional/Hash
581
BOOST_DEFUN([Hash],
582
[BOOST_FIND_HEADER([boost/functional/hash.hpp])])
583
584
585
# BOOST_LAMBDA()
586
# --------------
587
# Look for Boost.Lambda
588
BOOST_DEFUN([Lambda],
589
[BOOST_FIND_HEADER([boost/lambda/lambda.hpp])])
590
591
592
# BOOST_LOG([PREFERRED-RT-OPT])
593
# -----------------------------
594
# Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the
595
# documentation of BOOST_FIND_LIB above.
596
BOOST_DEFUN([Log],
597
[BOOST_FIND_LIB([log], [$1],
598
    [boost/log/core/core.hpp],
599
    [boost::log::attribute a; a.get_value();])
600
])# BOOST_LOG
601
602
603
# BOOST_LOG_SETUP([PREFERRED-RT-OPT])
604
# -----------------------------------
605
# Look for Boost.Log For the documentation of PREFERRED-RT-OPT, see the
606
# documentation of BOOST_FIND_LIB above.
607
BOOST_DEFUN([Log_Setup],
608
[AC_REQUIRE([BOOST_LOG])dnl
609
BOOST_FIND_LIB([log_setup], [$1],
610
    [boost/log/utility/init/from_settings.hpp],
611
    [boost::log::basic_settings<char> bs; bs.empty();])
612
])# BOOST_LOG_SETUP
613
614
615
# BOOST_MATH()
616
# ------------
617
# Look for Boost.Math
618
# TODO: This library isn't header-only but it comes in multiple different
619
# flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99,
620
# libboost_math_c99f, libboost_math_c99l, libboost_math_tr1,
621
# libboost_math_tr1f, libboost_math_tr1l).  This macro must be fixed to do the
622
# right thing anyway.
623
BOOST_DEFUN([Math],
624
[BOOST_FIND_HEADER([boost/math/special_functions.hpp])])
625
626
627
# BOOST_MULTIARRAY()
628
# ------------------
629
# Look for Boost.MultiArray
630
BOOST_DEFUN([MultiArray],
631
[BOOST_FIND_HEADER([boost/multi_array.hpp])])
632
633
634
# BOOST_NUMERIC_CONVERSION()
635
# --------------------------
636
# Look for Boost.NumericConversion (policy-based numeric conversion)
637
BOOST_DEFUN([Numeric_Conversion],
638
[BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp])
639
])# BOOST_NUMERIC_CONVERSION
640
641
642
# BOOST_OPTIONAL()
643
# ----------------
644
# Look for Boost.Optional
645
BOOST_DEFUN([Optional],
646
[BOOST_FIND_HEADER([boost/optional.hpp])])
647
648
649
# BOOST_PREPROCESSOR()
650
# --------------------
651
# Look for Boost.Preprocessor
652
BOOST_DEFUN([Preprocessor],
653
[BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])])
654
655
656
# BOOST_UNORDERED()
657
# -----------------
658
# Look for Boost.Unordered
659
BOOST_DEFUN([Unordered],
660
[BOOST_FIND_HEADER([boost/unordered_map.hpp])])
661
662
663
# BOOST_UUID()
664
# ------------
665
# Look for Boost.Uuid
666
BOOST_DEFUN([Uuid],
667
[BOOST_FIND_HEADER([boost/uuid/uuid.hpp])])
668
669
670
# BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT])
671
# -----------------------------------------
672
# Look for Boost.Program_options.  For the documentation of PREFERRED-RT-OPT,
673
# see the documentation of BOOST_FIND_LIB above.
674
BOOST_DEFUN([Program_Options],
675
[BOOST_FIND_LIB([program_options], [$1],
676
                [boost/program_options.hpp],
677
                [boost::program_options::options_description d("test");])
678
])# BOOST_PROGRAM_OPTIONS
679
680
681
682
# _BOOST_PYTHON_CONFIG(VARIABLE, FLAG)
683
# ------------------------------------
684
# Save VARIABLE, and define it via `python-config --FLAG`.
685
# Substitute BOOST_PYTHON_VARIABLE.
686
m4_define([_BOOST_PYTHON_CONFIG],
687
[AC_SUBST([BOOST_PYTHON_$1],
688
          [`python-config --$2 2>/dev/null`])dnl
689
boost_python_save_$1=$$1
690
$1="$$1 $BOOST_PYTHON_$1"])
691
692
693
# BOOST_PYTHON([PREFERRED-RT-OPT])
694
# --------------------------------
695
# Look for Boost.Python.  For the documentation of PREFERRED-RT-OPT,
696
# see the documentation of BOOST_FIND_LIB above.
697
BOOST_DEFUN([Python],
698
[_BOOST_PYTHON_CONFIG([CPPFLAGS], [includes])
699
_BOOST_PYTHON_CONFIG([LDFLAGS],   [ldflags])
700
_BOOST_PYTHON_CONFIG([LIBS],      [libs])
701
m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl
702
BOOST_FIND_LIB([python], [$1],
703
               [boost/python.hpp],
704
               [], [BOOST_PYTHON_MODULE(empty) {}])
705
CPPFLAGS=$boost_python_save_CPPFLAGS
706
LDFLAGS=$boost_python_save_LDFLAGS
707
LIBS=$boost_python_save_LIBS
708
])# BOOST_PYTHON
709
710
711
# BOOST_REF()
712
# -----------
713
# Look for Boost.Ref
714
BOOST_DEFUN([Ref],
715
[BOOST_FIND_HEADER([boost/ref.hpp])])
716
717
718
# BOOST_REGEX([PREFERRED-RT-OPT])
719
# -------------------------------
720
# Look for Boost.Regex.  For the documentation of PREFERRED-RT-OPT, see the
721
# documentation of BOOST_FIND_LIB above.
722
BOOST_DEFUN([Regex],
723
[BOOST_FIND_LIB([regex], [$1],
724
                [boost/regex.hpp],
725
                [boost::regex exp("*"); boost::regex_match("foo", exp);])
726
])# BOOST_REGEX
727
728
729
# BOOST_SERIALIZATION([PREFERRED-RT-OPT])
730
# ---------------------------------------
731
# Look for Boost.Serialization.  For the documentation of PREFERRED-RT-OPT, see
732
# the documentation of BOOST_FIND_LIB above.
733
BOOST_DEFUN([Serialization],
734
[BOOST_FIND_LIB([serialization], [$1],
735
                [boost/archive/text_oarchive.hpp],
736
                [std::ostream* o = 0; // Cheap way to get an ostream...
737
                boost::archive::text_oarchive t(*o);])
738
])# BOOST_SERIALIZATION
739
740
741
# BOOST_SIGNALS([PREFERRED-RT-OPT])
742
# ---------------------------------
743
# Look for Boost.Signals.  For the documentation of PREFERRED-RT-OPT, see the
744
# documentation of BOOST_FIND_LIB above.
745
BOOST_DEFUN([Signals],
746
[BOOST_FIND_LIB([signals], [$1],
747
                [boost/signal.hpp],
748
                [boost::signal<void ()> s;])
749
])# BOOST_SIGNALS
750
751
752
# BOOST_SMART_PTR()
753
# -----------------
754
# Look for Boost.SmartPtr
755
BOOST_DEFUN([Smart_Ptr],
756
[BOOST_FIND_HEADER([boost/scoped_ptr.hpp])
757
BOOST_FIND_HEADER([boost/shared_ptr.hpp])
758
])
759
760
761
# BOOST_STATICASSERT()
762
# --------------------
763
# Look for Boost.StaticAssert
764
BOOST_DEFUN([StaticAssert],
765
[BOOST_FIND_HEADER([boost/static_assert.hpp])])
766
767
768
# BOOST_STRING_ALGO()
769
# -------------------
770
# Look for Boost.StringAlgo
771
BOOST_DEFUN([String_Algo],
772
[BOOST_FIND_HEADER([boost/algorithm/string.hpp])
773
])
774
775
776
# BOOST_SYSTEM([PREFERRED-RT-OPT])
777
# --------------------------------
778
# Look for Boost.System.  For the documentation of PREFERRED-RT-OPT, see the
779
# documentation of BOOST_FIND_LIB above.  This library was introduced in Boost
780
# 1.35.0.
781
BOOST_DEFUN([System],
782
[BOOST_FIND_LIB([system], [$1],
783
                [boost/system/error_code.hpp],
784
                [boost::system::error_code e; e.clear();])
785
])# BOOST_SYSTEM
786
787
788
# BOOST_TEST([PREFERRED-RT-OPT])
789
# ------------------------------
790
# Look for Boost.Test.  For the documentation of PREFERRED-RT-OPT, see the
791
# documentation of BOOST_FIND_LIB above.
792
BOOST_DEFUN([Test],
793
[m4_pattern_allow([^BOOST_CHECK$])dnl
794
BOOST_FIND_LIB([unit_test_framework], [$1],
795
               [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);],
796
               [using boost::unit_test::test_suite;
797
               test_suite* init_unit_test_suite(int argc, char ** argv)
798
               { return NULL; }])
799
])# BOOST_TEST
800
801
802
# BOOST_THREADS([PREFERRED-RT-OPT])
803
# ---------------------------------
804
# Look for Boost.Thread.  For the documentation of PREFERRED-RT-OPT, see the
805
# documentation of BOOST_FIND_LIB above.
806
# FIXME: Provide an alias "BOOST_THREAD".
807
BOOST_DEFUN([Threads],
808
[dnl Having the pthread flag is required at least on GCC3 where
809
dnl boost/thread.hpp would complain if we try to compile without
810
dnl -pthread on GNU/Linux.
811
AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl
812
boost_threads_save_LIBS=$LIBS
813
boost_threads_save_CPPFLAGS=$CPPFLAGS
814
LIBS="$LIBS $boost_cv_pthread_flag"
815
# Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
816
# boost/thread.hpp will trigger a #error if -pthread isn't used:
817
#   boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
818
#   is not turned on. Please set the correct command line options for
819
#   threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
820
CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag"
821
BOOST_FIND_LIB([thread], [$1],
822
               [boost/thread.hpp], [boost::thread t; boost::mutex m;])
823
BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $boost_cv_pthread_flag"
824
BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag"
825
LIBS=$boost_threads_save_LIBS
826
CPPFLAGS=$boost_threads_save_CPPFLAGS
827
])# BOOST_THREADS
828
829
830
# BOOST_TOKENIZER()
831
# -----------------
832
# Look for Boost.Tokenizer
833
BOOST_DEFUN([Tokenizer],
834
[BOOST_FIND_HEADER([boost/tokenizer.hpp])])
835
836
837
# BOOST_TRIBOOL()
838
# ---------------
839
# Look for Boost.Tribool
840
BOOST_DEFUN([Tribool],
841
[BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp])
842
BOOST_FIND_HEADER([boost/logic/tribool.hpp])
843
])
844
845
846
# BOOST_TUPLE()
847
# -------------
848
# Look for Boost.Tuple
849
BOOST_DEFUN([Tuple],
850
[BOOST_FIND_HEADER([boost/tuple/tuple.hpp])])
851
852
853
# BOOST_TYPETRAITS()
854
# --------------------
855
# Look for Boost.TypeTraits
856
BOOST_DEFUN([TypeTraits],
857
[BOOST_FIND_HEADER([boost/type_traits.hpp])])
858
859
860
# BOOST_UTILITY()
861
# ---------------
862
# Look for Boost.Utility (noncopyable, result_of, base-from-member idiom,
863
# etc.)
864
BOOST_DEFUN([Utility],
865
[BOOST_FIND_HEADER([boost/utility.hpp])])
866
867
868
# BOOST_VARIANT()
869
# ---------------
870
# Look for Boost.Variant.
871
BOOST_DEFUN([Variant],
872
[BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp])
873
BOOST_FIND_HEADER([boost/variant.hpp])])
874
875
876
# BOOST_WAVE([PREFERRED-RT-OPT])
877
# ------------------------------
878
# NOTE: If you intend to use Wave/Spirit with thread support, make sure you
879
# call BOOST_THREADS first.
880
# Look for Boost.Wave.  For the documentation of PREFERRED-RT-OPT, see the
881
# documentation of BOOST_FIND_LIB above.
882
BOOST_DEFUN([Wave],
883
[AC_REQUIRE([BOOST_FILESYSTEM])dnl
884
AC_REQUIRE([BOOST_DATE_TIME])dnl
885
boost_wave_save_LIBS=$LIBS
886
boost_wave_save_LDFLAGS=$LDFLAGS
887
m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl
888
LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \
889
$BOOST_THREAD_LIBS"
890
LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \
891
$BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS"
892
BOOST_FIND_LIB([wave], [$1],
893
                [boost/wave.hpp],
894
                [boost::wave::token_id id; get_token_name(id);])
895
LIBS=$boost_wave_save_LIBS
896
LDFLAGS=$boost_wave_save_LDFLAGS
897
])# BOOST_WAVE
898
899
900
# BOOST_XPRESSIVE()
901
# -----------------
902
# Look for Boost.Xpressive (new since 1.36.0).
903
BOOST_DEFUN([Xpressive],
904
[BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])])
905
906
907
# ----------------- #
908
# Internal helpers. #
909
# ----------------- #
910
911
912
# _BOOST_PTHREAD_FLAG()
913
# ---------------------
914
# Internal helper for BOOST_THREADS.  Based on ACX_PTHREAD:
915
# http://autoconf-archive.cryp.to/acx_pthread.html
916
AC_DEFUN([_BOOST_PTHREAD_FLAG],
917
[AC_REQUIRE([AC_PROG_CXX])dnl
918
AC_REQUIRE([AC_CANONICAL_HOST])dnl
919
AC_LANG_PUSH([C++])dnl
920
AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag],
921
[ boost_cv_pthread_flag=
922
  # The ordering *is* (sometimes) important.  Some notes on the
923
  # individual items follow:
924
  # (none): in case threads are in libc; should be tried before -Kthread and
925
  #       other compiler flags to prevent continual compiler warnings
926
  # -lpthreads: AIX (must check this before -lpthread)
927
  # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
928
  # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
929
  # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
930
  # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
931
  # -pthreads: Solaris/GCC
932
  # -mthreads: MinGW32/GCC, Lynx/GCC
933
  # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
934
  #      doesn't hurt to check since this sometimes defines pthreads too;
935
  #      also defines -D_REENTRANT)
936
  #      ... -mt is also the pthreads flag for HP/aCC
937
  # -lpthread: GNU Linux, etc.
938
  # --thread-safe: KAI C++
939
  case $host_os in #(
940
    *solaris*)
941
      # On Solaris (at least, for some versions), libc contains stubbed
942
      # (non-functional) versions of the pthreads routines, so link-based
943
      # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
944
      # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
945
      # a function called by this macro, so we could check for that, but
946
      # who knows whether they'll stub that too in a future libc.)  So,
947
      # we'll just look for -pthreads and -lpthread first:
948
      boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #(
949
    *)
950
      boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \
951
                           -pthreads -mthreads -lpthread --thread-safe -mt";;
952
  esac
953
  # Generate the test file.
954
  AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <pthread.h>],
955
    [pthread_t th; pthread_join(th, 0);
956
    pthread_attr_init(0); pthread_cleanup_push(0, 0);
957
    pthread_create(0,0,0,0); pthread_cleanup_pop(0);])])
958
  for boost_pthread_flag in '' $boost_pthread_flags; do
959
    boost_pthread_ok=false
960
dnl Re-use the test file already generated.
961
    boost_pthreads__save_LIBS=$LIBS
962
    LIBS="$LIBS $boost_pthread_flag"
963
    AC_LINK_IFELSE([],
964
      [if grep ".*$boost_pthread_flag" conftest.err; then
965
         echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD
966
       else
967
         boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag
968
       fi])
969
    LIBS=$boost_pthreads__save_LIBS
970
    $boost_pthread_ok && break
971
  done
972
])
973
AC_LANG_POP([C++])dnl
974
])# _BOOST_PTHREAD_FLAG
975
976
977
# _BOOST_gcc_test(MAJOR, MINOR)
978
# -----------------------------
979
# Internal helper for _BOOST_FIND_COMPILER_TAG.
980
m4_define([_BOOST_gcc_test],
981
["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl
982
983
984
# _BOOST_FIND_COMPILER_TAG()
985
# --------------------------
986
# Internal.  When Boost is installed without --layout=system, each library
987
# filename will hold a suffix that encodes the compiler used during the
988
# build.  The Boost build system seems to call this a `tag'.
989
AC_DEFUN([_BOOST_FIND_COMPILER_TAG],
990
[AC_REQUIRE([AC_PROG_CXX])dnl
991
AC_REQUIRE([AC_CANONICAL_HOST])dnl
992
AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag],
993
[boost_cv_lib_tag=unknown
994
if test x$boost_cv_inc_path != xno; then
995
  AC_LANG_PUSH([C++])dnl
996
  # The following tests are mostly inspired by boost/config/auto_link.hpp
997
  # The list is sorted to most recent/common to oldest compiler (in order
998
  # to increase the likelihood of finding the right compiler with the
999
  # least number of compilation attempt).
1000
  # Beware that some tests are sensible to the order (for instance, we must
1001
  # look for MinGW before looking for GCC3).
1002
  # I used one compilation test per compiler with a #error to recognize
1003
  # each compiler so that it works even when cross-compiling (let me know
1004
  # if you know a better approach).
1005
  # Known missing tags (known from Boost's tools/build/v2/tools/common.jam):
1006
  #   como, edg, kcc, bck, mp, sw, tru, xlc
1007
  # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines
1008
  # the same defines as GCC's).
1009
  for i in \
1010
    _BOOST_gcc_test(4, 6) \
1011
    _BOOST_gcc_test(4, 5) \
1012
    _BOOST_gcc_test(4, 4) \
1013
    _BOOST_gcc_test(4, 3) \
1014
    _BOOST_gcc_test(4, 2) \
1015
    _BOOST_gcc_test(4, 1) \
1016
    _BOOST_gcc_test(4, 0) \
1017
    "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \
1018
     && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \
1019
         || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \
1020
    _BOOST_gcc_test(3, 4) \
1021
    _BOOST_gcc_test(3, 3) \
1022
    "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \
1023
    "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \
1024
    _BOOST_gcc_test(3, 2) \
1025
    "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \
1026
    _BOOST_gcc_test(3, 1) \
1027
    _BOOST_gcc_test(3, 0) \
1028
    "defined __BORLANDC__ @ bcb" \
1029
    "defined __ICC && (defined __unix || defined __unix__) @ il" \
1030
    "defined __ICL @ iw" \
1031
    "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \
1032
    _BOOST_gcc_test(2, 95) \
1033
    "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \
1034
    "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \
1035
    "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \
1036
    "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8"
1037
  do
1038
    boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '`
1039
    boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'`
1040
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1041
#if $boost_tag_test
1042
/* OK */
1043
#else
1044
# error $boost_tag_test
1045
#endif
1046
]])], [boost_cv_lib_tag=$boost_tag; break], [])
1047
  done
1048
AC_LANG_POP([C++])dnl
1049
  case $boost_cv_lib_tag in #(
1050
    # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed
1051
    # to "gcc41" for instance.
1052
    *-gcc | *'-gcc ') :;; #(  Don't re-add -gcc: it's already in there.
1053
    gcc*)
1054
      boost_tag_x=
1055
      case $host_os in #(
1056
        darwin*)
1057
          if test $boost_major_version -ge 136; then
1058
            # The `x' added in r46793 of Boost.
1059
            boost_tag_x=x
1060
          fi;;
1061
      esac
1062
      # We can specify multiple tags in this variable because it's used by
1063
      # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ...
1064
      boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc"
1065
      ;; #(
1066
    unknown)
1067
      AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]])
1068
      boost_cv_lib_tag=
1069
      ;;
1070
  esac
1071
fi])dnl end of AC_CACHE_CHECK
1072
])# _BOOST_FIND_COMPILER_TAG
1073
1074
1075
# _BOOST_GUESS_WHETHER_TO_USE_MT()
1076
# --------------------------------
1077
# Compile a small test to try to guess whether we should favor MT (Multi
1078
# Thread) flavors of Boost.  Sets boost_guess_use_mt accordingly.
1079
AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT],
1080
[# Check whether we do better use `mt' even though we weren't ask to.
1081
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1082
#if defined _REENTRANT || defined _MT || defined __MT__
1083
/* use -mt */
1084
#else
1085
# error MT not needed
1086
#endif
1087
]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false])
1088
])
1089
1090
# _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1091
# -------------------------------------------------------------------
1092
# Fork of _AC_LINK_IFELSE that preserves conftest.o across calls.  Fragile,
1093
# will break when Autoconf changes its internals.  Requires that you manually
1094
# rm -f conftest.$ac_objext in between to really different tests, otherwise
1095
# you will try to link a conftest.o left behind by a previous test.
1096
# Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this
1097
# macro).
1098
#
1099
# Don't use "break" in the actions, as it would short-circuit some code
1100
# this macro runs after the actions.
1101
m4_define([_BOOST_AC_LINK_IFELSE],
1102
[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
1103
rm -f conftest$ac_exeext
1104
boost_save_ac_ext=$ac_ext
1105
boost_use_source=:
1106
# If we already have a .o, re-use it.  We change $ac_ext so that $ac_link
1107
# tries to link the existing object file instead of compiling from source.
1108
test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false &&
1109
  _AS_ECHO_LOG([re-using the existing conftest.$ac_objext])
1110
AS_IF([_AC_DO_STDERR($ac_link) && {
1111
	 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
1112
	 test ! -s conftest.err
1113
       } && test -s conftest$ac_exeext && {
1114
	 test "$cross_compiling" = yes ||
1115
	 $as_executable_p conftest$ac_exeext
1116
dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough.
1117
       }],
1118
      [$2],
1119
      [if $boost_use_source; then
1120
         _AC_MSG_LOG_CONFTEST
1121
       fi
1122
       $3])
1123
ac_objext=$boost_save_ac_objext
1124
ac_ext=$boost_save_ac_ext
1125
dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
1126
dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
1127
dnl as it would interfere with the next link command.
1128
rm -f core conftest.err conftest_ipa8_conftest.oo \
1129
      conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl
1130
])# _BOOST_AC_LINK_IFELSE
1131
1132
# Local Variables:
1133
# mode: autoconf
1134
# End:
1135
1136
###############################################################################
1137
#
1138
# ====================================================================
1139
# ACX_PTHREAD
1140
# ====================================================================
1141
#
1142
# This script has been downloaded from
1143
# http://autoconf-archive.cryp.to/acx_pthread.html
1144
#
1145
# Copyright © 2006 Steven G. Johnson <stevenj@alum.mit.edu>
1146
#
1147
# This program is free software; you can redistribute it and/or modify
1148
# it under the terms of the GNU General Public License as published by
1149
# the Free Software Foundation; either version 2 of the License, or (at
1150
# your option) any later version.
1151
#
1152
# This program is distributed in the hope that it will be useful, but
1153
# WITHOUT ANY WARRANTY; without even the implied warranty of
1154
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1155
# General Public License for more details.
1156
#
1157
# You should have received a copy of the GNU General Public License
1158
# along with this program; if not, write to the Free Software
1159
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1160
# USA.
1161
#
1162
# As a special exception, the respective Autoconf Macro's copyright
1163
# owner gives unlimited permission to copy, distribute and modify the
1164
# configure scripts that are the output of Autoconf when processing the
1165
# Macro. You need not follow the terms of the GNU General Public
1166
# License when using or distributing such scripts, even though portions
1167
# of the text of the Macro appear in them. The GNU General Public
1168
# License (GPL) does govern all other use of the material that
1169
# constitutes the Autoconf Macro.
1170
#
1171
# This special exception to the GPL applies to versions of the
1172
# Autoconf Macro released by the Autoconf Macro Archive. When you make
1173
# and distribute a modified version of the Autoconf Macro, you may
1174
# extend this special exception to the GPL to apply to your modified
1175
# version as well.
1176
1177
AC_DEFUN([ACX_PTHREAD], [
1178
AC_REQUIRE([AC_CANONICAL_HOST])
1179
AC_LANG_SAVE
1180
AC_LANG_C
1181
acx_pthread_ok=no
1182
1183
# We used to check for pthread.h first, but this fails if pthread.h
1184
# requires special compiler flags (e.g. on True64 or Sequent).
1185
# It gets checked for in the link test anyway.
1186
1187
# First of all, check if the user has set any of the PTHREAD_LIBS,
1188
# etcetera environment variables, and if threads linking works using
1189
# them:
1190
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
1191
        save_CFLAGS="$CFLAGS"
1192
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1193
        save_LIBS="$LIBS"
1194
        LIBS="$PTHREAD_LIBS $LIBS"
1195
        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
1196
        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
1197
        AC_MSG_RESULT($acx_pthread_ok)
1198
        if test x"$acx_pthread_ok" = xno; then
1199
                PTHREAD_LIBS=""
1200
                PTHREAD_CFLAGS=""
1201
        fi
1202
        LIBS="$save_LIBS"
1203
        CFLAGS="$save_CFLAGS"
1204
fi
1205
1206
# We must check for the threads library under a number of different
1207
# names; the ordering is very important because some systems
1208
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
1209
# libraries is broken (non-POSIX).
1210
1211
# Create a list of thread flags to try.  Items starting with a "-" are
1212
# C compiler flags, and other items are library names, except for "none"
1213
# which indicates that we try without any flags at all, and "pthread-config"
1214
# which is a program returning the flags for the Pth emulation library.
1215
1216
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
1217
1218
# The ordering *is* (sometimes) important.  Some notes on the
1219
# individual items follow:
1220
1221
# pthreads: AIX (must check this before -lpthread)
1222
# none: in case threads are in libc; should be tried before -Kthread and
1223
#       other compiler flags to prevent continual compiler warnings
1224
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
1225
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
1226
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
1227
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
1228
# -pthreads: Solaris/gcc
1229
# -mthreads: Mingw32/gcc, Lynx/gcc
1230
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
1231
#      doesn't hurt to check since this sometimes defines pthreads too;
1232
#      also defines -D_REENTRANT)
1233
#      ... -mt is also the pthreads flag for HP/aCC
1234
# pthread: Linux, etcetera
1235
# --thread-safe: KAI C++
1236
# pthread-config: use pthread-config program (for GNU Pth library)
1237
1238
case "${host_cpu}-${host_os}" in
1239
        *solaris*)
1240
1241
        # On Solaris (at least, for some versions), libc contains stubbed
1242
        # (non-functional) versions of the pthreads routines, so link-based
1243
        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/
1244
        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
1245
        # a function called by this macro, so we could check for that, but
1246
        # who knows whether they'll stub that too in a future libc.)  So,
1247
        # we'll just look for -pthreads and -lpthread first:
1248
1249
        acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
1250
        ;;
1251
esac
1252
1253
if test x"$acx_pthread_ok" = xno; then
1254
for flag in $acx_pthread_flags; do
1255
1256
        case $flag in
1257
                none)
1258
                AC_MSG_CHECKING([whether pthreads work without any flags])
1259
                ;;
1260
1261
                -*)
1262
                AC_MSG_CHECKING([whether pthreads work with $flag])
1263
                PTHREAD_CFLAGS="$flag"
1264
                ;;
1265
1266
                pthread-config)
1267
                AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
1268
                if test x"$acx_pthread_config" = xno; then continue; fi
1269
                PTHREAD_CFLAGS="`pthread-config --cflags`"
1270
                PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
1271
                ;;
1272
1273
                *)
1274
                AC_MSG_CHECKING([for the pthreads library -l$flag])
1275
                PTHREAD_LIBS="-l$flag"
1276
                ;;
1277
        esac
1278
1279
        save_LIBS="$LIBS"
1280
        save_CFLAGS="$CFLAGS"
1281
        LIBS="$PTHREAD_LIBS $LIBS"
1282
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1283
1284
        # Check for various functions.  We must include pthread.h,
1285
        # since some functions may be macros.  (On the Sequent, we
1286
        # need a special flag -Kthread to make this header compile.)
1287
        # We check for pthread_join because it is in -lpthread on IRIX
1288
        # while pthread_create is in libc.  We check for pthread_attr_init
1289
        # due to DEC craziness with -lpthreads.  We check for
1290
        # pthread_cleanup_push because it is one of the few pthread
1291
        # functions on Solaris that doesn't have a non-functional libc stub.
1292
        # We try pthread_create on general principles.
1293
        AC_TRY_LINK([#include <pthread.h>],
1294
                    [pthread_t th; pthread_join(th, 0);
1295
                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
1296
                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
1297
                    [acx_pthread_ok=yes])
1298
1299
        LIBS="$save_LIBS"
1300
        CFLAGS="$save_CFLAGS"
1301
1302
        AC_MSG_RESULT($acx_pthread_ok)
1303
        if test "x$acx_pthread_ok" = xyes; then
1304
                break;
1305
        fi
1306
1307
        PTHREAD_LIBS=""
1308
        PTHREAD_CFLAGS=""
1309
done
1310
fi
1311
1312
# Various other checks:
1313
if test "x$acx_pthread_ok" = xyes; then
1314
        save_LIBS="$LIBS"
1315
        LIBS="$PTHREAD_LIBS $LIBS"
1316
        save_CFLAGS="$CFLAGS"
1317
        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
1318
1319
        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
1320
        AC_MSG_CHECKING([for joinable pthread attribute])
1321
        attr_name=unknown
1322
        for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
1323
            AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
1324
                        [attr_name=$attr; break])
1325
        done
1326
        AC_MSG_RESULT($attr_name)
1327
        if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
1328
            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
1329
                               [Define to necessary symbol if this constant
1330
                                uses a non-standard name on your system.])
1331
        fi
1332
1333
        AC_MSG_CHECKING([if more special flags are required for pthreads])
1334
        flag=no
1335
        case "${host_cpu}-${host_os}" in
1336
            *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
1337
            *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
1338
        esac
1339
        AC_MSG_RESULT(${flag})
1340
        if test "x$flag" != xno; then
1341
            PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
1342
        fi
1343
1344
        LIBS="$save_LIBS"
1345
        CFLAGS="$save_CFLAGS"
1346
1347
        # More AIX lossage: must compile with xlc_r or cc_r
1348
        if test x"$GCC" != xyes; then
1349
          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
1350
        else
1351
          PTHREAD_CC=$CC
1352
        fi
1353
else
1354
        PTHREAD_CC="$CC"
1355
fi
1356
1357
AC_SUBST(PTHREAD_LIBS)
1358
AC_SUBST(PTHREAD_CFLAGS)
1359
AC_SUBST(PTHREAD_CC)
1360
1361
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
1362
if test x"$acx_pthread_ok" = xyes; then
1363
        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
1364
        :
1365
else
1366
        acx_pthread_ok=no
1367
        $2
1368
fi
1369
AC_LANG_RESTORE
1370
])dnl ACX_PTHREAD
1371
1372
# ##########################################################################
1373
1374
# sets the search path which is used by MT_HAVE_PACKAGE
1375
AC_DEFUN([MT_SET_SEARCHPATH],
1376
[
1377
    AC_REQUIRE([AC_CANONICAL_HOST])
1378
1379
    MT_SEARCHPATH="/usr/local"
1380
    case $host in
1381
        *-*-darwin*)
1382
            MT_SEARCHPATH="/opt/local"
1383
        ;;
1384
    esac
1385
1386
    AC_ARG_WITH(search,
1387
        AC_HELP_STRING([--with-search=DIR], [additionally search for packages in DIR]),
1388
        [
1389
            MT_SEARCHPATH=$withval
1390
            AC_MSG_NOTICE([Will also search for packages in ${MT_SEARCHPATH}])
1391
        ]
1392
    )
1393
1394
    MT_SEARCHPATH_HEADERS="${MT_SEARCHPATH}/include"
1395
    MT_SEARCHPATH_LIBS="${MT_SEARCHPATH}/lib"
1396
    MT_SEARCHPATH_PROGS="${MT_SEARCHPATH}/bin"
1397
    MT_SEARCHPATH_PKGCONFIG="${MT_SEARCHPATH}/lib/pkgconfig"
1398
1399
    AC_SUBST(MT_SEARCHPATH)
1400
    AC_SUBST(MT_SEARCHPATH_HEADERS)
1401
    AC_SUBST(MT_SEARCHPATH_LIBS)
1402
    AC_SUBST(MT_SEARCHPATH_PROGS)
1403
    AC_SUBST(MT_SEARCHPATH_PKGCONFIG)
1404
])
1405
1406
1407
# $1 with parameter/package name
1408
# $2 library name
1409
# $3 function name
1410
# $4 "pass" if requested option failed
1411
# $5 other libraries
1412
#
1413
# returns:
1414
#   mt_$1_library_status
1415
#   mt_$1_libs
1416
#   mt_$1_ldflags
1417
1418
AC_DEFUN([MT_CHECK_LIBRARY_INTERNAL],
1419
[
1420
    mt_[]translit($1, `/.-', `___')_arg_default=yes
1421
    mt_[]translit($1, `/.-', `___')_library_status=yes
1422
1423
    LIBS_SAVE=$LIBS
1424
    LDFLAGS_SAVE=$LDFLAGS
1425
    CFLAGS_SAVE=$CFLAGS
1426
    CXXFLAGS_SAVE=$CXXFLAGS
1427
    CPPFLAGS_SAVE=$CPPFLAGS
1428
1429
    AC_ARG_WITH($1-libs,
1430
        AC_HELP_STRING([--with-$1-libs=DIR], [search for $1 libraries in DIR]),
1431
        [
1432
            mt_[]translit($1, `/.-', `___')_search_libs="$withval"
1433
            AC_MSG_NOTICE([Will search for $1 libs in $withval])
1434
        ]
1435
    )
1436
1437
    if test "$mt_[]translit($1, `/.-', `___')_search_libs" ; then
1438
        unset ac_cv_lib_[]translit($2, `/.-', `___')_$3
1439
        LDFLAGS="$LDFLAGS -L$mt_[]translit($1, `/.-', `___')_search_libs"
1440
        AC_CHECK_LIB($2, $3,
1441
            [
1442
                mt_[]translit($1, `/.-', `___')_libs="-l$2 $5"
1443
                mt_[]translit($1, `/.-', `___')_ldflags="-L$mt_[]translit($1, `/.-', `___')_search_libs"
1444
            ],
1445
            [
1446
                mt_[]translit($1, `/.-', `___')_library_status=missing
1447
                if test "$4" = "pass"; then
1448
                    AC_MSG_NOTICE([$1 library not found in requested location $mt_$1_search_libs])
1449
                else
1450
                    AC_MSG_ERROR([$1 library not found in requested location $mt_$1_search_libs])
1451
                fi
1452
            ],
1453
            [
1454
                $5
1455
            ]
1456
        )
1457
    else
1458
        unset ac_cv_lib_[]translit($2, `/.-', `___')_$3
1459
        AC_CHECK_LIB($2, $3,
1460
            [
1461
                mt_[]translit($1, `/.-', `___')_libs="-l$2 $5"
1462
            ],
1463
            [
1464
                LDFLAGS="$LDFLAGS -L$MT_SEARCHPATH_LIBS"
1465
                unset ac_cv_lib_[]translit($2, `/.-', `___')_$3
1466
                AC_CHECK_LIB($2, $3,
1467
                    [
1468
                        mt_[]translit($1, `/.-', `___')_libs="-l$2 $5"
1469
                        mt_[]translit($1, `/.-', `___')_ldflags="-L$MT_SEARCHPATH_LIBS" 
1470
                    ],
1471
                    [
1472
                        mt_[]translit($1, `/.-', `___')_library_status=missing
1473
                    ],
1474
                    [
1475
                        $5
1476
                    ]
1477
                )
1478
            ],
1479
            [
1480
                $5
1481
            ]
1482
1483
        )
1484
    fi
1485
1486
    if test "x$mt_[]translit($1, `/.-', `___')_library_status" != xyes; then
1487
        mt_[]translit($1, `/.-', `___')_libs=""
1488
        mt_[]translit($1, `/.-', `___')_ldflags=""
1489
    fi
1490
1491
    LIBS=$LIBS_SAVE
1492
    LDFLAGS=$LDFLAGS_SAVE
1493
    CFLAGS=$CFLAGS_SAVE
1494
    CXXFLAGS=$CXXFLAGS_SAVE
1495
    CPPFLAGS=$CPPFLAGS_SAVE
1496
])
1497
1498
# $1 with parameter / library name
1499
# $2 header without .h extension
1500
# $3 fail / pass
1501
#
1502
# returns:
1503
#   mt_$1_header_status
1504
#   mt_$1_cxxflags
1505
1506
AC_DEFUN([MT_CHECK_HEADER_INTERNAL],
1507
[
1508
    LIBS_SAVE=$LIBS
1509
    LDFLAGS_SAVE=$LDFLAGS
1510
    CFLAGS_SAVE=$CFLAGS
1511
    CXXFLAGS_SAVE=$CXXFLAGS
1512
    CPPFLAGS_SAVE=$CPPFLAGS
1513
1514
    mt_[]translit($1, `/.-', `___')_header_status=yes
1515
1516
    AC_ARG_WITH($1-h,
1517
        AC_HELP_STRING([--with-$1-h=DIR], [search for $1 headers in DIR]),
1518
        [
1519
            mt_[]translit($1, `/.-', `___')_search_headers="$withval"
1520
            AC_MSG_NOTICE([Will search for $1 headers in $withval])
1521
        ]
1522
    )
1523
1524
    if test "$mt_[]translit($1, `/.-', `___')_search_headers" ; then
1525
        unset translit(ac_cv_header_$2_h, `/.-', `___')
1526
        CFLAGS="$CFLAGS -I${mt_[]translit($1, `/.-', `___')_search_headers}"
1527
        CXXFLAGS="$CXXFLAGS -I${mt_[]translit($1, `/.-', `___')_search_headers}"
1528
        CPPFLAGS="$CPPFLAGS -I${mt_[]translit($1, `/.-', `___')_search_headers}"
1529
        AC_CHECK_HEADER($mt_[]translit($1, `/.-', `___')_search_headers/$2.h,
1530
            [
1531
                mt_[]translit($1, `/.-', `___')_cxxflags="-I${mt_[]translit($1, `/.-', `___')_search_headers}"
1532
            ],
1533
            [
1534
                mt_[]translit($1, `/.-', `___')_header_status=missing
1535
                if test "$3" = "pass"; then
1536
                    AC_MSG_NOTICE([$1 headers not found in requested location $mt_$1_search_headers])
1537
                else
1538
                    AC_MSG_ERROR([$1 headers not found in requested location $mt_$1_search_headers])
1539
                fi
1540
            ]
1541
        )
1542
    else
1543
        unset translit(ac_cv_header_$2_h, `/.-', `___')
1544
        AC_CHECK_HEADER($2.h,
1545
            [],
1546
            [
1547
                CFLAGS="$CFLAGS -I$MT_SEARCHPATH_HEADERS"
1548
                CXXFLAGS="$CXXFLAGS -I$MT_SEARCHPATH_HEADERS"
1549
                CPPFLAGS="$CPPFLAGS -I$MT_SEARCHPATH_HEADERS"
1550
                unset translit(ac_cv_header_$2_h, `/.-', `___')
1551
                AC_CHECK_HEADER($MT_SEARCHPATH_HEADERS/$2.h,
1552
                    [
1553
                        mt_[]translit($1, `/.-', `___')_cxxflags="-I${MT_SEARCHPATH_HEADERS}"
1554
                    ],
1555
                    [
1556
                        mt_[]translit($1, `/.-', `___')_header_status=missing
1557
                        if test "$3" = "pass"; then
1558
                            AC_MSG_NOTICE([$1 headers not found in requested location $mt_$1_search_headers])
1559
                        else
1560
                            AC_MSG_ERROR([$1 headers not found in requested location $mt_$1_search_headers])
1561
                        fi
1562
                    ]
1563
                )
1564
            ]
1565
        )
1566
    fi
1567
1568
    if test "x$mt_[]translit($1, `/.-', `___')_header_status" != xyes; then
1569
        mt_[]translit($1, `/.-', `___')_cxxflags=""
1570
    fi
1571
1572
    LIBS=$LIBS_SAVE
1573
    LDFLAGS=$LDFLAGS_SAVE
1574
    CFLAGS=$CFLAGS_SAVE
1575
    CXXFLAGS=$CXXFLAGS_SAVE
1576
    CPPFLAGS=$CPPFLAGS_SAVE
1577
])
1578
1579
1580
# $1 package name
1581
# $2 header name (without .h extension)
1582
# $3 library name
1583
# $4 function name
1584
# $5 "pass" if requested options failed
1585
# $6 additional LDFLAGS
1586
#
1587
# returns:
1588
#   mt_$1_package_status
1589
#   $1_CFLAGS
1590
#   $1_LIBS
1591
#   $1_LDFLAGS
1592
   
1593
AC_DEFUN([MT_CHECK_PACKAGE_INTERNAL],
1594
[
1595
    MT_CHECK_HEADER_INTERNAL([$1], [$2], [$5])
1596
    mt_[]translit($1, `/.-', `___')_package_status=${mt_[]translit($1, `/.-', `___')_header_status}
1597
  
1598
    if test "x$mt_[]translit($1, `/.-', `___')_package_status" = xyes; then 
1599
        MT_CHECK_LIBRARY_INTERNAL([$1], [$3], [$4], [$5], [$6])
1600
        mt_[]translit($1, `/.-', `___')_package_status=${mt_[]translit($1, `/.-', `___')_library_status}
1601
    fi
1602
    
1603
    if test "x$mt_[]translit($1, `/.-', `___')_package_status" = xyes; then
1604
        translit($1, `a-z/.-', `A-Z___')_CFLAGS=${mt_[]translit($1, `/.-', `___')_cxxflags}
1605
        translit($1, `a-z/.-', `A-Z___')_LIBS=${mt_[]translit($1, `/.-', `___')_libs}
1606
        translit($1, `a-z/.-', `A-Z___')_LDFLAGS=${mt_[]translit($1, `/.-', `___')_ldflags}
1607
    fi 
1608
])
1609
1610
# $1 option name
1611
# $2 enable/disable
1612
# $3 help text
1613
# $4 action if enabled
1614
# $5 action if disabled
1615
#
1616
# returns:
1617
#   $1_OPTION_ENABLED
1618
#   $1_OPTION_REQUESTED
1619
1620
AC_DEFUN([MT_OPTION],
1621
[
1622
1623
    translit(mt_$1_option_enabled, `/.-', `___')=
1624
    translit(mt_$1_option_requested, `/.-', `___')=no
1625
    if test "x$2" = xdisable; then
1626
        translit(mt_$1_option_enabled, `/.-', `___')=yes
1627
    else
1628
        translit(mt_$1_option_enabled, `/.-', `___')=no
1629
    fi
1630
1631
    AC_ARG_ENABLE([$1],
1632
        AC_HELP_STRING([--$2-$1], [$3]),
1633
        [
1634
            translit(mt_$1_option_enabled, `/.-', `___')=$enableval
1635
            translit(mt_$1_option_requested, `/.-', `___')=yes
1636
        ]
1637
    )
1638
1639
    translit($1, `a-z/.-', `A-Z___')_OPTION_ENABLED=${translit(mt_$1_option_enabled,`/.-', `___')}
1640
    translit($1, `a-z/.-', `A-Z___')_OPTION_REQUESTED=${translit(mt_$1_option_requested, `/.-', `___')}
1641
1642
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_OPTION_ENABLED)
1643
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_OPTION_REQUESTED)
1644
1645
    AS_IF([test "x${translit(mt_$1_option_enabled,`/.-', `___')}" = xyes], [$4], [$5])[]dnl
1646
])
1647
1648
# $1 package name
1649
# $2 enable/disable
1650
# $3 enable/disable help string
1651
# $4 header name (without .h)
1652
# $5 library name
1653
# $6 function name
1654
# $7 "pass" on requested options
1655
# $8 additional LDFLAGS
1656
# returns substed:
1657
#   $1_STATUS
1658
#   $1_LDFLAGS
1659
#   $1_LIBS
1660
#   $1_CFLAGS
1661
1662
AC_DEFUN([MT_CHECK_OPTIONAL_PACKAGE], 
1663
[
1664
    mt_[]translit($1, `/.-', `___')_status=yes
1665
1666
    MT_OPTION([$1], [$2], [$3],[],[])
1667
1668
    if test "x${translit($1, `a-z/.-', `A-Z___')_OPTION_ENABLED}" = xyes; then
1669
        MT_CHECK_PACKAGE_INTERNAL([$1], [$4], [$5], [$6], [$7], [$8])
1670
        mt_[]translit($1, `/.-', `___')_status=${mt_[]translit($1, `/.-', `___')_package_status}
1671
    else
1672
        mt_[]translit($1, `/.-', `___')_status=disabled
1673
    fi
1674
    
1675
    if ((test "x${translit($1, `a-z/.-', `A-Z___')_OPTION_ENABLED}" = xyes) &&
1676
        (test "x${translit($1, `a-z/.-', `A-Z___')_OPTION_REQUESTED}" = xyes) &&
1677
        (test "x$mt_[]translit($1, `/.-', `___')_status" != xyes) && (test "$7" != "pass")); then
1678
        AC_MSG_ERROR([unable to configure $1 support])
1679
    fi
1680
1681
    if test "x$mt_[]translit($1, `/.-', `___')_status" = xyes; then
1682
        AC_DEFINE(translit(HAVE_$1, `a-z/.-', `A-Z___'), [1], [$1 library presence])
1683
    fi
1684
    
1685
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_[]translit($1, `/.-', `___')_status}
1686
1687
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
1688
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LDFLAGS)
1689
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
1690
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1691
])
1692
1693
# $1 package name
1694
# $2 header name (without .h)
1695
# $3 library name
1696
# $4 function name
1697
# $5 additional ldflags
1698
#
1699
# returns substed:
1700
#   $1_STATUS
1701
#   $1_LDFLAGS
1702
#   $1_LIBS
1703
#   $1_CFLAGS
1704
1705
1706
AC_DEFUN([MT_CHECK_REQUIRED_PACKAGE],
1707
[
1708
    MT_CHECK_PACKAGE_INTERNAL([$1], [$2], [$3], [$4], [], [$5])
1709
    if test "x$mt_[]translit($1, `/.-', `___')_package_status" != xyes; then
1710
        AC_MSG_ERROR([unable to configure required package $1])
1711
    fi
1712
1713
    AC_DEFINE(translit(HAVE_$1, `a-z/.-', `A-Z___'), [1], [$1 library presence])
1714
    
1715
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_[]translit($1, `/.-', `___')_package_status}
1716
1717
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
1718
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
1719
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LDFLAGS)
1720
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1721
])
1722
1723
# $1 with parameter name
1724
# $2 library name
1725
# $3 function to check
1726
AC_DEFUN([MT_CHECK_LIBRARY],
1727
[
1728
    MT_CHECK_LIBRARY_INTERNAL([$1], [$2], [$3])
1729
1730
    translit($1, `a-z/.-', `A-Z___')_LIBS=${mt_$1_libs}
1731
    translit($1, `a-z/.-', `A-Z___')_LDFLAGS=${mt_$1_ldflags}
1732
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_$1_library_status}
1733
    
1734
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
1735
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LDFLAGS)
1736
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1737
])
1738
1739
# $1 with parameter name
1740
# $2 header to check
1741
# $3 fail or pass in case a path parameter was specified and the header missing
1742
#    empty: fail
1743
AC_DEFUN([MT_CHECK_HEADER],
1744
[
1745
    MT_CHECK_HEADER_INTERNAL($1, $2, $3)
1746
    
1747
    translit($1, `a-z/.-', `A-Z___')_CFLAGS=${mt_$1_cxxflags}
1748
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_$1_header_status}
1749
1750
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
1751
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1752
])
1753
1754
# $1 package name
1755
# $2 config file name
1756
# $3 headers
1757
# $4 library name
1758
# $5 function name
1759
# $6 optional library command
1760
#
1761
#  returns substed:
1762
#    $mt_$1_package_status
1763
#    $1_LDFLAGS
1764
#    $1_LIBS
1765
#    $1_CFLAGS
1766
1767
AC_DEFUN([MT_CHECK_BINCONFIG_INTERNAL],
1768
[
1769
    LIBS_SAVE=$LIBS
1770
    LDFLAGS_SAVE=$LDFLAGS
1771
    CFLAGS_SAVE=$CFLAGS
1772
    CXXFLAGS_SAVE=$CXXFLAGS
1773
    CPPFLAGS_SAVE=$CPPFLAGS
1774
1775
1776
    mt_$1_config=none
1777
    mt_$1_package_status=yes
1778
1779
    AC_ARG_WITH($1-cfg,
1780
        AC_HELP_STRING([--with-$1-cfg=$2], [absolute path/name of $2]),
1781
        [
1782
            mt_$1_search_config="$withval"
1783
            AC_MSG_NOTICE([Will search for $1 config in $withval])
1784
        ]
1785
    )
1786
1787
    if test -n "$mt_$1_search_config"; then
1788
        AC_MSG_NOTICE([You specified ${mt_$1_search_config} for $2])
1789
        if test -f "$mt_$1_search_config"; then
1790
            mt_$1_config=${mt_$1_search_config}
1791
        else
1792
            AC_MSG_ERROR([${mt_$1_search_config} not found])
1793
        fi
1794
1795
        mt_$1_version=`${mt_$1_config} --version 2>/dev/null`
1796
        if test -z "$mt_$1_version"; then
1797
            AC_MSG_ERROR([${mt_$1_search_config} could not be executed or returned invalid values])
1798
        fi
1799
    else
1800
        AC_PATH_PROG(mt_$1_config, $2, none)
1801
        if test "x$mt_$1_config" = xnone; then
1802
            unset ac_cv_path_mt_$1_config
1803
            AC_PATH_PROG(mt_$1_config, $2, none, $MT_SEARCHPATH_PROGS)
1804
            if test "x$mt_$1_config" = xnone; then
1805
                mt_$1_package_status=missing
1806
                AC_MSG_RESULT([$2 not found, please install the $1 devel package])
1807
            fi
1808
        fi
1809
       
1810
        mt_$1_version=`${mt_$1_config} --version 2>/dev/null`
1811
        if test -z "$mt_$1_version"; then
1812
            AC_MSG_NOTICE([${mt_$1_config} could not be executed or returned invalid values])
1813
            mt_$1_package_status=missing
1814
        fi
1815
    fi
1816
    if test "x$mt_$1_package_status" = xyes; then
1817
        AC_MSG_CHECKING([$1 cflags])
1818
        mt_$1_cxxflags=`${mt_$1_config} --cflags`
1819
        AC_MSG_RESULT([$mt_$1_cxxflags])
1820
        mt_$1_libs=
1821
        AC_MSG_CHECKING([$1 libs])
1822
        if test -z "$6";  then
1823
            mt_$1_libs=`${mt_$1_config} --libs`
1824
        else
1825
            mt_$1_libs=`${mt_$1_config} $6`
1826
        fi
1827
        AC_MSG_RESULT([$mt_$1_libs])
1828
    fi
1829
1830
    if test "x$mt_$1_package_status" = xyes; then
1831
        CPPFLAGS="$CPPFLAGS $mt_$1_cxxflags"
1832
        CXXFLAGS="$CXXFLAGS $mt_$1_cxxflags"
1833
        CFLAGS="$CFLAGS $mt_$1_cxxflags"
1834
        for mt_u_header in translit($3, `/.-', `___'); do
1835
            unset ac_cv_header_${mt_u_header}
1836
        done
1837
        AC_CHECK_HEADERS($3, [], [mt_$1_package_status=missing])
1838
    fi
1839
1840
    if test "x$mt_$1_package_status" = xyes; then
1841
        LIBS="$mt_$1_libs $LIBS"
1842
        if test -z "$4"; then
1843
            unset ac_cv_func_$5
1844
            AC_CHECK_FUNCS($5, [], [mt_$1_package_status=missing])
1845
        else
1846
            unset ac_cv_lib_$4_$5
1847
            AC_CHECK_LIB($4, $5, [], [mt_$1_package_status=missing])
1848
        fi
1849
    fi
1850
1851
    if test "x$mt_$1_package_status" = xyes; then
1852
        translit($1, `a-z/.-', `A-Z___')_CFLAGS=${mt_$1_cxxflags}
1853
        translit($1, `a-z/.-', `A-Z___')_LIBS=${mt_$1_libs}
1854
        translit($1, `a-z/.-', `A-Z___')_VERSION=${mt_$1_version}
1855
    fi 
1856
1857
1858
    LIBS=$LIBS_SAVE
1859
    LDFLAGS=$LDFLAGS_SAVE
1860
    CFLAGS=$CFLAGS_SAVE
1861
    CXXFLAGS=$CXXFLAGS_SAVE
1862
    CPPFLAGS=$CPPFLAGS_SAVE
1863
])
1864
1865
# $1 package name
1866
# $2 enable/disable
1867
# $3 enable/disable help string
1868
# $4 config file name
1869
# $5 headers
1870
# $6 library name
1871
# $7 function name
1872
# $8 custom lib parameter
1873
#
1874
# returns:
1875
#   mt_$1_package_status
1876
#   $1_CFLAGS
1877
#   $1_LIBS
1878
#   $1_VERSION
1879
1880
AC_DEFUN([MT_CHECK_OPTIONAL_PACKAGE_CFG],
1881
[
1882
    mt_$1_status=yes
1883
    mt_$1_requested=no
1884
1885
    MT_OPTION([$1], [$2], [$3],[],[])
1886
1887
    if test "x${translit($1, `a-z/.-', `A-Z___')_OPTION_ENABLED}" = xyes; then
1888
        MT_CHECK_BINCONFIG_INTERNAL($1, $4, $5, $6, $7, $8)
1889
        mt_$1_status=${mt_$1_package_status}
1890
    else
1891
        mt_$1_status=disabled
1892
    fi
1893
 
1894
    if ((test "x${translit($1, `a-z/.-', `A-Z___')_OPTION_ENABLED}" = xyes) &&
1895
        (test "x${translit($1, `a-z/.-', `A-Z___')_OPTION_REQUESTED}" = xyes) &&
1896
        (test "x$mt_$1_status" != xyes)); then
1897
        AC_MSG_ERROR([unable to configure $1 support])
1898
    fi
1899
   
1900
    if test "x$mt_$1_status" = xyes; then
1901
        AC_DEFINE(translit(HAVE_$1, `a-z/.-', `A-Z___'), [1], [$1 library presence])
1902
    fi
1903
1904
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_$1_status}
1905
1906
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
1907
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
1908
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_VERSION)
1909
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1910
1911
1912
#    AS_IF([test x"$mt_$1_status" = xyes], [$8], [$9])[]dnl
1913
])
1914
1915
# $1 package name
1916
# $2 config file name
1917
# $3 headers
1918
# $4 library name
1919
# $5 function name
1920
#
1921
#  returns substed:
1922
#    $mt_$1_package_status
1923
#    $1_LDFLAGS
1924
#    $1_LIBS
1925
#    $1_CFLAGS
1926
1927
AC_DEFUN([MT_CHECK_REQUIRED_PACKAGE_CFG],
1928
[
1929
    MT_CHECK_BINCONFIG_INTERNAL($1, $2, $3, $4, $5)
1930
    if test "x$mt_$1_package_status" != xyes; then
1931
        AC_MSG_ERROR([unable to configure required package $1])
1932
    fi
1933
    
1934
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_$1_package_status}
1935
        
1936
    AC_DEFINE(translit(HAVE_$1, `a-z/.-', `A-Z___'), [1], [$1 library presence])
1937
1938
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
1939
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
1940
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_VERSION)
1941
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1942
])
1943
1944
# $1 package name
1945
# $2 config file name
1946
# $3 headers
1947
# $4 library name
1948
# $5 function name
1949
#
1950
#  returns substed:
1951
#    $mt_$1_package_status
1952
#    $1_LDFLAGS
1953
#    $1_LIBS
1954
#    $1_CFLAGS
1955
1956
1957
AC_DEFUN([MT_CHECK_PACKAGE_CFG],
1958
[
1959
    mt_$1_status=yes
1960
1961
    if test "x$mt_$1_status" = xyes; then
1962
        MT_CHECK_BINCONFIG_INTERNAL($1, $2, $3, $4, $5)
1963
        mt_$1_status=${mt_$1_package_status}
1964
    fi
1965
    
1966
    if test "x$mt_$1_status" = xyes; then
1967
        AC_DEFINE(translit(HAVE_$1, `a-z/.-', `A-Z___'), [1], [$1 library presence])
1968
    fi
1969
1970
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_$1_status}
1971
1972
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
1973
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
1974
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_VERSION)
1975
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
1976
])
1977
1978
# $1 package name
1979
# $2 headers
1980
# $3 library name
1981
# $4 function name
1982
# $5 additional LDFLAGS
1983
#
1984
#  returns substed:
1985
#    $mt_$1_package_status
1986
#    $1_LDFLAGS
1987
#    $1_LIBS
1988
#    $1_CFLAGS
1989
1990
1991
AC_DEFUN([MT_CHECK_PACKAGE],
1992
[
1993
    mt_[]translit($1, `/.-', `___')_status=yes
1994
1995
    if test "x$mt_[]translit($1, `/.-', `___')_status" = xyes; then
1996
        MT_CHECK_PACKAGE_INTERNAL([$1], [$2], [$3], [$4], [], [$5])
1997
        mt_[]translit($1, `/.-', `___')_status=${mt_[]translit($1, `/.-', `___')_package_status}
1998
    fi
1999
2000
    if test "x$mt_[]translit($1, `/.-', `___')_status" = xyes; then
2001
        AC_DEFINE(translit(HAVE_$1, `a-z/.-', `A-Z___'), [1], [$1 library presence])
2002
    fi
2003
2004
    translit($1, `a-z/.-', `A-Z___')_STATUS=${mt_[]translit($1, `/.-', `___')_status}
2005
2006
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_CFLAGS)
2007
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_LIBS)
2008
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_VERSION)
2009
    AC_SUBST(translit($1, `a-z/.-', `A-Z___')_STATUS)
2010
])