]> xenbits.xensource.com Git - libvirt.git/commitdiff
m4: add check for pthread library
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 17 Jan 2020 15:30:51 +0000 (15:30 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 4 Feb 2020 14:00:45 +0000 (14:00 +0000)
When we get rid of GNULIB, we need to check for -lpthread
support.

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
m4/virt-pthread.m4
src/Makefile.am
tests/Makefile.am

index 5b3750e8e9d34607c3093bf339fcbae1b3fae38e..0b52b40bb82102506ec008fd477a79ad6786f3c3 100644 (file)
@@ -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"
 ])
index 7bb6127ca4b775fc01df0e7b2ecc127e63a3456d..2e1814ccff2551201762b6ffa38561662f89f261 100644 (file)
@@ -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
index ef49b122cd22a87bd4413c3f6b582b9ff75de6e3..12f6bf6814c3022e6f32792202608381e4c00180 100644 (file)
@@ -1506,7 +1506,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 = \