From 0e1efa0e8c7961fc3eca21d0268c07f44eb572e5 Mon Sep 17 00:00:00 2001 From: Charles Briere Date: Sun, 1 Dec 2013 18:00:50 -0800 Subject: [PATCH] Cleanup: Check for pthread in Libc Some libc like Googles's Bionic for Android include pThread. Instead of checking for Android as in commit 58a052effb2305655ff1b7233c78ab24fc25257e this patch checks for pthread in libc as proposed by Thomas Petazzoni. Reported-by: Thomas Petazzoni Signed-off-by: Charles Briere Signed-off-by: Mathieu Desnoyers --- Makefile.am | 2 +- configure.ac | 9 +++++++++ tests/benchmark/Makefile.am | 2 +- tests/regression/Makefile.am | 2 +- tests/unit/Makefile.am | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 938027c..2f81bce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ INCLUDES = -I$(top_builddir)/urcu #Add the -version-info directly here since we are only building # library that use the version-info AM_LDFLAGS=-version-info $(URCU_LIBRARY_VERSION) -if !TARGET_IS_ANDROID +if !LIBC_INCLUDES_PTHREAD AM_LDFLAGS+=-lpthread endif AM_CFLAGS=-Wall diff --git a/configure.ac b/configure.ac index 38e39e1..774094e 100644 --- a/configure.ac +++ b/configure.ac @@ -165,6 +165,15 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ compat_futex_test=1 ]) +# Check for pthread +AC_CHECK_LIB([pthread], [pthread_create], + [AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, false)], + [AC_CHECK_LIB([c], [pthread_create], + [AM_CONDITIONAL(LIBC_INCLUDES_PTHREAD, true)], + [AC_MSG_ERROR([Cannot find libpthread. Use [LDFLAGS]=-Ldir to specify its location.])] + )] +) + AM_CONDITIONAL([COMPAT_FUTEX], [test "x$compat_futex_test" = "x1"]) AM_CONDITIONAL([COMPAT_ARCH], [test "x$SUBARCHTYPE" = "xx86compat"]) AM_CONDITIONAL([NO_SHARED], [test "x$enable_shared" = "xno"]) diff --git a/tests/benchmark/Makefile.am b/tests/benchmark/Makefile.am index bf02189..e889f88 100644 --- a/tests/benchmark/Makefile.am +++ b/tests/benchmark/Makefile.am @@ -1,4 +1,4 @@ -if !TARGET_IS_ANDROID +if !LIBC_INCLUDES_PTHREAD AM_LDFLAGS=-lpthread endif AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index eb15699..80cb1bc 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -1,4 +1,4 @@ -if !TARGET_IS_ANDROID +if !LIBC_INCLUDES_PTHREAD AM_LDFLAGS=-lpthread endif AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 2c89ca6..9efd74e 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -1,4 +1,4 @@ -if !TARGET_IS_ANDROID +if !LIBC_INCLUDES_PTHREAD AM_LDFLAGS=-lpthread endif AM_CFLAGS=-I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/tests/common -g -- 2.34.1