From: Uwe Hermann Date: Sat, 15 Aug 2015 19:06:30 +0000 (+0200) Subject: backend: Output lib versions, host, and endianness in sr_init(). X-Git-Tag: libsigrok-0.4.0~448 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bd7b83cf631d515ae7e9560400cef2d9f662299a;p=libsigrok.git backend: Output lib versions, host, and endianness in sr_init(). This should help to more easily debug issues reported by users. --- diff --git a/configure.ac b/configure.ac index 3eccf89d..ff9c9395 100644 --- a/configure.ac +++ b/configure.ac @@ -261,6 +261,8 @@ AC_DEFINE_UNQUOTED(HAVE_RPC, [$have_rpc], [Specifies whether we have RPC support # VXI support is only compiled if RPC support was found. AM_CONDITIONAL(NEED_RPC, test "x$have_rpc" != "x0") +AC_DEFINE_UNQUOTED(HOST, ["$host"], [.]) + # libglib-2.0 is always needed. Abort if it's not found. # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement). # We require at least 2.32.0 due to e.g. g_variant_new_fixed_array(). @@ -271,6 +273,8 @@ AM_PATH_GLIB_2_0([2.32.0], PKG_CHECK_MODULES([libzip], [libzip >= 0.10], [LIB_CFLAGS="$LIB_CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS"; SR_PKGLIBS="$SR_PKGLIBS libzip"]) +libzip_ver=`$PKG_CONFIG --modversion libzip` +AC_DEFINE_UNQUOTED(HAVE_LIBZIP_VER, ["$libzip_ver"], [.]) # libserialport is only needed for some hardware drivers. Disable the # respective drivers if it is not found. @@ -315,6 +319,8 @@ if test "x$have_librevisa" != "xno"; then # Define HAVE_LIBREVISA in config.h if we found librevisa. AC_DEFINE_UNQUOTED(HAVE_LIBREVISA, [1], [Specifies whether we have librevisa.]) + librevisa_ver=`$PKG_CONFIG --modversion librevisa` + AC_DEFINE_UNQUOTED(HAVE_LIBREVISA_VER, ["$librevisa_ver"], [.]) fi # The GPIB SCPI backend is only compiled in if libgpib is found. @@ -328,6 +334,8 @@ if test "x$have_libgpib" != "xno"; then # Define HAVE_LIBGPIB in config.h if we found libgpib. AC_DEFINE_UNQUOTED(HAVE_LIBGPIB, [1], [Specifies whether we have libgpib.]) + libgpib_ver=`$PKG_CONFIG --modversion libgpib` + AC_DEFINE_UNQUOTED(HAVE_LIBGPIB_VER, ["$libgpib_ver"], [.]) fi # libusb-1.0 is only needed for some hardware drivers. Disable the respective @@ -374,12 +382,13 @@ AM_CONDITIONAL(NEED_USB, test "x$have_libusb1_0" != xno) if test "x$enable_libftdi" != "xno"; then PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16], [have_libftdi="yes"; LIB_CFLAGS="$LIB_CFLAGS $libftdi_CFLAGS"; - LIBS="$LIBS $libftdi_LIBS"; - SR_PKGLIBS="$SR_PKGLIBS libftdi"], + LIBS="$LIBS $libftdi_LIBS"; SR_PKGLIBS="$SR_PKGLIBS libftdi"; + libftdi_ver=`$PKG_CONFIG --modversion libftdi`], [PKG_CHECK_MODULES([libftdi1], [libftdi1 >= 1.0], [LIB_CFLAGS="$LIB_CFLAGS $libftdi1_CFLAGS"; LIBS="$LIBS $libftdi1_LIBS"; - SR_PKGLIBS="$SR_PKGLIBS libftdi1"], + SR_PKGLIBS="$SR_PKGLIBS libftdi1"; + libftdi_ver=`$PKG_CONFIG --modversion libftdi1`], [have_libftdi="no"])]) if test "x$enable_libftdi$have_libftdi" = "xyesno"; then AC_MSG_ERROR([libftdi support requested, but it was not found.]) @@ -390,6 +399,11 @@ fi if test "x$have_libftdi" = "xno"; then HW_ASIX_SIGMA="no"; HW_CHRONOVU_LA="no"; HW_IKALOGIC_SCANAPLUS="no"; HW_PIPISTRELLO_OLS="no"; +else + # Define HAVE_LIBFTDI in config.h if we found libftdi. + AC_DEFINE_UNQUOTED(HAVE_LIBFTDI, [1], + [Specifies whether we have libftdi.]) + AC_DEFINE_UNQUOTED(HAVE_LIBFTDI_VER, ["$libftdi_ver"], [.]) fi # glibmm-2.4 is needed for the C++ bindings. diff --git a/src/backend.c b/src/backend.c index 613de246..4889358a 100644 --- a/src/backend.c +++ b/src/backend.c @@ -119,6 +119,83 @@ * @{ */ +static void print_versions(void) +{ + GString *s; +#ifdef HAVE_LIBUSB_1_0 + const struct libusb_version *lv; +#endif + + s = g_string_sized_new(200); + + sr_dbg("libsigrok %s/%s (rt: %s/%s).", + SR_PACKAGE_VERSION_STRING, SR_LIB_VERSION_STRING, + sr_package_version_string_get(), sr_lib_version_string_get()); + + g_string_append(s, "Libs: "); + g_string_append_printf(s, "glib %d.%d.%d (rt: %d.%d.%d/%d:%d), ", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION, + glib_major_version, glib_minor_version, glib_micro_version, + glib_binary_age, glib_interface_age); + g_string_append_printf(s, "libzip %s, ", HAVE_LIBZIP_VER); +#ifdef HAVE_LIBSERIALPORT + g_string_append_printf(s, "libserialport %s/%s (rt: %s/%s), ", + SP_PACKAGE_VERSION_STRING, SP_LIB_VERSION_STRING, + sp_get_package_version_string(), sp_get_lib_version_string()); +#endif +#ifdef HAVE_LIBUSB_1_0 + lv = libusb_get_version(); + g_string_append_printf(s, "libusb-1.0 %d.%d.%d.%d%s, ", + lv->major, lv->minor, lv->micro, lv->nano, lv->rc); +#endif +#ifdef HAVE_LIBFTDI + g_string_append_printf(s, "libftdi %s, ", HAVE_LIBFTDI_VER); +#endif +#ifdef HAVE_LIBGPIB + g_string_append_printf(s, "libgpib %s, ", HAVE_LIBGPIB_VER); +#endif +#ifdef HAVE_LIBREVISA + g_string_append_printf(s, "librevisa %s, ", HAVE_LIBREVISA_VER); +#endif + s->str[s->len - 2] = '.'; + s->str[s->len - 1] = '\0'; + sr_dbg("%s", s->str); + + s = g_string_truncate(s, 0); + g_string_append_printf(s, "Host: %s, ", HOST); +#ifdef WORDS_BIGENDIAN + g_string_append_printf(s, "big-endian."); +#else + g_string_append_printf(s, "little-endian."); +#endif + sr_dbg("%s", s->str); + + s = g_string_truncate(s, 0); + g_string_append_printf(s, "SCPI backends: "); + + g_string_append_printf(s, "TCP, "); +#if HAVE_RPC + g_string_append_printf(s, "RPC, "); +#endif +#ifdef HAVE_LIBSERIALPORT + g_string_append_printf(s, "serial, "); +#endif +#ifdef HAVE_LIBREVISA + g_string_append_printf(s, "VISA, "); +#endif +#ifdef HAVE_LIBGPIB + g_string_append_printf(s, "GPIB, "); +#endif +#ifdef HAVE_LIBUSB_1_0 + g_string_append_printf(s, "USBTMC, "); +#endif + s->str[s->len - 2] = '.'; + s->str[s->len - 1] = '\0'; + sr_dbg("%s", s->str); + + g_string_free(s, TRUE); +} + /** * Sanity-check all libsigrok drivers. * @@ -384,6 +461,8 @@ SR_API int sr_init(struct sr_context **ctx) struct sr_dev_driver ***lists, **drivers; GArray *array; + print_versions(); + if (!ctx) { sr_err("%s(): libsigrok context was NULL.", __func__); return SR_ERR;