Skip to content

Commit bf51558

Browse files
committed
Linux: update ax_boost_thread.m4 to match ax_boost_base.m4
1 parent 6aca13d commit bf51558

File tree

1 file changed

+108
-70
lines changed

1 file changed

+108
-70
lines changed

unix/config/ax_boost_thread.m4

+108-70
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ===========================================================================
2-
# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html
2+
# https://www.gnu.org/software/autoconf-archive/ax_boost_thread.html
33
# ===========================================================================
44
#
55
# SYNOPSIS
@@ -30,73 +30,96 @@
3030
# and this notice are preserved. This file is offered as-is, without any
3131
# warranty.
3232

33-
#serial 27
33+
#serial 33
3434

3535
AC_DEFUN([AX_BOOST_THREAD],
3636
[
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 ]),
4142
[
42-
if test "$withval" = "no"; then
43-
want_boost="no"
44-
elif test "$withval" = "yes"; then
43+
if test "$withval" = "yes"; then
4544
want_boost="yes"
4645
ax_boost_user_thread_lib=""
4746
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
5150
],
5251
[want_boost="yes"]
53-
)
52+
)
5453
55-
if test "x$want_boost" = "xyes"; then
54+
if test "x$want_boost" = "xyes"; then
5655
AC_REQUIRE([AC_PROG_CC])
5756
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
6160
62-
LDFLAGS_SAVED="$LDFLAGS"
63-
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
64-
export LDFLAGS
61+
LDFLAGS_SAVED="$LDFLAGS"
62+
LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
63+
export LDFLAGS
6564
6665
AC_CACHE_CHECK(whether the Boost::Thread library is available,
67-
ax_cv_boost_thread,
66+
ax_cv_boost_thread,
6867
[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
7087
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
8395
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
93115
94-
AC_SUBST(BOOST_CPPFLAGS)
116+
AC_SUBST(BOOST_CPPFLAGS)
95117
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])
97120
BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'`
98121
99-
LDFLAGS_SAVE=$LDFLAGS
122+
LDFLAGS_SAVE=$LDFLAGS
100123
case "x$host_os" in
101124
*bsd* )
102125
LDFLAGS="-pthread $LDFLAGS"
@@ -106,44 +129,59 @@ AC_DEFUN([AX_BOOST_THREAD],
106129
if test "x$ax_boost_user_thread_lib" = "x"; then
107130
for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do
108131
ax_lib=${libextension}
109-
AC_CHECK_LIB($ax_lib, exit,
110-
[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],
111134
[link_thread="no"])
112-
done
135+
done
113136
if test "x$link_thread" != "xyes"; then
114137
for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do
115138
ax_lib=${libextension}
116-
AC_CHECK_LIB($ax_lib, exit,
117-
[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],
118141
[link_thread="no"])
119-
done
142+
done
120143
fi
121144
122145
else
123146
for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do
124-
AC_CHECK_LIB($ax_lib, exit,
125-
[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],
126149
[link_thread="no"])
127150
done
128151
129152
fi
130153
if test "x$ax_lib" = "x"; then
131-
AC_MSG_ERROR(Could not find a version of the library!)
154+
AC_MSG_ERROR(Could not find a version of the Boost::Thread library!)
132155
fi
133-
if test "x$link_thread" = "xno"; then
134-
AC_MSG_ERROR(Could not link against $ax_lib !)
135-
else
136-
case "x$host_os" in
137-
*bsd* )
138-
BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS"
139-
break;
140-
;;
141-
esac
142-
143-
fi
144-
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
145183
146-
CPPFLAGS="$CPPFLAGS_SAVED"
147-
LDFLAGS="$LDFLAGS_SAVED"
148-
fi
184+
CPPFLAGS="$CPPFLAGS_SAVED"
185+
LDFLAGS="$LDFLAGS_SAVED"
186+
fi
149187
])

0 commit comments

Comments
 (0)