@@ -13213,11 +13213,13 @@ echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6
1321313213 -*)
1321413214 echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5
1321513215echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6
13216- PTHREAD_CFLAGS ="$flag"
13216+ tryPTHREAD_CFLAGS ="$flag"
1321713217 ;;
1321813218
13219- pthread-config)
13220- # Extract the first word of "pthread-config", so it can be a program name with args.
13219+ pthread-config)
13220+ # skip this if we already have flags defined, for PostgreSQL
13221+ if test x"$PTHREAD_CFLAGS" != x -o x"$PTHREAD_LIBS" != x; then continue; fi
13222+ # Extract the first word of "pthread-config", so it can be a program name with args.
1322113223set dummy pthread-config; ac_word=$2
1322213224echo "$as_me:$LINENO: checking for $ac_word" >&5
1322313225echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
@@ -13253,22 +13255,23 @@ else
1325313255echo "${ECHO_T}no" >&6
1325413256fi
1325513257
13256- if test x"$acx_pthread_config" = xno; then continue; fi
13257- PTHREAD_CFLAGS="`pthread-config --cflags`"
13258- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
13259- ;;
13258+ if test x"$acx_pthread_config" = xno; then continue; fi
13259+ tryPTHREAD_CFLAGS="`pthread-config --cflags`"
13260+ tryPTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
13261+ fi
13262+ ;;
1326013263
1326113264 *)
1326213265 echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5
1326313266echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6
13264- PTHREAD_LIBS ="-l$flag"
13267+ tryPTHREAD_LIBS ="-l$flag"
1326513268 ;;
1326613269 esac
1326713270
1326813271 save_LIBS="$LIBS"
1326913272 save_CFLAGS="$CFLAGS"
13270- LIBS="$PTHREAD_LIBS $LIBS"
13271- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
13273+ LIBS="$tryPTHREAD_LIBS $ PTHREAD_LIBS $LIBS"
13274+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS $tryPTHREAD_CFLAGS "
1327213275
1327313276 # Check for various functions. We must include pthread.h,
1327413277 # since some functions may be macros. (On the Sequent, we
@@ -13324,11 +13327,13 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
1332413327 echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
1332513328echo "${ECHO_T}$acx_pthread_ok" >&6
1332613329 if test "x$acx_pthread_ok" = xyes; then
13327- break;
13330+ # we continue with more flags because Linux needs -lpthread
13331+ # for libpq builds on PostgreSQL. The test above only
13332+ # tests for building binaries, not shared libraries.
13333+ PTHREAD_LIBS=" $tryPTHREAD_LIBS $PTHREAD_LIBS"
13334+ PTHREAD_CFLAGS="$PTHREAD_CFLAGS $tryPTHREAD_CFLAGS"
1332813335 fi
1332913336
13330- PTHREAD_LIBS=""
13331- PTHREAD_CFLAGS=""
1333213337done
1333313338fi
1333413339
@@ -13436,11 +13441,11 @@ echo "$as_me: WARNING: we do not know how to create joinable pthreads" >&2;}
1343613441 echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5
1343713442echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6
1343813443 flag=no
13439- # Wehandle this ourselves in PostgreSQL
13440- # case "${host_cpu}-${host_os}" in
13441- # *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";;
13442- # *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
13443- # esac
13444+ # Wealways add these in PostgreSQL
13445+ # case "${host_cpu}-${host_os}" in
13446+ # *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
13447+ # *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
13448+ # esac
1344413449 echo "$as_me:$LINENO: result: ${flag}" >&5
1344513450echo "${ECHO_T}${flag}" >&6
1344613451 if test "x$flag" != xno; then