summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-05-11 00:36:46 +0100
committerPete Batard <pbatard@gmail.com>2010-05-11 00:36:46 +0100
commit0e74019d22094c1d0f35c40b01f9c788c63f4fee (patch)
treefb5c6d205ef5806a097cebbda5a34c0782d84861
parent71eaaccde2c6ff09d3c772f8d99981d20787b2d3 (diff)
downloadlibusb-0e74019d22094c1d0f35c40b01f9c788c63f4fee.tar.gz
added detection of -pthread option - only use when required
-rw-r--r--configure.ac17
-rw-r--r--examples/Makefile.am2
-rw-r--r--libusb/Makefile.am2
3 files changed, 16 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 938621c..7f6a39b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,7 +31,7 @@ case $host in
AC_DEFINE([POSIX_THREADS], [], [Posix Threads])
threads="posix"
AC_CHECK_LIB(rt, clock_gettime)
- AM_CFLAGS="-pthread -Wshadow"
+ AM_CFLAGS="-Wshadow"
AM_LDFLAGS=""
;;
*-darwin*)
@@ -42,7 +42,7 @@ case $host in
backend="darwin"
AC_DEFINE([POSIX_THREADS], [], [Posix Threads])
threads="posix"
- AM_CFLAGS="-pthread -Wshadow"
+ AM_CFLAGS="-Wshadow"
AM_LDFLAGS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation -Wl,-prebind -no-undefined"
;;
*-mingw*)
@@ -63,7 +63,7 @@ case $host in
backend="windows"
AC_DEFINE([POSIX_THREADS], [], [Posix Threads])
threads="posix"
- LIBS="-lpthread -lsetupapi -lole32 -ladvapi32"
+ LIBS="-lsetupapi -lole32 -ladvapi32"
AM_CFLAGS=""
AM_LDFLAGS="-no-undefined -avoid-version"
AC_CHECK_TOOL(RC, windres, no)
@@ -165,6 +165,17 @@ AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
nopointersign_cflags="-Wno-pointer-sign", nopointersign_cflags="")
CFLAGS="$saved_cflags"
+# check if -pthread is supported (some environments like cygwin don't support it)
+AC_MSG_CHECKING([whether compiler supports the -pthread option])
+if $CC -pthread 2>&1 | grep -q 'unrecognized option.*pthread'; then
+ AC_MSG_RESULT([no])
+ THREAD_CFLAGS=""
+else
+ AC_MSG_RESULT([yes])
+ THREAD_CFLAGS="-pthread"
+fi
+AC_SUBST([THREAD_CFLAGS])
+
AM_CFLAGS="$AM_CFLAGS -std=gnu99 $inline_cflags -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration $nopointersign_cflags"
AC_SUBST(VISIBILITY_CFLAGS)
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 8ffc9c5..a5512cb 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -18,6 +18,6 @@ dpfp_SOURCES = dpfp.c
dpfp_LDADD = ../libusb/libusb-1.0.la -lusb-1.0
dpfp_threaded_SOURCES = dpfp_threaded.c
-dpfp_threaded_CFLAGS = $(AM_CFLAGS)
+dpfp_threaded_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS)
dpfp_threaded_LDADD = ../libusb/libusb-1.0.la -lusb-1.0
diff --git a/libusb/Makefile.am b/libusb/Makefile.am
index 48b28fb..24ab9dc 100644
--- a/libusb/Makefile.am
+++ b/libusb/Makefile.am
@@ -27,7 +27,7 @@ OS_SRC = $(WINDOWS_USB_SRC)
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) -i $< -o $@
endif
-libusb_1_0_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS)
+libusb_1_0_la_CFLAGS = $(VISIBILITY_CFLAGS) $(THREAD_CFLAGS) $(AM_CFLAGS)
libusb_1_0_la_SOURCES = libusbi.h core.c descriptor.c io.c sync.c $(OS_SRC)
hdrdir = $(includedir)/libusb-1.0