From bf012f8173c39bda7473336431e9bfd79aa755c9 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 18 Feb 2022 18:15:14 +0200 Subject: [PATCH 41/41] configure: Make pthreads test also with "-lpthread" See osdn #43561 Signed-off-by: Marko Lindqvist --- configure.ac | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 5e64c16703..bc0a02dbee 100644 --- a/configure.ac +++ b/configure.ac @@ -981,7 +981,6 @@ if test "x$fctinycthr" = "xyes" ; then fi if test "x$thread_impl" = "xnone" ; then - libs_save="$LIBS" LIBS="$LIBS -lpthread" AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return thrd_create(NULL, NULL, NULL);]])], @@ -990,7 +989,7 @@ if test "x$thread_impl" = "xnone" ; then AC_MSG_RESULT([C11]) AC_DEFINE([FREECIV_HAVE_THREAD_COND], [1], [Has thread condition variable implementation]) thread_cond=true], - [LIBS="$libs_save"]) + [LIBS="$LIBS_SAVE"]) fi if test x$crosser != xyes && test "x$thread_impl" = "xnone" ; then @@ -998,16 +997,25 @@ if test x$crosser != xyes && test "x$thread_impl" = "xnone" ; then FC_LD_FLAGS([-pthread], [], [LIBS]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return pthread_create(NULL, NULL, NULL, NULL);]])], - [AC_DEFINE([FREECIV_HAVE_PTHREAD], [1], [Use pthreads as thread implementation]) - thread_impl=pthreads + [thread_impl=pthreads], + [LIBS="$LIBS -lpthread" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[return pthread_create(NULL, NULL, NULL, NULL);]])], + [thread_impl=pthreads])]) + + if test $thread_impl = pthreads ; then + AC_DEFINE([FREECIV_HAVE_PTHREAD], [1], [Use pthreads as thread implementation]) AC_MSG_RESULT([pthreads]) AC_DEFINE([FREECIV_HAVE_THREAD_COND], [1], [Has thread condition variable implementation]) - thread_cond=true]) + thread_cond=true + else + LIBS="$LIBS_SAVE" + fi fi if test "x$thread_impl" = "xnone" ; then CFLAGS="$CFLAGS_SAVE" - LDFLAGS="$LDFLAGS_SAVE" + LIBS="$LIBS_SAVE" AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[CreateThread(NULL, 0, NULL, NULL, 0, NULL);]])], -- 2.34.1