@matheusbsbs / matheus-bagliano / commits / 20f7a39825
Fork 0

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 <david.syzdek@acsalaska.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David M. Syzdek committed Nov 3, 2008 at 09:14 UTC 20f7a39825e30891056ab00ea620eaffda6aa451
2 files changed +17
config.mak.in
+1
@@ -51,3 +51,4 @@ OLD_ICONV=@OLD_ICONV@
51 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
52 FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
53 SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
54 +PTHREAD_LIBS=@PTHREAD_LIBS@
configure.ac
+16
@@ -479,6 +479,22 @@ AC_SUBST(NO_MKDTEMP)
479 #
480 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
481 # Enable it on Windows. By default, symrefs are still used.
482 +#
483 +# Define PTHREAD_LIBS to the linker flag used for Pthread support.
484 +AC_LANG_CONFTEST([AC_LANG_PROGRAM(
485 + [[#include <pthread.h>]],
486 + [[pthread_mutex_t test_mutex;]]
487 +)])
488 +${CC} -pthread conftest.c -o conftest.o > /dev/null 2>&1
489 +if test $? -eq 0;then
490 + PTHREAD_LIBS="-pthread"
491 +else
492 + ${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1
493 + if test $? -eq 0;then
494 + PTHREAD_LIBS="-lpthread"
495 + fi
496 +fi
497 +AC_SUBST(PTHREAD_LIBS)
498
499 ## Site configuration (override autodetection)
500 ## --with-PACKAGE[=ARG] and --without-PACKAGE