From 5415a1c985b45326fcc5ac5fb56b01863fbcf9cd Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Wed, 10 Jul 2013 23:54:13 +0200 Subject: [PATCH] sigrok: build system setup --- configure.in | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 10 +++++++ 2 files changed, 81 insertions(+) diff --git a/configure.in b/configure.in index 27c6cd31..0838de8b 100644 --- a/configure.in +++ b/configure.in @@ -3767,6 +3767,74 @@ fi AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes") # }}} +# --with-libsigrok {{{ +with_libsigrok_cflags="" +with_libsigrok_ldflags="" +AC_ARG_WITH(libsigrok, [AS_HELP_STRING([--with-libsigrok@<:@=PREFIX@:>@], [Path to libsigrok.])], +[ + if test "x$withval" = "xno" + then + with_libsigrok="no" + else + with_libsigrok="yes" + if test "x$withval" != "xyes" + then + with_libsigrok_cflags="-I$withval/include" + with_libsigrok_ldflags="-L$withval/lib" + fi + fi +],[]) + +# libsigrok has a glib dependency +if test "x$with_libsigrok" = "xyes" +then + if test -z "m4_ifdef([AM_PATH_GLIB_2_0], [yes], [])" + then + with_libsigrok="no (glib not available)" + else + AM_PATH_GLIB_2_0([2.28.0], + [with_libsigrok_cflags="$with_libsigrok_cflags $GLIB_CFLAGS"; with_libsigrok_ldflags="$with_libsigrok_ldflags $GLIB_LIBS"]) + fi +fi + +# libsigrok headers +if test "x$with_libsigrok" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags" + + AC_CHECK_HEADERS(libsigrok/libsigrok.h, [], [with_libsigrok="no (libsigrok/libsigrok.h not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" +fi + +# libsigrok library +if test "x$with_libsigrok" = "xyes" +then + SAVE_CPPFLAGS="$CPPFLAGS" + SAVE_LDFLAGS="$LDFLAGS" + CPPFLAGS="$CPPFLAGS $with_libsigrok_cflags" + LDFLAGS="$LDFLAGS $with_libsigrok_ldflags" + + AC_CHECK_LIB(sigrok, sr_init, + [ + AC_DEFINE(HAVE_LIBSIGROK, 1, [Define to 1 if you have the sigrok library (-lsigrok).]) + ], + [with_libsigrok="no (libsigrok not found)"]) + + CPPFLAGS="$SAVE_CPPFLAGS" + LDFLAGS="$SAVE_LDFLAGS" +fi +if test "x$with_libsigrok" = "xyes" +then + BUILD_WITH_LIBSIGROK_CFLAGS="$with_libsigrok_cflags" + BUILD_WITH_LIBSIGROK_LDFLAGS="$with_libsigrok_ldflags" + AC_SUBST(BUILD_WITH_LIBSIGROK_CFLAGS) + AC_SUBST(BUILD_WITH_LIBSIGROK_LDFLAGS) +fi +AM_CONDITIONAL(BUILD_WITH_LIBSIGROK, test "x$with_libsigrok" = "xyes") +# }}} + # --with-libstatgrab {{{ with_libstatgrab_cflags="" with_libstatgrab_ldflags="" @@ -5098,6 +5166,7 @@ AC_PLUGIN([rrdcached], [$librrd_rrdc_update], [RRDTool output plugin]) AC_PLUGIN([rrdtool], [$with_librrd], [RRDTool output plugin]) AC_PLUGIN([sensors], [$with_libsensors], [lm_sensors statistics]) AC_PLUGIN([serial], [$plugin_serial], [serial port traffic]) +AC_PLUGIN([sigrok], [$with_libsigrok], [sigrok acquisition sources]) AC_PLUGIN([snmp], [$with_libnetsnmp], [SNMP querying plugin]) AC_PLUGIN([swap], [$plugin_swap], [Swap usage statistics]) AC_PLUGIN([syslog], [$have_syslog], [Syslog logging plugin]) @@ -5331,6 +5400,7 @@ Configuration: librouteros . . . . . $with_librouteros librrd . . . . . . . $with_librrd libsensors . . . . . $with_libsensors + libsigrok . . . . . $with_libsigrok libstatgrab . . . . . $with_libstatgrab libtokyotyrant . . . $with_libtokyotyrant libupsclient . . . . $with_libupsclient @@ -5435,6 +5505,7 @@ Configuration: rrdtool . . . . . . . $enable_rrdtool sensors . . . . . . . $enable_sensors serial . . . . . . . $enable_serial + sigrok . . . . . . . $enable_sigrok snmp . . . . . . . . $enable_snmp swap . . . . . . . . $enable_swap syslog . . . . . . . $enable_syslog diff --git a/src/Makefile.am b/src/Makefile.am index c3e596d4..bdde5a35 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1052,6 +1052,16 @@ collectd_LDADD += "-dlopen" serial.la collectd_DEPENDENCIES += serial.la endif +if BUILD_PLUGIN_SIGROK +pkglib_LTLIBRARIES += sigrok.la +sigrok_la_SOURCES = sigrok.c +sigrok_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBSIGROK_CFLAGS) +sigrok_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBSIGROK_LDFLAGS) +sigrok_la_LIBADD = -lsigrok +collectd_LDADD += "-dlopen" sigrok.la +collectd_DEPENDENCIES += sigrok.la +endif + if BUILD_PLUGIN_SNMP pkglib_LTLIBRARIES += snmp.la snmp_la_SOURCES = snmp.c -- 2.30.2