[libvirt PATCH v2 50/56] m4: add check for pthread library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we get rid of GNULIB, we need to check for -lpthread
support.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 m4/virt-pthread.m4 | 26 ++++++++++++++------------
 src/Makefile.am    |  2 --
 tests/Makefile.am  |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/m4/virt-pthread.m4 b/m4/virt-pthread.m4
index 5b3750e8e9..0b52b40bb8 100644
--- a/m4/virt-pthread.m4
+++ b/m4/virt-pthread.m4
@@ -18,20 +18,24 @@ dnl <http://www.gnu.org/licenses/>.
 dnl
 
 AC_DEFUN([LIBVIRT_CHECK_PTHREAD], [
-  old_LIBS="$LIBS"
+  dnl Availability of pthread functions
 
-  dnl Availability of pthread functions. Because of $LIB_PTHREAD, we
-  dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD
-  dnl were set during gl_INIT by gnulib.
-  LIBS="$LIBS $LIB_PTHREAD $LIBMULTITHREAD"
-  pthread_found=yes
-  AC_CHECK_FUNCS([pthread_mutexattr_init])
-  AC_CHECK_HEADER([pthread.h],,[pthread_found=no])
+  AC_SEARCH_LIBS([pthread_mutexattr_init],[pthread ""])
 
-  if test "$ac_cv_func_pthread_mutexattr_init:$pthread_found" != "yes:yes"
+  if test "$ac_cv_func_pthread_mutexattr_init" = "no"
   then
-    AC_MSG_ERROR([A pthreads impl is required for building libvirt])
+    AC_MSG_ERROR([libpthread is required for building libvirt])
   fi
+  THREAD_LIBS=""
+  if test "x$ac_cv_func_pthread_mutexattr_init" != "x"
+  then
+    THREAD_LIBS="-l$ac_cv_func_pthread_mutexattr_init"
+  fi
+  AC_SUBST([THREAD_LIBS])
+
+  AC_CHECK_HEADER([pthread.h],,[
+    AC_MSG_ERROR([pthread.h is required for building libvirt])
+  ])
 
   dnl At least mingw64-winpthreads #defines pthread_sigmask to 0,
   dnl which in turn causes compilation to complain about unused variables.
@@ -51,6 +55,4 @@ AC_DEFUN([LIBVIRT_CHECK_PTHREAD], [
     AC_DEFINE([FUNC_PTHREAD_SIGMASK_BROKEN], [1],
       [Define to 1 if pthread_sigmask is not a real function])
   fi
-
-  LIBS="$old_LIBS"
 ])
diff --git a/src/Makefile.am b/src/Makefile.am
index 58355c5337..87322521c8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -130,8 +130,6 @@ include storage/Makefile.inc.am
 include remote/Makefile.inc.am
 
 
-THREAD_LIBS = $(LIB_PTHREAD) $(LTLIBMULTITHREAD)
-
 SECDRIVER_CFLAGS =
 SECDRIVER_LIBS =
 if WITH_SECDRIVER_SELINUX
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 19705c6b76..54b128833b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1511,7 +1511,7 @@ libshunload_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
 
 shunloadtest_SOURCES = \
 	shunloadtest.c
-shunloadtest_LDADD = $(LIB_PTHREAD) $(DLOPEN_LIBS)
+shunloadtest_LDADD = $(THREAD_LIBS) $(DLOPEN_LIBS)
 shunloadtest_DEPENDENCIES = libshunload.la
 
 sysinfotest_SOURCES = \
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux