Skip to content

Commit

Permalink
Add autoconf tests for pthreads
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
syzdek authored and gitster committed Nov 9, 2008
1 parent 158629b commit 20f7a39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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.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"
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
Expand Down

0 comments on commit 20f7a39

Please sign in to comment.