summaryrefslogtreecommitdiff
path: root/config/ax_boost_thread.m4
blob: 8e42510ea9c3ae146711010252f15b68e44a3ce3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#
# SYNOPSIS
#
#   AX_BOOST_THREAD
#
# DESCRIPTION
#
#   Test for Thread library from the Boost C++ libraries.
#
#   This macro calls:
#
#     AC_SUBST(BOOST_THREAD_LIB)
#     AC_SUBST(BOOST_CXXFLAGS)
#
#   And sets:
#
#     HAVE_BOOST_THREAD
#
# COPYLEFT
#
#   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
#   Copyright (c) 2008 Michael Tindal
#   Copyright (c) 2008 Free Software Foundation, Inc.
#
#   Copying and distribution of this file, with or without modification, are
#   permitted in any medium without royalty provided the copyright notice
#   and this notice are preserved.


AC_DEFUN([AX_BOOST_THREAD],
[
    AC_REQUIRE([AX_BOOST_BASE])
    AC_REQUIRE([ACX_PTHREAD])
    _AX_BOOST_WITH([boost_thread])

    if test "$want_boost" = "yes"; then
        AC_REQUIRE([AC_PROG_CC])
        AC_REQUIRE([AC_PROG_CXX])
        AC_REQUIRE([AC_CANONICAL_HOST])

        CPPFLAGS_SAVED="$CPPFLAGS"
        LDFLAGS_SAVED="$LDFLAGS"
	CXXFLAGS_SAVED="$CXXFLAGS"

        CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
        LDFLAGS="$LDFLAGS $BOOST_LDFLAGS $PTHREAD_LIBS"
	CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"

        AC_CACHE_CHECK([whether the boost::thread includes are available],
                       [ax_cv_boost_thread],
        [AC_LANG_PUSH([C++])
             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]],
                                   [[boost::thread_group thrds;
                                   return 0;]])],
                   [ax_cv_boost_thread=yes], [ax_cv_boost_thread=no])
             AC_LANG_POP([C++])
        ])

        if test "$ax_cv_boost_thread" = "yes"; then
	    BOOST_CXXFLAGS="$PTHREAD_CFLAGS"
            AC_SUBST([BOOST_CXXFLAGS])
	    _AX_BOOST_CHECK_LIB([boost_thread])
	    if test "$link_ok" = "yes" && test -n "$PTHREAD_LIBS"; then
	        BOOST_THREAD_LIB="$BOOST_THREAD_LIB $PTHREAD_LIBS"
	    fi
        fi

        CPPFLAGS="$CPPFLAGS_SAVED"
        LDFLAGS="$LDFLAGS_SAVED"
	CXXFLAGS="$CXXFLAGS_SAVED"
    fi
])