| | 337 | dnl @synopsis AX_BOOST([MINIMUM-VERSION]) |
| | 338 | dnl |
| | 339 | dnl Test for the Boost C++ libraries of a particular version (or newer) |
| | 340 | dnl |
| | 341 | dnl If no path to the installed boost library is given the macro |
| | 342 | dnl searchs under /usr, /usr/local, and /opt, and evaluates the |
| | 343 | dnl $BOOST_ROOT environment variable. Further documentation is |
| | 344 | dnl available at <http://randspringer.de/boost/index.html>. |
| | 345 | dnl |
| | 346 | dnl This macro calls: |
| | 347 | dnl |
| | 348 | dnl AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) |
| | 349 | dnl |
| | 350 | dnl And sets: |
| | 351 | dnl |
| | 352 | dnl HAVE_BOOST |
| | 353 | dnl |
| | 354 | dnl @category InstalledPackages |
| | 355 | dnl @category Cxx |
| | 356 | dnl @author Thomas Porschberg <thomas@randspringer.de> |
| | 357 | dnl @version 2006-06-15 |
| | 358 | dnl @license AllPermissive |
| | 359 | AC_DEFUN([AX_BOOST_BASE], |
| | 360 | [ |
| | 361 | AC_ARG_WITH([boost], |
| | 362 | AS_HELP_STRING([--with-boost-dir@<:@=DIR@:>@], [specify boost directory (optional)]), |
| | 363 | [ |
| | 364 | if test "$withval" = "yes"; then |
| | 365 | ac_boost_path="" |
| | 366 | else |
| | 367 | ac_boost_path="$withval" |
| | 368 | fi |
| | 369 | ]) |
| | 370 | |
| | 371 | boost_lib_version_req=ifelse([$1], ,1.31.0,$1) |
| | 372 | boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` |
| | 373 | boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` |
| | 374 | boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` |
| | 375 | boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` |
| | 376 | if test "x$boost_lib_version_req_sub_minor" = "x" ; then |
| | 377 | boost_lib_version_req_sub_minor="0" |
| | 378 | fi |
| | 379 | WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` |
| | 380 | AC_MSG_CHECKING(for Boost >= $boost_lib_version_req) |
| | 381 | succeeded=no |
| | 382 | |
| | 383 | dnl first we check the system location for boost libraries |
| | 384 | dnl this location ist chosen if boost libraries are installed with the --layout=system option |
| | 385 | dnl or if you install boost with RPM |
| | 386 | if test "$ac_boost_path" != ""; then |
| | 387 | BOOST_LDFLAGS="-L$ac_boost_path/lib" |
| | 388 | BOOST_CPPFLAGS="-I$ac_boost_path/include" |
| | 389 | else |
| | 390 | for ac_boost_path_tmp in /usr /usr/local /opt ; do |
| | 391 | if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then |
| | 392 | BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib" |
| | 393 | BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" |
| | 394 | break; |
| | 395 | fi |
| | 396 | done |
| | 397 | fi |
| | 398 | |
| | 399 | CPPFLAGS_SAVED="$CPPFLAGS" |
| | 400 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
| | 401 | export CPPFLAGS |
| | 402 | |
| | 403 | LDFLAGS_SAVED="$LDFLAGS" |
| | 404 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
| | 405 | export LDFLAGS |
| | 406 | |
| | 407 | AC_LANG_PUSH(C++) |
| | 408 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
| | 409 | @%:@include <boost/version.hpp> |
| | 410 | ]], [[ |
| | 411 | #if BOOST_VERSION >= $WANT_BOOST_VERSION |
| | 412 | // Everything is okay |
| | 413 | #else |
| | 414 | # error Boost version is too old |
| | 415 | #endif |
| | 416 | ]])],[ |
| | 417 | AC_MSG_RESULT(yes) |
| | 418 | succeeded=yes |
| | 419 | found_system=yes |
| | 420 | ],[ |
| | 421 | ]) |
| | 422 | AC_LANG_POP([C++]) |
| | 423 | |
| | 424 | dnl if we found no boost with system layout we search for boost libraries |
| | 425 | dnl built and installed without the --layout=system option or for a staged(not installed) version |
| | 426 | if test "x$succeeded" != "xyes"; then |
| | 427 | _version=0 |
| | 428 | if test "$ac_boost_path" != ""; then |
| | 429 | BOOST_LDFLAGS="-L$ac_boost_path/lib" |
| | 430 | if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then |
| | 431 | for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do |
| | 432 | _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` |
| | 433 | V_CHECK=`expr $_version_tmp \> $_version` |
| | 434 | if test "$V_CHECK" = "1" ; then |
| | 435 | _version=$_version_tmp |
| | 436 | fi |
| | 437 | VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` |
| | 438 | BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" |
| | 439 | done |
| | 440 | fi |
| | 441 | else |
| | 442 | for ac_boost_path in /usr /usr/local /opt ; do |
| | 443 | if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then |
| | 444 | for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do |
| | 445 | _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` |
| | 446 | V_CHECK=`expr $_version_tmp \> $_version` |
| | 447 | if test "$V_CHECK" = "1" ; then |
| | 448 | _version=$_version_tmp |
| | 449 | best_path=$ac_boost_path |
| | 450 | fi |
| | 451 | done |
| | 452 | fi |
| | 453 | done |
| | 454 | |
| | 455 | VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` |
| | 456 | BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" |
| | 457 | BOOST_LDFLAGS="-L$best_path/lib" |
| | 458 | |
| | 459 | if test "x$BOOST_ROOT" != "x"; then |
| | 460 | if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then |
| | 461 | version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` |
| | 462 | stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` |
| | 463 | stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` |
| | 464 | V_CHECK=`expr $stage_version_shorten \>\= $_version` |
| | 465 | if test "$V_CHECK" = "1" ; then |
| | 466 | AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) |
| | 467 | BOOST_CPPFLAGS="-I$BOOST_ROOT" |
| | 468 | BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib" |
| | 469 | fi |
| | 470 | fi |
| | 471 | fi |
| | 472 | fi |
| | 473 | |
| | 474 | CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
| | 475 | export CPPFLAGS |
| | 476 | LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
| | 477 | export LDFLAGS |
| | 478 | |
| | 479 | AC_LANG_PUSH(C++) |
| | 480 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
| | 481 | @%:@include <boost/version.hpp> |
| | 482 | ]], [[ |
| | 483 | #if BOOST_VERSION >= $WANT_BOOST_VERSION |
| | 484 | // Everything is okay |
| | 485 | #else |
| | 486 | # error Boost version is too old |
| | 487 | #endif |
| | 488 | ]])],[ |
| | 489 | AC_MSG_RESULT(yes) |
| | 490 | succeeded=yes |
| | 491 | found_system=yes |
| | 492 | ],[ |
| | 493 | ]) |
| | 494 | AC_LANG_POP([C++]) |
| | 495 | fi |
| | 496 | |
| | 497 | if test "$succeeded" != "yes" ; then |
| | 498 | if test "$_version" = "0" ; then |
| | 499 | 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.]]) |
| | 500 | else |
| | 501 | AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) |
| | 502 | fi |
| | 503 | else |
| | 504 | AC_SUBST(BOOST_CPPFLAGS) |
| | 505 | AC_SUBST(BOOST_LDFLAGS) |
| | 506 | AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) |
| | 507 | fi |
| | 508 | |
| | 509 | CPPFLAGS="$CPPFLAGS_SAVED" |
| | 510 | LDFLAGS="$LDFLAGS_SAVED" |
| | 511 | ]) |
| | 512 | |