[PATCH] Add autoconf tests for pthreads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: David M. Syzdek <david.syzdek@xxxxxxxxxxxxx>

Sets the value of PTHREAD_LIBS to the correct flags for linking pthreads on
the current environment.  If the correct flags can be determined then
THREADED_DELTA_SEARCH is set.  If the correct flags cannot be determined,
then THREADED_DELTA_SEARCH is unset.

Signed-off-by: David M. Syzdek <david.syzdek@xxxxxxxxxxxxx>
---
 config.mak.in |    2 ++
 configure.ac  |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/config.mak.in b/config.mak.in
index 7170729..3d3fbcd 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -51,3 +51,5 @@ OLD_ICONV=@OLD_ICONV@
 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
 FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
 SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
+THREADED_DELTA_SEARCH=@THREADED_DELTA_SEARCH@
+PTHREAD_LIBS=@PTHREAD_LIBS@
diff --git a/configure.ac b/configure.ac
index 9dfc0d3..3bf5d15 100644
--- a/configure.ac
+++ b/configure.ac
@@ -489,6 +489,26 @@ AC_SUBST(NO_MKDTEMP)
 #
 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
 # Enable it on Windows.  By default, symrefs are still used.
+#
+# Define PTHREAD_LIBS to the linker flag used for Pthread support and define
+# THREADED_DELTA_SEARCH if Pthreads are available.
+AC_LANG_CONFTEST([AC_LANG_PROGRAM(
+  [[#include <pthread.h>]],
+  [[pthread_mutex_t test_mutex;]]
+)])
+${CC} -pthread conftest.c -o conftest.o > /dev/null 2>&1
+if test $? -eq 0;then
+ PTHREAD_LIBS="-pthread"
+ THREADED_DELTA_SEARCH=YesPlease
+else
+ ${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1
+ if test $? -eq 0;then
+  PTHREAD_LIBS="-lpthread"
+  THREADED_DELTA_SEARCH=YesPlease
+ fi
+fi
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(THREADED_DELTA_SEARCH)
 
 ## Site configuration (override autodetection)
 ## --with-PACKAGE[=ARG] and --without-PACKAGE
-- 
1.6.0.2.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux