summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-04-09 12:05:16 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-04-09 12:05:16 -0700
commit33b3ba3fc71ada906bfeb05eee937661c32b2877 (patch)
treecfed2960c7840c9e36e9ea0d814f8d4c4ea00735
parent6f0330c78467bb9b5154ffb1859f6b9850235b7a (diff)
downloadlibusb-33b3ba3fc71ada906bfeb05eee937661c32b2877.tar.gz
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>
-rw-r--r--configure.ac14
-rw-r--r--libusb/version_nano.h2
2 files changed, 13 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 2aaa9e6..d386053 100644
--- a/configure.ac
+++ b/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
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 07b0839..f5243a0 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11488
+#define LIBUSB_NANO 11489