]> sigrok.org Git - libsigrok.git/commitdiff
configure: make zlib an optional dependency which input/stf depends on
authorGerhard Sittig <redacted>
Wed, 22 Dec 2021 12:39:38 +0000 (13:39 +0100)
committerGerhard Sittig <redacted>
Wed, 22 Dec 2021 19:04:28 +0000 (20:04 +0100)
The STF input module calls into the zlib's crc32() routine, although
this dependency is not checked for and need not be satisfied. This went
unnoticed because zlib is rather ubiquitous, most development machines
provide it.

Extend the configure script to check for the zlib presence. Absence is
non-fatal (the library is truly optional). Reflect the version details
in the libsigrok version output, update the README. Make the STF input
module depend on the zlib presence, which makes the module optional.

It's unfortunate that the MiniLZO library which the libsigrok source
embeds does not provide the CRC32 calculation. Else we could have used
it instead of introducing another external dependency.

This implementation attempts to properly separate the autoconf/shell
layer from the automake layer from the C language preprocessor, and
separate the zlib library availability from the compression and CRC32
calculation availability from the STF input module applicability. This
shall prepare more zlib use in future implementations.

Makefile.am
README
configure.ac
src/backend.c
src/input/input.c

index 67b73b5df00c55dfc99aa08ac72ec95cb9189196..280cf64d29d915199a0b3092f9ffd5a96d5d3f7b 100644 (file)
@@ -85,11 +85,14 @@ libsigrok_la_SOURCES += \
        src/input/logicport.c \
        src/input/raw_analog.c \
        src/input/saleae.c \
        src/input/logicport.c \
        src/input/raw_analog.c \
        src/input/saleae.c \
-       src/input/stf.c \
        src/input/trace32_ad.c \
        src/input/vcd.c \
        src/input/wav.c \
        src/input/null.c
        src/input/trace32_ad.c \
        src/input/vcd.c \
        src/input/wav.c \
        src/input/null.c
+if HAVE_INPUT_STF
+libsigrok_la_SOURCES += \
+       src/input/stf.c
+endif
 
 # Output modules
 libsigrok_la_SOURCES += \
 
 # Output modules
 libsigrok_la_SOURCES += \
diff --git a/README b/README
index d1f965667bc828ffd60d64fbbb0d07129d0fa49f..768c8ca2b6612d1850d69f8f25e95c830850aef7 100644 (file)
--- a/README
+++ b/README
@@ -37,6 +37,7 @@ Requirements for the C library:
  - libtool (only needed when building from git)
  - pkg-config >= 0.22
  - libglib >= 2.32.0
  - libtool (only needed when building from git)
  - pkg-config >= 0.22
  - libglib >= 2.32.0
+ - zlib (optional, used for CRC32 calculation in STF input)
  - libzip >= 0.10
  - libtirpc (optional, used by VXI, fallback when glibc >= 2.26)
  - libserialport >= 0.1.1 (optional, used by some drivers)
  - libzip >= 0.10
  - libtirpc (optional, used by VXI, fallback when glibc >= 2.26)
  - libserialport >= 0.1.1 (optional, used by some drivers)
index 982f54300b40625041db9504f43dd97e3d27e6bd..27e79e4d365523281216aec57800ebd716312339 100644 (file)
@@ -96,6 +96,18 @@ SR_PKGLIBS_RUBY=
 SR_EXTRA_LIBS=
 SR_EXTRA_CXX_LIBS=
 
 SR_EXTRA_LIBS=
 SR_EXTRA_CXX_LIBS=
 
+SR_ARG_OPT_PKG([zlib], [ZLIB], , [zlib])
+AM_CONDITIONAL([HAVE_ZLIB], [test "x$sr_have_zlib" = xyes])
+AM_COND_IF([HAVE_ZLIB], [
+       SR_APPEND([sr_deps_avail], [crc32 zlib])
+       SR_PREPEND([SR_EXTRA_LIBS], [-lz])
+])
+
+AM_CONDITIONAL([HAVE_INPUT_STF], [test "x$sr_have_zlib" = xyes])
+AM_COND_IF([HAVE_INPUT_STF], [
+       AC_DEFINE([HAVE_INPUT_STF], [1], [Is the STF input module supported?])
+])
+
 SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], ,
        [libserialport >= 0.1.1])
 
 SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], ,
        [libserialport >= 0.1.1])
 
@@ -621,9 +633,12 @@ AM_COND_IF([NEED_USB], [AS_CASE([$sr_have_libusb_os_handle:$host_os], [no:mingw*
 
 sr_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
 sr_libzip_version=`$PKG_CONFIG --modversion libzip 2>&AS_MESSAGE_LOG_FD`
 
 sr_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
 sr_libzip_version=`$PKG_CONFIG --modversion libzip 2>&AS_MESSAGE_LOG_FD`
+sr_zlib_version=`$PKG_CONFIG --modversion zlib 2>&AS_MESSAGE_LOG_FD`
 
 AC_DEFINE_UNQUOTED([CONF_LIBZIP_VERSION], ["$sr_libzip_version"],
        [Build-time version of libzip.])
 
 AC_DEFINE_UNQUOTED([CONF_LIBZIP_VERSION], ["$sr_libzip_version"],
        [Build-time version of libzip.])
+AC_DEFINE_UNQUOTED([CONF_ZLIB_VERSION], ["$sr_zlib_version"],
+       [Build-time version of zlib.])
 AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"],
        [The canonical host libsigrok will run on.])
 
 AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"],
        [The canonical host libsigrok will run on.])
 
index 79340822fb38f8e9cc817297e7b5db6f948fa282..82ad42f7ee6b7b2e442a78a7af93c06433dd4c3f 100644 (file)
@@ -137,6 +137,10 @@ SR_API GSList *sr_buildinfo_libs_get(void)
                glib_binary_age, glib_interface_age));
        l = g_slist_append(l, m);
 
                glib_binary_age, glib_interface_age));
        l = g_slist_append(l, m);
 
+       m = g_slist_append(NULL, g_strdup("zlib"));
+       m = g_slist_append(m, g_strdup_printf("%s", CONF_ZLIB_VERSION));
+       l = g_slist_append(l, m);
+
        m = g_slist_append(NULL, g_strdup("libzip"));
        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("libzip"));
        m = g_slist_append(m, g_strdup_printf("%s", CONF_LIBZIP_VERSION));
        l = g_slist_append(l, m);
index 8708cc637a886beb5829354d9b69fffdd1356611..b5de532bc58a1c25a4d3430d223a8b5b8ee7299b 100644 (file)
@@ -80,7 +80,9 @@ static const struct sr_input_module *input_module_list[] = {
        &input_binary,
        &input_chronovu_la8,
        &input_csv,
        &input_binary,
        &input_chronovu_la8,
        &input_csv,
+#if defined HAVE_INPUT_STF && HAVE_INPUT_STF
        &input_stf,
        &input_stf,
+#endif
        &input_trace32_ad,
        &input_vcd,
        &input_wav,
        &input_trace32_ad,
        &input_vcd,
        &input_wav,