|
1 | 1 | # =========================================================================== |
2 | | -# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html |
| 2 | +# https://www.gnu.org/software/autoconf-archive/ax_boost_thread.html |
3 | 3 | # =========================================================================== |
4 | 4 | # |
5 | 5 | # SYNOPSIS |
|
30 | 30 | # and this notice are preserved. This file is offered as-is, without any |
31 | 31 | # warranty. |
32 | 32 |
|
33 | | -#serial 27 |
| 33 | +#serial 33 |
34 | 34 |
|
35 | 35 | AC_DEFUN([AX_BOOST_THREAD], |
36 | 36 | [ |
37 | | - AC_ARG_WITH([boost-thread], |
38 | | - AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], |
39 | | - [use the Thread library from boost - it is possible to specify a certain library for the linker |
40 | | - e.g. --with-boost-thread=boost_thread-gcc-mt ]), |
| 37 | + AC_ARG_WITH([boost-thread], |
| 38 | + AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], |
| 39 | + [use the Thread library from boost - |
| 40 | + it is possible to specify a certain library for the linker |
| 41 | + e.g. --with-boost-thread=boost_thread-gcc-mt ]), |
41 | 42 | [ |
42 | | - if test "$withval" = "no"; then |
43 | | - want_boost="no" |
44 | | - elif test "$withval" = "yes"; then |
| 43 | + if test "$withval" = "yes"; then |
45 | 44 | want_boost="yes" |
46 | 45 | ax_boost_user_thread_lib="" |
47 | 46 | else |
48 | | - want_boost="yes" |
49 | | - ax_boost_user_thread_lib="$withval" |
50 | | - fi |
| 47 | + want_boost="yes" |
| 48 | + ax_boost_user_thread_lib="$withval" |
| 49 | + fi |
51 | 50 | ], |
52 | 51 | [want_boost="yes"] |
53 | | - ) |
| 52 | + ) |
54 | 53 |
|
55 | | - if test "x$want_boost" = "xyes"; then |
| 54 | + if test "x$want_boost" = "xyes"; then |
56 | 55 | AC_REQUIRE([AC_PROG_CC]) |
57 | 56 | AC_REQUIRE([AC_CANONICAL_BUILD]) |
58 | | - CPPFLAGS_SAVED="$CPPFLAGS" |
59 | | - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
60 | | - export CPPFLAGS |
| 57 | + CPPFLAGS_SAVED="$CPPFLAGS" |
| 58 | + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
| 59 | + export CPPFLAGS |
61 | 60 |
|
62 | | - LDFLAGS_SAVED="$LDFLAGS" |
63 | | - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
64 | | - export LDFLAGS |
| 61 | + LDFLAGS_SAVED="$LDFLAGS" |
| 62 | + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" |
| 63 | + export LDFLAGS |
65 | 64 |
|
66 | 65 | AC_CACHE_CHECK(whether the Boost::Thread library is available, |
67 | | - ax_cv_boost_thread, |
| 66 | + ax_cv_boost_thread, |
68 | 67 | [AC_LANG_PUSH([C++]) |
69 | | - CXXFLAGS_SAVE=$CXXFLAGS |
| 68 | + CXXFLAGS_SAVE=$CXXFLAGS |
| 69 | +
|
| 70 | + case "x$host_os" in |
| 71 | + xsolaris ) |
| 72 | + CXXFLAGS="-pthreads $CXXFLAGS" |
| 73 | + break; |
| 74 | + ;; |
| 75 | + xmingw32 ) |
| 76 | + CXXFLAGS="-mthreads $CXXFLAGS" |
| 77 | + break; |
| 78 | + ;; |
| 79 | + *android* ) |
| 80 | + break; |
| 81 | + ;; |
| 82 | + * ) |
| 83 | + CXXFLAGS="-pthread $CXXFLAGS" |
| 84 | + break; |
| 85 | + ;; |
| 86 | + esac |
70 | 87 |
|
71 | | - if test "x$host_os" = "xsolaris" ; then |
72 | | - CXXFLAGS="-pthreads $CXXFLAGS" |
73 | | - elif test "x$host_os" = "xmingw32" ; then |
74 | | - CXXFLAGS="-mthreads $CXXFLAGS" |
75 | | - else |
76 | | - CXXFLAGS="-pthread $CXXFLAGS" |
77 | | - fi |
78 | | - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <boost/thread/thread.hpp>]], |
79 | | - [[boost::thread_group thrds; |
80 | | - return 0;]])], |
81 | | - ax_cv_boost_thread=yes, ax_cv_boost_thread=no) |
82 | | - CXXFLAGS=$CXXFLAGS_SAVE |
| 88 | + AC_COMPILE_IFELSE([ |
| 89 | + AC_LANG_PROGRAM( |
| 90 | + [[@%:@include <boost/thread/thread.hpp>]], |
| 91 | + [[boost::thread_group thrds; |
| 92 | + return 0;]])], |
| 93 | + ax_cv_boost_thread=yes, ax_cv_boost_thread=no) |
| 94 | + CXXFLAGS=$CXXFLAGS_SAVE |
83 | 95 | AC_LANG_POP([C++]) |
84 | | - ]) |
85 | | - if test "x$ax_cv_boost_thread" = "xyes"; then |
86 | | - if test "x$host_os" = "xsolaris" ; then |
87 | | - BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" |
88 | | - elif test "x$host_os" = "xmingw32" ; then |
89 | | - BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" |
90 | | - else |
91 | | - BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" |
92 | | - fi |
| 96 | + ]) |
| 97 | + if test "x$ax_cv_boost_thread" = "xyes"; then |
| 98 | + case "x$host_os" in |
| 99 | + xsolaris ) |
| 100 | + BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" |
| 101 | + break; |
| 102 | + ;; |
| 103 | + xmingw32 ) |
| 104 | + BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" |
| 105 | + break; |
| 106 | + ;; |
| 107 | + *android* ) |
| 108 | + break; |
| 109 | + ;; |
| 110 | + * ) |
| 111 | + BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" |
| 112 | + break; |
| 113 | + ;; |
| 114 | + esac |
93 | 115 |
|
94 | | - AC_SUBST(BOOST_CPPFLAGS) |
| 116 | + AC_SUBST(BOOST_CPPFLAGS) |
95 | 117 |
|
96 | | - AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available]) |
| 118 | + AC_DEFINE(HAVE_BOOST_THREAD,, |
| 119 | + [define if the Boost::Thread library is available]) |
97 | 120 | BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` |
98 | 121 |
|
99 | | - LDFLAGS_SAVE=$LDFLAGS |
| 122 | + LDFLAGS_SAVE=$LDFLAGS |
100 | 123 | case "x$host_os" in |
101 | 124 | *bsd* ) |
102 | 125 | LDFLAGS="-pthread $LDFLAGS" |
103 | 126 | break; |
104 | 127 | ;; |
105 | 128 | esac |
106 | 129 | if test "x$ax_boost_user_thread_lib" = "x"; then |
107 | | - ax_lib= |
108 | 130 | for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do |
109 | 131 | ax_lib=${libextension} |
110 | | - AC_CHECK_LIB($ax_lib, exit, |
111 | | - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], |
| 132 | + AC_CHECK_LIB($ax_lib, exit, |
| 133 | + [link_thread="yes"; break], |
112 | 134 | [link_thread="no"]) |
113 | | - done |
| 135 | + done |
114 | 136 | if test "x$link_thread" != "xyes"; then |
115 | 137 | for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do |
116 | 138 | ax_lib=${libextension} |
117 | | - AC_CHECK_LIB($ax_lib, exit, |
118 | | - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], |
| 139 | + AC_CHECK_LIB($ax_lib, exit, |
| 140 | + [link_thread="yes"; break], |
119 | 141 | [link_thread="no"]) |
120 | | - done |
| 142 | + done |
121 | 143 | fi |
122 | 144 |
|
123 | 145 | else |
124 | 146 | for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do |
125 | | - AC_CHECK_LIB($ax_lib, exit, |
126 | | - [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], |
| 147 | + AC_CHECK_LIB($ax_lib, exit, |
| 148 | + [link_thread="yes"; break], |
127 | 149 | [link_thread="no"]) |
128 | 150 | done |
129 | 151 |
|
130 | 152 | fi |
131 | 153 | if test "x$ax_lib" = "x"; then |
132 | | - AC_MSG_ERROR(Could not find a version of the boost_thread library!) |
| 154 | + AC_MSG_ERROR(Could not find a version of the Boost::Thread library!) |
133 | 155 | fi |
134 | | - if test "x$link_thread" = "xno"; then |
135 | | - AC_MSG_ERROR(Could not link against $ax_lib !) |
136 | | - else |
137 | | - case "x$host_os" in |
138 | | - *bsd* ) |
139 | | - BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" |
140 | | - break; |
141 | | - ;; |
142 | | - esac |
143 | | -
|
144 | | - fi |
145 | | - fi |
| 156 | + if test "x$link_thread" = "xno"; then |
| 157 | + AC_MSG_ERROR(Could not link against $ax_lib !) |
| 158 | + else |
| 159 | + BOOST_THREAD_LIB="-l$ax_lib" |
| 160 | + case "x$host_os" in |
| 161 | + *bsd* ) |
| 162 | + BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" |
| 163 | + break; |
| 164 | + ;; |
| 165 | + xsolaris ) |
| 166 | + BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread" |
| 167 | + break; |
| 168 | + ;; |
| 169 | + xmingw32 ) |
| 170 | + break; |
| 171 | + ;; |
| 172 | + *android* ) |
| 173 | + break; |
| 174 | + ;; |
| 175 | + * ) |
| 176 | + BOOST_THREAD_LIB="$BOOST_THREAD_LIB -lpthread" |
| 177 | + break; |
| 178 | + ;; |
| 179 | + esac |
| 180 | + AC_SUBST(BOOST_THREAD_LIB) |
| 181 | + fi |
| 182 | + fi |
146 | 183 |
|
147 | | - CPPFLAGS="$CPPFLAGS_SAVED" |
148 | | - LDFLAGS="$LDFLAGS_SAVED" |
149 | | - fi |
| 184 | + CPPFLAGS="$CPPFLAGS_SAVED" |
| 185 | + LDFLAGS="$LDFLAGS_SAVED" |
| 186 | + fi |
150 | 187 | ]) |
0 commit comments