From: Gerhard Sittig Date: Sun, 13 Aug 2017 15:41:38 +0000 (+0200) Subject: configure: hook up minilzo to the libsigrok build, reflect its version X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b9cd0c6a53a6f6c4c4520748b860693306fbdb23;p=libsigrok.git configure: hook up minilzo to the libsigrok build, reflect its version Add the minilzo/ directory to the list of source files for the libsigrok build. Have the minilzo library use the project's config.h file, extend the set of autoconf checks. This approach follows the documentation in the README.LZO file. It avoids the dependency on an external library and its version or configuration. Reflect the minilzo version in the libsigrok version output. The example application which ships with the library suggests that failed init calls typically originate from compile issues. Present the same error message to sigrok users as the example application does. --- diff --git a/Makefile.am b/Makefile.am index 4b05175b..4557677a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,7 +42,8 @@ AM_CPPFLAGS = $(local_includes) $(global_defs) # The tests CFLAGS are a superset of the libsigrok CFLAGS, and the # python bindings CFLAGS are a superset of the C++ bindings CFLAGS. -AM_CFLAGS = $(SR_EXTRA_CFLAGS) $(SR_WFLAGS) $(TESTS_CFLAGS) +SR_MINILZO_CFLAGS = -DMINILZO_HAVE_CONFIG_H +AM_CFLAGS = $(SR_EXTRA_CFLAGS) $(SR_WFLAGS) $(SR_MINILZO_CFLAGS) $(TESTS_CFLAGS) AM_CXXFLAGS = $(SR_WXXFLAGS) $(LIBSIGROKCXX_CFLAGS) lib_LTLIBRARIES = libsigrok.la @@ -70,6 +71,10 @@ libsigrok_la_SOURCES = \ src/std.c \ src/sw_limits.c +# Support code, shared among input and driver modules +libsigrok_la_SOURCES += \ + src/minilzo/minilzo.c + # Input modules libsigrok_la_SOURCES += \ src/input/input.c \ diff --git a/configure.ac b/configure.ac index 6a92e097..982f5430 100644 --- a/configure.ac +++ b/configure.ac @@ -213,6 +213,27 @@ AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes]) # Check for compiler support of 128 bit integers AC_CHECK_TYPES([__int128_t, __uint128_t], [], [], []) + +####################### +## miniLZO related ## +####################### +# These were taken from the README.LZO file in the miniLZO archive. + +AC_CHECK_TYPE(ptrdiff_t,long) +AC_TYPE_SIZE_T +AC_CHECK_SIZEOF(short) +AC_CHECK_SIZEOF(int) +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(__int64) +AC_CHECK_SIZEOF(void *) +AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(ptrdiff_t) + +AC_C_CONST + +AC_CHECK_FUNCS(memcmp memcpy memmove memset) + ######################## ## Hardware drivers ## ######################## diff --git a/src/backend.c b/src/backend.c index 47180031..79340822 100644 --- a/src/backend.c +++ b/src/backend.c @@ -25,6 +25,7 @@ #endif #include #include "libsigrok-internal.h" +#include "minilzo/minilzo.h" /** @cond PRIVATE */ #define LOG_PREFIX "backend" @@ -140,6 +141,10 @@ SR_API GSList *sr_buildinfo_libs_get(void) m = g_slist_append(m, g_strdup_printf("%s", CONF_LIBZIP_VERSION)); l = g_slist_append(l, m); + m = g_slist_append(NULL, g_strdup("minilzo")); + m = g_slist_append(m, g_strdup_printf("%s", lzo_version_string())); + l = g_slist_append(l, m); + #ifdef HAVE_LIBSERIALPORT m = g_slist_append(NULL, g_strdup("libserialport")); m = g_slist_append(m, g_strdup_printf("%s/%s (rt: %s/%s)", @@ -594,6 +599,14 @@ SR_API int sr_init(struct sr_context **ctx) } #endif + if ((ret = lzo_init()) != LZO_E_OK) { + sr_err("lzo_init() failed with return code %d.", ret); + sr_err("This usually indicates a compiler bug. Recompile without"); + sr_err("optimizations, and enable '-DLZO_DEBUG' for diagnostics."); + ret = SR_ERR; + goto done; + } + #ifdef HAVE_LIBUSB_1_0 ret = libusb_init(&context->libusb_ctx); if (LIBUSB_SUCCESS != ret) {