]> sigrok.org Git - libsigrok.git/commitdiff
configure: hook up minilzo to the libsigrok build, reflect its version
authorGerhard Sittig <redacted>
Sun, 13 Aug 2017 15:41:38 +0000 (17:41 +0200)
committerGerhard Sittig <redacted>
Wed, 20 Oct 2021 18:38:08 +0000 (20:38 +0200)
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.

Makefile.am
configure.ac
src/backend.c

index 4b05175b480870bd89e38f7647d4e8a1bf1f40d2..4557677ac4f116880e81022cb4fefc7fa7d982b6 100644 (file)
@@ -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.
 
 # 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
 AM_CXXFLAGS = $(SR_WXXFLAGS) $(LIBSIGROKCXX_CFLAGS)
 
 lib_LTLIBRARIES = libsigrok.la
@@ -70,6 +71,10 @@ libsigrok_la_SOURCES = \
        src/std.c \
        src/sw_limits.c
 
        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 \
 # Input modules
 libsigrok_la_SOURCES += \
        src/input/input.c \
index 6a92e097d27dced24749a26b92835a491b77f10c..982f54300b40625041db9504f43dd97e3d27e6bd 100644 (file)
@@ -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], [], [], [])
 
 # 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  ##
 ########################
 ########################
 ##  Hardware drivers  ##
 ########################
index 471800315a1016a72768b73e7bf6a05cdd82fdf2..79340822fb38f8e9cc817297e7b5db6f948fa282 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
 #endif
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
+#include "minilzo/minilzo.h"
 
 /** @cond PRIVATE */
 #define LOG_PREFIX "backend"
 
 /** @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(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)",
 #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
 
        }
 #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) {
 #ifdef HAVE_LIBUSB_1_0
        ret = libusb_init(&context->libusb_ctx);
        if (LIBUSB_SUCCESS != ret) {