commit 2534aab3f96c0284203b6566c399623332bccd71
parent 03abafc46bfcdc92e4c20ad6e4613212a335f626
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Wed, 5 Jun 2024 15:02:32 +0200
W32 resources: reworked, added support for the static lib resources
Diffstat:
3 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -172,6 +172,7 @@ AC_SYS_LARGEFILE
AC_FUNC_FSEEKO
LT_INIT([win32-dll])
LT_LANG([Windows Resource])
+lt_prog_compiler_pic_RC="$lt_prog_compiler_pic_RC -DDLL_EXPORT" # Used only on W32
AC_ARG_ENABLE([compact-code],
[AS_HELP_STRING([[--enable-compact-code]],
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
@@ -123,36 +123,34 @@ libmicrohttpd_la_LIBADD = \
$(MHD_LIBDEPS) $(MHD_TLS_LIBDEPS)
-if HAVE_W32
-MHD_DLL_RES_SRC = microhttpd_dll_res.rc
-MHD_DLL_RES_LO = libmicrohttpd_la-$(MHD_DLL_RES_SRC:.rc=.lo)
-
-EXTRA_libmicrohttpd_la_DEPENDENCIES = $(MHD_DLL_RES_LO)
-libmicrohttpd_la_LIBADD += $(MHD_DLL_RES_LO)
-
-AM_V_RC = $(am__v_RC_$(V))
-am__v_RC_ = $(am__v_RC_$(AM_DEFAULT_VERBOSITY))
+AM_V_RC = $(am__v_RC_@AM_V@)
+am__v_RC_ = $(am__v_RC_@AM_DEFAULT_V@)
am__v_RC_0 = @echo " RC " $@;
am__v_RC_1 =
# General rule is not required, but keep it just in case
+# Note: windres does not understand '-isystem' flag, so all
+# possible '-isystem' flags are replaced by simple '-I' flags.
.rc.lo:
- $(AM_V_RC) $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< -o $@
-
-# To add dll resource only to .dll file and exclude it form static
-# lib, a little trick was used. Allow libtool to create file.lo,
-# file.o and .libs/file.lo, .libs/file.o files, then overwrite file.o
-# by empty object generated from empty c-file. Later libtool will
-# use .libs/file.o for shared lib and empty file.o for static lib.
-# This implementation is based on trick found in liblzma.
+ $(AM_V_RC) RC_ALL_CPPFLAGS=`echo ' $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) ' | $(SED) -e 's/ -isystem / -I /g'`; \
+ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_ALL_CPPFLAGS} $< -o $@
+
# Note: windres does not understand '-isystem' flag, so all
# possible '-isystem' flags are replaced by simple '-I' flags.
-$(MHD_DLL_RES_LO): $(MHD_DLL_RES_SRC)
- $(AM_V_RC) RC_CPP_FLAGS=" $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) " && \
- $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_CPP_FLAGS// -isystem / -I} $< -o $@ && \
- echo > $@-empty.c && $(CC) $(DEFS) $(AM_CFLAGS) $(CFLAGS) -c $@-empty.c -o $(@:.lo=.o) && rm -f $@-empty.c
+libmicrohttpd_la-microhttpd_dll_res.lo: $(builddir)/microhttpd_dll_res.rc
+ $(AM_V_RC) RC_ALL_CPPFLAGS=`echo ' $(DEFAULT_INCLUDES) $(INCLUDES) $(libmicrohttpd_la_CPPFLAGS) $(CPPFLAGS) ' | $(SED) -e 's/ -isystem / -I /g'`; \
+ $(LIBTOOL) $(AM_V_lt) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(RC) $(RCFLAGS) $(DEFS) $${RC_ALL_CPPFLAGS} $(builddir)/microhttpd_dll_res.rc -o $@
+
+if HAVE_W32
+MHD_DLL_RES_LO = libmicrohttpd_la-microhttpd_dll_res.lo
+else
+MHD_DLL_RES_LO =
endif
+EXTRA_libmicrohttpd_la_DEPENDENCIES = $(MHD_DLL_RES_LO)
+libmicrohttpd_la_LIBADD += $(MHD_DLL_RES_LO)
+
+
if USE_COVERAGE
AM_CFLAGS += --coverage
endif
diff --git a/src/microhttpd/microhttpd_dll_res.rc.in b/src/microhttpd/microhttpd_dll_res.rc.in
@@ -1,4 +1,4 @@
-/* W32 resources for .dll */
+/* W32 resources */
#include <winresrc.h>
@@ -13,7 +13,11 @@ VS_VERSION_INFO VERSIONINFO
FILEFLAGS 0
#endif
FILEOS VOS_NT_WINDOWS32
+#ifdef DLL_EXPORT
FILETYPE VFT_DLL
+#else
+ FILETYPE VFT_STATIC_LIB
+#endif
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
@@ -23,11 +27,19 @@ BEGIN
VALUE "ProductName", "GNU libmicrohttpd\0"
VALUE "ProductVersion", "@PACKAGE_VERSION@\0"
VALUE "FileVersion", "@PACKAGE_VERSION@\0"
+#ifdef DLL_EXPORT
VALUE "FileDescription", "GNU libmicrohttpd DLL for Windows (MinGW build, @W32CRT@ run-time lib)\0"
+#else
+ VALUE "FileDescription", "GNU libmicrohttpd static library for Windows (MinGW build, @W32CRT@ run-time lib)\0"
+#endif
VALUE "InternalName", "libmicrohttpd\0"
+#ifdef DLL_EXPORT
VALUE "OriginalFilename", "libmicrohttpd-@MHD_W32_DLL_SUFF@.dll\0"
+#else
+ VALUE "OriginalFilename", "libmicrohttpd.lib\0"
+#endif
VALUE "CompanyName", "Free Software Foundation\0"
- VALUE "LegalCopyright", "Copyright (C) 2007-2021 Christian Grothoff, Evgeny Grin, and project contributors\0"
+ VALUE "LegalCopyright", "Copyright (C) 2007-2024 Christian Grothoff, Evgeny Grin, and project contributors\0"
VALUE "Comments", "http://www.gnu.org/software/libmicrohttpd/\0"
END
END