From bd797318dc25cf86460af9971644a7b92dc34c7d Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Sat, 19 May 2018 18:50:06 +0700 Subject: [PATCH] Added support for libi2c-4.0 Closes: #2646 --- Makefile.am | 2 +- configure.ac | 9 +++++++++ src/barometer.c | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index b944b412..3d0964e0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -593,7 +593,7 @@ if BUILD_PLUGIN_BAROMETER pkglib_LTLIBRARIES += barometer.la barometer_la_SOURCES = src/barometer.c barometer_la_LDFLAGS = $(PLUGIN_LDFLAGS) -barometer_la_LIBADD = -lm +barometer_la_LIBADD = -lm $(BUILD_WITH_LIBI2C_LIBS) endif if BUILD_PLUGIN_BATTERY diff --git a/configure.ac b/configure.ac index 8ef9fc83..4be85bbf 100644 --- a/configure.ac +++ b/configure.ac @@ -1875,14 +1875,23 @@ fi # libi2c-dev if test "x$ac_system" = "xLinux"; then + with_libi2c_libs="" + AC_CHECK_HEADERS([i2c/smbus.h], + [with_libi2c_libs="-li2c"] + ) AC_CHECK_DECL([i2c_smbus_read_i2c_block_data], [with_libi2c="yes"], [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"], [[ #include #include + #if HAVE_I2C_SMBUS_H + # include + #endif ]] ) + BUILD_WITH_LIBI2C_LIBS="$with_libi2c_libs" + AC_SUBST([BUILD_WITH_LIBI2C_LIBS]) else with_libi2c="no (Linux only)" fi diff --git a/src/barometer.c b/src/barometer.c index 66ab20c0..a54d998a 100644 --- a/src/barometer.c +++ b/src/barometer.c @@ -27,6 +27,9 @@ #include #include +#if HAVE_I2C_SMBUS_H +#include +#endif #include #include #include -- 2.11.0