From 20f7a39825e30891056ab00ea620eaffda6aa451 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Mon, 3 Nov 2008 09:14:28 -0900 Subject: [PATCH] Add autoconf tests for pthreads Set the value of PTHREAD_LIBS to the correct flags for linking pthreads on the current environment. Signed-off-by: David M. Syzdek Signed-off-by: Junio C Hamano --- config.mak.in | 1 + configure.ac | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/config.mak.in b/config.mak.in index 717072943..ea7705c1e 100644 --- a/config.mak.in +++ b/config.mak.in @@ -51,3 +51,4 @@ OLD_ICONV=@OLD_ICONV@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@ +PTHREAD_LIBS=@PTHREAD_LIBS@ diff --git a/configure.ac b/configure.ac index a0d53f312..3f058a087 100644 --- a/configure.ac +++ b/configure.ac @@ -479,6 +479,22 @@ 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. +AC_LANG_CONFTEST([AC_LANG_PROGRAM( + [[#include ]], + [[pthread_mutex_t test_mutex;]] +)]) +${CC} -pthread conftest.c -o conftest.o > /dev/null 2>&1 +if test $? -eq 0;then + PTHREAD_LIBS="-pthread" +else + ${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1 + if test $? -eq 0;then + PTHREAD_LIBS="-lpthread" + fi +fi +AC_SUBST(PTHREAD_LIBS) ## Site configuration (override autodetection) ## --with-PACKAGE[=ARG] and --without-PACKAGE -- 2.30.2