Although bitcoin/bitcoin#22646 was a great change, it broke Windows builds with DEBUG=1:
$ make -C depends HOST=x86_64-w64-mingw32 DEBUG=1 NO_QT=1 NO_ZMQ=1 NO_WALLET=1 NO_UPNP=1 NO_NATPMP=1
$ ./autogen.sh
$ ./configure CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site --without-libs
$ make clean
$ make
...
CXXLD bitcoind.exe
/usr/bin/x86_64-w64-mingw32-ld: ./.libs/libunivalue.a(libunivalue_la-univalue.o):univalue.cpp:(.text+0x7d1): undefined reference to `__imp_pthread_mutex_lock'
/usr/bin/x86_64-w64-mingw32-ld: ./.libs/libunivalue.a(libunivalue_la-univalue.o):univalue.cpp:(.text+0x7d8): undefined reference to `__imp_pthread_mutex_unlock'
...
Please note that the --without-libs configuration option, therefore, this bug differs from bitcoin/bitcoin#19772.
Unfortunately, this is another evidence of the tough relationship between Libtool and cross-compiler for MinGW-w64. Other workarounds see here and here.
This PR avoids using Libtool for the libunivalue library at all. After bitcoin/bitcoin#22646 the libunivalue library been built not using its own build system. In such a context it will never be a shared library. Therefore, no need to use Libtool, and the libunivalue library could be a non-Libtool convenience library.
Btw, I strongly believe such an approach could also solve bitcoin/bitcoin#19772.
FWIW, while working on this PR I found a more concise fix:
--- a/src/Makefile.univalue.include
+++ b/src/Makefile.univalue.include
@@ -4,3 +4,6 @@ LIBUNIVALUE = libunivalue.la
noinst_LTLIBRARIES += $(LIBUNIVALUE)
libunivalue_la_SOURCES = $(UNIVALUE_LIB_SOURCES_INT) $(UNIVALUE_DIST_HEADERS_INT) $(UNIVALUE_LIB_HEADERS_INT) $(UNIVALUE_TEST_FILES_INT)
libunivalue_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
+if TARGET_WINDOWS
+libunivalue_la_LDFLAGS = -static
+endif