From 85a14f43e0ce27cd47f84fdaeacbaa81cebdb886 Mon Sep 17 00:00:00 2001 From: Peter Stuge Date: Mon, 9 May 2011 08:12:24 +0200 Subject: Move library version number from configure.ac to libusb/version.h This is neccessary to support native MS builds. The Windows resource file libusb/libusb-1.0.rc must include the release version, which was previously only available after configure had run and had substituted the numbers into a generated libusb/libusb-1.0.rc file. The version atoms are now stored as CPP style #defines in libusb/version.h so that the .rc no longer needs to be generated but can simply include the header file and access the version information directly. The m4 macro LU_DEFINE_VERSION_ATOM() was added to configure.ac to get version atoms from libusb/version.h for use in AC_INIT(). The macro handles C and C++ style comments in version.h, but can easily be made to fail by obscuring the file. Please don't do that. Tested with MinGW using autoconf, and manual compile of libusb-1.0.rc using RC.EXE Version 5.2.3690.0 from Visual C++ 2005 Express Edition. --- configure.ac | 20 ++++++++++------- libusb/libusb-1.0.rc | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ libusb/libusb-1.0.rc.in | 45 ------------------------------------- libusb/version.h | 14 ++++++++++++ 4 files changed, 86 insertions(+), 53 deletions(-) create mode 100644 libusb/libusb-1.0.rc delete mode 100644 libusb/libusb-1.0.rc.in create mode 100644 libusb/version.h diff --git a/configure.ac b/configure.ac index b805b23..bf2875e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,12 +1,17 @@ -m4_define(LIBUSB_MAJOR, [1]) -m4_define(LIBUSB_MINOR, [0]) -m4_define(LIBUSB_MICRO, [8]) +dnl These m4 macros are whitespace sensitive and break if moved around much. +m4_define([LU_VERSION_H], m4_include([libusb/version.h])) +m4_define([LU_DEFINE_VERSION_ATOM], + [m4_define([$1], m4_bregexp(LU_VERSION_H, + [^#define\s*$1\s*\([0-9]*\).*], [\1]))]) +dnl The m4_bregexp() returns (only) the numbers following the #define named +dnl in the first macro parameter. m4_define() then defines the name for use +dnl in AC_INIT(). -AC_INIT([libusb], LIBUSB_MAJOR.LIBUSB_MINOR.LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/]) +LU_DEFINE_VERSION_ATOM([LIBUSB_MAJOR]) +LU_DEFINE_VERSION_ATOM([LIBUSB_MINOR]) +LU_DEFINE_VERSION_ATOM([LIBUSB_MICRO]) -AC_SUBST([LIBUSB_VERSION_MAJOR], [LIBUSB_MAJOR]) -AC_SUBST([LIBUSB_VERSION_MINOR], [LIBUSB_MINOR]) -AC_SUBST([LIBUSB_VERSION_MICRO], [LIBUSB_MICRO]) +AC_INIT([libusb], LIBUSB_MAJOR[.]LIBUSB_MINOR[.]LIBUSB_MICRO, [libusb-devel@lists.sourceforge.net], [libusb], [http://www.libusb.org/]) # Library versioning # These numbers should be tweaked on every release. Read carefully: @@ -188,7 +193,6 @@ AC_SUBST(LTLDFLAGS) AC_CONFIG_FILES([libusb-1.0.pc]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([libusb/Makefile]) -AC_CONFIG_FILES([libusb/libusb-1.0.rc]) AC_CONFIG_FILES([examples/Makefile]) AC_CONFIG_FILES([doc/Makefile]) AC_CONFIG_FILES([doc/doxygen.cfg]) diff --git a/libusb/libusb-1.0.rc b/libusb/libusb-1.0.rc new file mode 100644 index 0000000..58933b5 --- /dev/null +++ b/libusb/libusb-1.0.rc @@ -0,0 +1,60 @@ +/* + * For Windows: input this file to the Resoure Compiler to produce a binary + * .res file. This is then embedded in the resultant library (like any other + * compilation object). + * The information can then be queried using standard APIs and can also be + * viewed with utilities such as Windows Explorer. + */ +#include "winresrc.h" + +#include "version.h" +#ifndef LIBUSB_VERSIONSTRING +#define LU_STR(s) #s +#define LU_XSTR(s) LU_STR(s) +#if LIBUSB_NANO > 0 +#define LIBUSB_VERSIONSTRING \ + LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \ + LU_XSTR(LIBUSB_MICRO) "." LU_XSTR(LIBUSB_NANO) "\0" +#else +#define LIBUSB_VERSIONSTRING \ + LU_XSTR(LIBUSB_MAJOR) "." LU_XSTR(LIBUSB_MINOR) "." \ + LU_XSTR(LIBUSB_MICRO) "\0" +#endif +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION LIBUSB_MAJOR,LIBUSB_MINOR,LIBUSB_MICRO,LIBUSB_NANO + PRODUCTVERSION LIBUSB_MAJOR,LIBUSB_MINOR,LIBUSB_MICRO,LIBUSB_NANO + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "\0" + VALUE "CompanyName", "libusb.org\0" + VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0" + VALUE "FileVersion", LIBUSB_VERSIONSTRING + VALUE "InternalName", "libusb\0" + VALUE "LegalCopyright", "See individual source files, GNU LGPL v2.1 or later.\0" + VALUE "LegalTrademarks", "http://www.gnu.org/licenses/lgpl-2.1.html\0" + VALUE "OriginalFilename", "libusb-1.0.dll\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "libusb-1.0\0" + VALUE "ProductVersion", LIBUSB_VERSIONSTRING + VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/libusb/libusb-1.0.rc.in b/libusb/libusb-1.0.rc.in deleted file mode 100644 index 81d46ce..0000000 --- a/libusb/libusb-1.0.rc.in +++ /dev/null @@ -1,45 +0,0 @@ -/* - * For Windows: input this file to the Resoure Compiler to produce a binary - * .res file. This is then embedded in the resultant library (like any other - * compilation object). - * The information can then be queried using standard APIs and can also be - * viewed with utilities such as Windows Explorer. - */ -#include "winresrc.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION @LIBUSB_VERSION_MAJOR@,@LIBUSB_VERSION_MINOR@,@LIBUSB_VERSION_MICRO@,0 - PRODUCTVERSION @LIBUSB_VERSION_MAJOR@,@LIBUSB_VERSION_MINOR@,@LIBUSB_VERSION_MICRO@,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "libusb.org\0" - VALUE "FileDescription", "C library for writing portable USB drivers in userspace\0" - VALUE "FileVersion", "@PACKAGE_VERSION@" - VALUE "InternalName", "libusb\0" - VALUE "LegalCopyright", "See individual source files, GNU LGPL v2.1 or later.\0" - VALUE "LegalTrademarks", "http://www.gnu.org/licenses/lgpl-2.1.html\0" - VALUE "OriginalFilename", "libusb-1.0.dll\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "libusb-1.0\0" - VALUE "ProductVersion", "@PACKAGE_VERSION@" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/libusb/version.h b/libusb/version.h new file mode 100644 index 0000000..ec45a32 --- /dev/null +++ b/libusb/version.h @@ -0,0 +1,14 @@ +/* This file is parsed by m4 and windres and RC.EXE so please keep it simple. */ +#ifndef LIBUSB_MAJOR +#define LIBUSB_MAJOR 1 +#endif +#ifndef LIBUSB_MINOR +#define LIBUSB_MINOR 0 +#endif +#ifndef LIBUSB_MICRO +#define LIBUSB_MICRO 8 +#endif +/* LIBUSB_NANO may be used for Windows internal versioning. 0 means unused. */ +#ifndef LIBUSB_NANO +#define LIBUSB_NANO 0 +#endif -- cgit v1.2.1