Always build with pthread support
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 3 Jun 2016 16:30:00 +0000 (18:30 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 3 Jun 2016 16:30:00 +0000 (18:30 +0200)
Until now you could run ./configure --with-libpthread=no.
This didn't actually compile though.

The daemon has assumed for a while now that pthread support
is available. Bail out in ./configure if this is not the case.

configure.ac
src/Makefile.am
src/daemon/Makefile.am

index e4d6133..5e2eaa0 100644 (file)
@@ -1603,37 +1603,21 @@ if test "x$with_libhal" = "xyes"; then
        fi
 fi
 
-# --with-libpthread {{{
-AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
-[      if test "x$withval" != "xno" \
-               && test "x$withval" != "xyes"
-       then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
-               with_libpthread="yes"
-       else
-               if test "x$withval" = "xno"
-               then
-                       with_libpthread="no (disabled)"
-               fi
-       fi
-], [with_libpthread="yes"])
-
 AC_SUBST([PTHREAD_LIBS])
-if test "x$with_libpthread" = "xyes"
-then
-       SAVE_LIBS="$LIBS"
-       AC_CHECK_LIB(pthread, pthread_create, [], [with_libpthread="no (Symbol 'pthread_create' not found)"], [])
-       PTHREAD_LIBS="$LIBS"
-       LIBS="$SAVE_LIBS"
-fi
+SAVE_LIBS="$LIBS"
+AC_CHECK_LIB([pthread],
+  [pthread_create],
+  [],
+  [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread"])],
+  []
+)
+PTHREAD_LIBS="$LIBS"
+LIBS="$SAVE_LIBS"
 
-if test "x$with_libpthread" = "xyes"
-then
-       AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
-# }}}
+AC_CHECK_HEADERS([pthread.h],
+  [],
+  [AC_MSG_ERROR([pthread.h not found])]
+)
 
 m4_divert_once([HELP_WITH], [
 collectd additional packages:])
@@ -6203,7 +6187,6 @@ Configuration:
     libperfstat . . . . . $with_perfstat
     libperl . . . . . . . $with_libperl
     libpq . . . . . . . . $with_libpq
-    libpthread  . . . . . $with_libpthread
     librabbitmq . . . . . $with_librabbitmq
     libriemann-client . . $with_libriemann_client
     librdkafka  . . . . . $with_librdkafka
index ec562d8..19a1fb1 100644 (file)
@@ -80,6 +80,7 @@ collectd_tg_SOURCES = collectd-tg.c
 collectd_tg_CPPFLAGS = $(AM_CPPFLAGS) \
                       -I$(top_srcdir)/src/libcollectdclient/collectd -I$(top_builddir)/src/libcollectdclient/collectd
 collectd_tg_LDADD = \
+       $(PTHREAD_LIBS) \
        daemon/libheap.la \
        libcollectdclient/libcollectdclient.la
 if BUILD_WITH_LIBSOCKET
@@ -91,9 +92,6 @@ endif
 if BUILD_AIX
 collectd_tg_LDADD += -lm
 endif
-if BUILD_WITH_LIBPTHREAD
-collectd_tg_LDADD += $(PTHREAD_LIBS)
-endif
 
 
 pkglib_LTLIBRARIES =
index 18aef36..d59e823 100644 (file)
@@ -10,7 +10,7 @@ AM_CPPFLAGS += -DPLUGINDIR='"${pkglibdir}"'
 AM_CPPFLAGS += -DPKGDATADIR='"${pkgdatadir}"'
 
 # Link to these libraries..
-COMMON_LIBS =
+COMMON_LIBS = $(PTHREAD_LIBS)
 if BUILD_WITH_LIBRT
 COMMON_LIBS += -lrt
 endif
@@ -23,9 +23,6 @@ endif
 if BUILD_WITH_LIBRESOLV
 COMMON_LIBS += -lresolv
 endif
-if BUILD_WITH_LIBPTHREAD
-COMMON_LIBS += $(PTHREAD_LIBS)
-endif
 if BUILD_WITH_LIBKSTAT
 COMMON_LIBS += -lkstat
 endif