configure.ac: use $LIBS not $CFLAGS when testing -lpthread

Some linkers, namely the one on IRIX are rather strict concerning the order or arguments for symbol resolution, i.e. no libraries listed before objects or other libraries on the command line are considered for symbol resolution. Therefore, -lpthread can't work if it's put in CFLAGS, because it will not be considered for resolving pthread_key_create in conftest.o. Use $LIBS instead. Signed-off-by: Rainer Canavan <git@canavan.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rainer M. Canavan committed Nov 6, 2015 at 02:11 UTC bac2c5bf1a74fbdb901c6c939e6ec1bb085749f8
1 file changed +7 -1
configure.ac
+7 -1
@@ -1013,7 +1013,12 @@ elif test -z "$PTHREAD_CFLAGS"; then
1013 # would then trigger compiler warnings on every single file we compile.
1014 for opt in "" -mt -pthread -lpthread; do
1015 old_CFLAGS="$CFLAGS"
1016 - CFLAGS="$opt $CFLAGS"
1016 + old_LIBS="$LIBS"
1017 + case "$opt" in
1018 + -l*) LIBS="$opt $LIBS" ;;
1019 + *) CFLAGS="$opt $CFLAGS" ;;
1020 + esac
1021 +
1022 AC_MSG_CHECKING([for POSIX Threads with '$opt'])
1023 AC_LINK_IFELSE([PTHREADTEST_SRC],
1024 [AC_MSG_RESULT([yes])
@@ -1025,6 +1030,7 @@ elif test -z "$PTHREAD_CFLAGS"; then
1030 ],
1031 [AC_MSG_RESULT([no])])
1032 CFLAGS="$old_CFLAGS"
1033 + LIBS="$old_LIBS"
1034 done
1035 if test $threads_found != yes; then
1036 AC_CHECK_LIB([pthread], [pthread_create],