From: Pali Rohár Date: Sun, 8 May 2022 12:31:11 +0000 (+0200) Subject: libpci: Put name and version information into DLL library X-Git-Tag: v3.9.0~17^2 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=59cb656889fe77f062b7391160188b70bf60c7b2;p=pciutils.git libpci: Put name and version information into DLL library 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. --- diff --git a/Makefile b/Makefile index 409cefc..e2e3bd7 100644 --- 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 diff --git a/lib/Makefile b/lib/Makefile index ae23144..77cef30 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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 index 0000000..519772b --- /dev/null +++ b/lib/dllrsrc.rc.in @@ -0,0 +1,35 @@ +#include +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