summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2011-05-09 08:12:24 +0200
committerPeter Stuge <peter@stuge.se>2011-06-13 22:06:30 +0200
commit85a14f43e0ce27cd47f84fdaeacbaa81cebdb886 (patch)
treeef39f336c38dc9c82e432d20572ec02fbd65a6f1 /configure.ac
parent3481f52b014110f6c291e5a15e79ba774dcdfacf (diff)
downloadlibusb-85a14f43e0ce27cd47f84fdaeacbaa81cebdb886.tar.gz
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.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac20
1 files changed, 12 insertions, 8 deletions
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])