]> mj.ucw.cz Git - pciutils.git/commitdiff
libpci: Put name and version information into DLL library
authorPali Rohár <pali@kernel.org>
Sun, 8 May 2022 12:31:11 +0000 (14:31 +0200)
committerPali Rohár <pali@kernel.org>
Sun, 30 Oct 2022 15:00:36 +0000 (16:00 +0100)
Generate rc file from in template and fill DLL name and DLL version from
Makefile.

It looks like that the only possible way via GNU tools to specify version
information for DLL library is via text rc file compiled as COFF object
file via GNU windres and linked into the final DLL library via GNU ld.

Makefile
lib/Makefile
lib/dllrsrc.rc.in [new file with mode: 0644]

index 409cefce628710a0d27db7db4c96caac17d106bc..e2e3bd7ee74d92f46e9a26a7ee0f7cde6fe4492c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -54,6 +54,7 @@ endif
 AR=$(CROSS_COMPILE)ar
 RANLIB=$(CROSS_COMPILE)ranlib
 DLLTOOL=$(CROSS_COMPILE)dlltool
+WINDRES=$(CROSS_COMPILE)windres
 
 # Base name of the library (overridden on NetBSD, which has its own libpci)
 LIBNAME=libpci
@@ -124,7 +125,7 @@ TAGS:
 
 clean:
        rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
-       rm -f update-pciids lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lib/config.* *.[578] pci.ids.gz lib/*.pc lib/*.so lib/*.so.* lib/*.dll lib/*.def tags
+       rm -f update-pciids lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lib/config.* *.[578] pci.ids.gz lib/*.pc lib/*.so lib/*.so.* lib/*.dll lib/*.def lib/dllrsrc.rc tags
        rm -rf maint/dist
 
 distclean: clean
index ae2314408eaf252fb8356583503e9c9e5d8008f6..77cef30c0bb1509e498aac36d1776129f3213825 100644 (file)
@@ -74,6 +74,15 @@ $(PCIIMPDEF): libpci.ver ver2def.pl
        perl ver2def.pl libpci.ver $(PCILIB) build.def $(PCIIMPDEF)
 $(PCIIMPLIB): $(PCIIMPDEF)
        $(DLLTOOL) --input-def $< --output-lib $@
+comma := ,
+dllrsrc.rc: dllrsrc.rc.in
+       sed <$< >$@ -e 's,@PCILIB_VERSION@,$(PCILIB_VERSION),' \
+               -e 's,@PCILIB_VERSION_WINRC@,$(subst .,\$(comma),$(PCILIB_VERSION).0),' \
+               -e 's,@PCILIB@,$(PCILIB),' \
+               -e 's,@DEBUG_BUILD@,$(if $(findstring -g,$(CFLAGS)),1,0),'
+dllrsrc.o: dllrsrc.rc
+       $(WINDRES) --input=$< --output=$@ --input-format=rc --output-format=coff
+OBJS += dllrsrc
 endif
 CFLAGS += -fPIC -fvisibility=hidden
 $(PCILIB): $(addsuffix .o,$(OBJS))
diff --git a/lib/dllrsrc.rc.in b/lib/dllrsrc.rc.in
new file mode 100644 (file)
index 0000000..519772b
--- /dev/null
@@ -0,0 +1,35 @@
+#include <windows.h>
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION @PCILIB_VERSION_WINRC@
+PRODUCTVERSION @PCILIB_VERSION_WINRC@
+FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#if @DEBUG_BUILD@
+FILEFLAGS VS_FF_DEBUG
+#else
+FILEFLAGS 0
+#endif
+FILEOS VOS_NT_WINDOWS32
+FILETYPE VFT_DLL
+FILESUBTYPE 0
+BEGIN
+       BLOCK "StringFileInfo"
+       BEGIN
+               /*
+                * GNU windres seems that converts 7-bit ASCII strings to UTF-16,
+                * so specify UNICODE/UTF-16 encoding (0x04B0) for these strings.
+                */
+               BLOCK "040904B0" /* Default U.S. English language, UNICODE/UTF-16 codepage */
+               BEGIN
+                       VALUE "FileDescription", "libpci"
+                       VALUE "FileVersion", "@PCILIB_VERSION@"
+                       VALUE "InternalName", "@PCILIB@"
+                       VALUE "OriginalFilename", "@PCILIB@"
+                       VALUE "ProductName", "pciutils"
+                       VALUE "ProductVersion", "@PCILIB_VERSION@"
+               END
+       END
+       BLOCK "VarFileInfo"
+       BEGIN
+               VALUE "Translation", 0x0409, 0x004B0 /* Default U.S. English language, UNICODE/UTF-16 codepage */
+       END
+END