[collectd] [PATCH 1/3] configure, perl plugin: Check for ithreads support.

Sebastian Harl sh at tokkee.org
Tue Nov 13 23:58:20 CET 2007


Disable the perl plugin if Perl does not support ithreads (introduced in Perl
5.6). The configure script will check, if USE_ITHREADS has been defined. Also,
the perl plugin won't build if it has not been defined.

Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
 configure.in |   43 ++++++++++++++++++++++++++++++++++++++++++-
 src/perl.c   |    4 ++++
 2 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/configure.in b/configure.in
index 2936058..d9bca16 100644
--- a/configure.in
+++ b/configure.in
@@ -1261,6 +1261,41 @@ then
 fi
 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
 
+if test "x$with_libperl" = "xyes"
+then
+	SAVE_CFLAGS=$CFLAGS
+	SAVE_LDFLAGS=$LDFLAGS
+	CFLAGS="$CFLAGS $PERL_CFLAGS"
+	LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
+
+	AC_CACHE_CHECK([if perl supports ithreads],
+		[have_perl_ithreads],
+		AC_LINK_IFELSE(
+			AC_LANG_PROGRAM(
+			[[
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+
+#if !defined(USE_ITHREADS)
+# error "Perl does not support ithreads!"
+#endif /* !defined(USE_ITHREADS) */
+			]],
+			[[ ]]),
+			[have_perl_ithreads="yes"],
+			[have_perl_ithreads="no"]
+		)
+	)
+
+	if test "x$have_perl_ithreads" = "xyes"
+	then
+		AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
+	fi
+
+	CFLAGS=$SAVE_CFLAGS
+	LDFLAGS=$SAVE_LDFLAGS
+fi
+
 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
 [
 	if test "x$withval" != "xno" && test "x$withval" != "xyes"
@@ -1848,6 +1883,7 @@ plugin_load="no"
 plugin_memory="no"
 plugin_multimeter="no"
 plugin_nfs="no"
+plugin_perl="no"
 plugin_processes="no"
 plugin_serial="no"
 plugin_swap="no"
@@ -1945,6 +1981,11 @@ then
 	plugin_load="yes"
 fi
 
+if test "x$have_libperl$have_perl_ithreads" = "xyesyes"
+then
+	plugin_perl="yes"
+fi
+
 # Mac OS X memory interface
 if test "x$have_host_statistics" = "xyes"
 then
@@ -2012,7 +2053,7 @@ AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
-AC_PLUGIN([perl],        [$with_libperl],      [Embed a Perl interpreter])
+AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
diff --git a/src/perl.c b/src/perl.c
index 1ed9d00..1a380fe 100644
--- a/src/perl.c
+++ b/src/perl.c
@@ -42,6 +42,10 @@
 #include "plugin.h"
 #include "common.h"
 
+#if !defined(USE_ITHREADS)
+# error "Perl does not support ithreads!"
+#endif /* !defined(USE_ITHREADS) */
+
 #define PLUGIN_INIT     0
 #define PLUGIN_READ     1
 #define PLUGIN_WRITE    2
-- 
1.5.3.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071113/5ffb8b5b/attachment.pgp 


More information about the collectd mailing list