configure: redo pthread check to check for more things
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 13 Aug 2012 18:43:12 +0000 (19:43 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 19 Nov 2012 15:13:42 +0000 (15:13 +0000)
commit277675a40e7252a1c5c479b0e0572d9b8a4014ae
tree3d179b406e5823c5f6ac163d7280b90c4f9d0c5a
parent16d0564f30dbe975409e36af5e63ab3ececedda4
configure: redo pthread check to check for more things

In principle, anything in the pthread namespace might either be in the
platform-specific thread library (libpthread or libpthreads or libthreads
or ...), or in libc.

In particular, it seems that pthread_mutexattr_init and
pthread_mutexattr_settype are in libpthread, not libc, on Linux. We
previously didn't (intentionally) look for them in libpthread, only
in libc; so this check deserved to fail.

However, a faulty configure check for pthread_cond_timedwait
worked around this on Linux by checking for -lpthread and adding it
to THREAD_LIBS if pthread_cond_timedwait *was* found in libc (even
though that behaviour makes no sense).

The practical impact was that D-Bus would fail to compile on platforms
where pthread_cond_timedwait is in a special threading library that
is not linked by default, and at least one of
(pthread_mutexattr_init, pthread_mutexattr_settype) is also in a
special threading library. This is the case on at least OpenBSD
(fd.o #54416).

So far I've only added checks for the new symbols introduced by
using recursive pthreads mutexes. If we get reports of compilation
failures on weird platforms, we can check for more symbols.

Also clarify the indentation, which was turning into quite a mess,
and use AS_IF instead of if/elif/else/fi in accordance with Autoconf
best-practice.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=47239
Reviewed-by: Colin Walters <walters@verbum.org>
configure.ac