mirror of
https://github.com/libusb/libusb
synced 2024-11-21 14:29:12 -07:00
configure.ac: Enhance compiler checks for pthreads
There apparently exist some compiler ports (e.g Haiku's GCC) that do not support the ubiquitous '-pthread' compiler option. Add a check for this and only use the option if supported. Also tweak the check for the pthread library to check for the pthread_create() function. Even though libusb does not use this function, it seems to be sufficiently distinct such that the standard C library would not provide this directly if the pthread implementation resided in a separate library. Also explicitly check whether no additional library linkage is required. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
This commit is contained in:
parent
6f0330c784
commit
33b3ba3fc7
2 changed files with 13 additions and 3 deletions
14
configure.ac
14
configure.ac
|
@ -153,10 +153,20 @@ fi
|
|||
|
||||
if test "x$threads" = xposix; then
|
||||
AC_DEFINE([THREADS_POSIX], [1], [Define to 1 if using POSIX threads.])
|
||||
AC_SUBST(THREAD_CFLAGS, [-pthread])
|
||||
dnl Some compilers do not support the '-pthread' option so check for it here
|
||||
saved_CFLAGS="${CFLAGS}"
|
||||
CFLAGS="-Wall -Werror -pthread"
|
||||
AC_MSG_CHECKING([if $CC recognizes -pthread])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_SUBST(THREAD_CFLAGS, [-pthread])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
CFLAGS="${saved_CFLAGS}"
|
||||
dnl Android Linux and Darwin provide pthread functions directly in libc
|
||||
dnl glibc also provides some pthread functions directly, so search for a thread-specific function
|
||||
AC_SEARCH_LIBS([pthread_key_create], [pthread], [AC_SUBST(THREAD_LIBS, [-lpthread])], [], [])
|
||||
AC_SEARCH_LIBS([pthread_create], [pthread],
|
||||
[test "x$ac_cv_search_pthread_create" != "xnone required" && AC_SUBST(THREAD_LIBS, [-lpthread])],
|
||||
[], [])
|
||||
elif test "x$threads" = xwindows; then
|
||||
AC_DEFINE([THREADS_WINDOWS], [1], [Define to 1 if using Windows threads.])
|
||||
else
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define LIBUSB_NANO 11488
|
||||
#define LIBUSB_NANO 11489
|
||||
|
|
Loading…
Reference in a new issue