Build: Make version.h a configuration header

Use the proper tool for the job and make libsigrok/version.h
a secondary configuration header, so that autoconf's AC_DEFINE
machinery can be used to generate it.  Note that the header
template is still hand-written, enabling fine control of the
content.
This commit is contained in:
Daniel Elstner 2015-08-14 17:53:06 +02:00
parent 4960aeb035
commit b2478a23db
3 changed files with 29 additions and 30 deletions

6
.gitignore vendored
View File

@ -18,7 +18,8 @@ map
missing missing
stamp-h1 stamp-h1
autostuff/ autostuff/
version.h /include/libsigrok/version.h
/include/libsigrok/stamp-h2
ChangeLog ChangeLog
INSTALL INSTALL
tests/check_main tests/check_main
@ -41,8 +42,9 @@ Makefile.in
# KDE backup files # KDE backup files
*.kate-swp *.kate-swp
# KDevelop project files # IDE project files
*.kdev4 *.kdev4
/Makefile.am.user
# Files generated by building C++ bindings # Files generated by building C++ bindings
doxy/ doxy/

View File

@ -30,7 +30,7 @@ m4_define([sr_package_version], [sr_package_version_major.sr_package_version_min
AC_INIT([libsigrok], [sr_package_version], [sigrok-devel@lists.sourceforge.net], AC_INIT([libsigrok], [sr_package_version], [sigrok-devel@lists.sourceforge.net],
[libsigrok], [http://www.sigrok.org]) [libsigrok], [http://www.sigrok.org])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADERS([config.h include/libsigrok/version.h])
AC_CONFIG_MACRO_DIR([autostuff]) AC_CONFIG_MACRO_DIR([autostuff])
AC_CONFIG_AUX_DIR([autostuff]) AC_CONFIG_AUX_DIR([autostuff])
@ -66,6 +66,13 @@ LT_INIT
# We require at least 0.22, as "Requires.private" behaviour changed there. # We require at least 0.22, as "Requires.private" behaviour changed there.
PKG_PROG_PKG_CONFIG([0.22]) PKG_PROG_PKG_CONFIG([0.22])
AC_SUBST([SR_PACKAGE_VERSION], [sr_package_version])
AC_DEFINE([SR_PACKAGE_VERSION_MAJOR], [sr_package_version_major], [.])
AC_DEFINE([SR_PACKAGE_VERSION_MINOR], [sr_package_version_minor], [.])
AC_DEFINE([SR_PACKAGE_VERSION_MICRO], [sr_package_version_micro], [.])
AC_DEFINE_UNQUOTED([SR_PACKAGE_VERSION_STRING], ["$SR_PACKAGE_VERSION"], [.])
# Library version for libsigrok (NOT the same as the package version). # Library version for libsigrok (NOT the same as the package version).
# Carefully read the libtool docs before updating these numbers! # Carefully read the libtool docs before updating these numbers!
# The algorithm for determining which number to change (and how) is nontrivial! # The algorithm for determining which number to change (and how) is nontrivial!
@ -73,13 +80,14 @@ PKG_PROG_PKG_CONFIG([0.22])
SR_LIB_VERSION_CURRENT=2 SR_LIB_VERSION_CURRENT=2
SR_LIB_VERSION_REVISION=0 SR_LIB_VERSION_REVISION=0
SR_LIB_VERSION_AGE=0 SR_LIB_VERSION_AGE=0
SR_LIB_VERSION="$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"
SR_LIB_LDFLAGS="-version-info $SR_LIB_VERSION" AC_SUBST([SR_LIB_VERSION], ["$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"])
AC_SUBST(SR_LIB_VERSION_CURRENT) AC_SUBST([SR_LIB_LDFLAGS], ["-version-info $SR_LIB_VERSION"])
AC_SUBST(SR_LIB_VERSION_REVISION)
AC_SUBST(SR_LIB_VERSION_AGE) AC_DEFINE_UNQUOTED([SR_LIB_VERSION_CURRENT], [$SR_LIB_VERSION_CURRENT], [.])
AC_SUBST(SR_LIB_VERSION) AC_DEFINE_UNQUOTED([SR_LIB_VERSION_REVISION], [$SR_LIB_VERSION_REVISION], [.])
AC_SUBST(SR_LIB_LDFLAGS) AC_DEFINE_UNQUOTED([SR_LIB_VERSION_AGE], [$SR_LIB_VERSION_AGE], [.])
AC_DEFINE_UNQUOTED([SR_LIB_VERSION_STRING], ["$SR_LIB_VERSION"], [.])
AC_ARG_ENABLE(all-drivers, AC_HELP_STRING([--enable-all-drivers], AC_ARG_ENABLE(all-drivers, AC_HELP_STRING([--enable-all-drivers],
[enable all drivers by default [default=yes]]), [enable all drivers by default [default=yes]]),
@ -555,18 +563,7 @@ AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
AC_SUBST(MAKEFLAGS, '--no-print-directory') AC_SUBST(MAKEFLAGS, '--no-print-directory')
AC_SUBST(AM_LIBTOOLFLAGS, '--silent') AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
SR_PACKAGE_VERSION_MAJOR=sr_package_version_major AC_CONFIG_FILES([Makefile libsigrok.pc bindings/cxx/libsigrokcxx.pc])
SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
SR_PACKAGE_VERSION=sr_package_version
AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
AC_SUBST(SR_PACKAGE_VERSION_MINOR)
AC_SUBST(SR_PACKAGE_VERSION_MICRO)
AC_SUBST(SR_PACKAGE_VERSION)
AC_CONFIG_FILES([Makefile include/libsigrok/version.h libsigrok.pc
bindings/cxx/libsigrokcxx.pc])
AC_OUTPUT AC_OUTPUT

View File

@ -37,32 +37,32 @@
*/ */
/** The libsigrok package 'major' version number. */ /** The libsigrok package 'major' version number. */
#define SR_PACKAGE_VERSION_MAJOR @SR_PACKAGE_VERSION_MAJOR@ #undef SR_PACKAGE_VERSION_MAJOR
/** The libsigrok package 'minor' version number. */ /** The libsigrok package 'minor' version number. */
#define SR_PACKAGE_VERSION_MINOR @SR_PACKAGE_VERSION_MINOR@ #undef SR_PACKAGE_VERSION_MINOR
/** The libsigrok package 'micro' version number. */ /** The libsigrok package 'micro' version number. */
#define SR_PACKAGE_VERSION_MICRO @SR_PACKAGE_VERSION_MICRO@ #undef SR_PACKAGE_VERSION_MICRO
/** The libsigrok package version ("major.minor.micro") as string. */ /** The libsigrok package version ("major.minor.micro") as string. */
#define SR_PACKAGE_VERSION_STRING "@SR_PACKAGE_VERSION@" #undef SR_PACKAGE_VERSION_STRING
/* /*
* Library/libtool version macros (can be used for conditional compilation). * Library/libtool version macros (can be used for conditional compilation).
*/ */
/** The libsigrok libtool 'current' version number. */ /** The libsigrok libtool 'current' version number. */
#define SR_LIB_VERSION_CURRENT @SR_LIB_VERSION_CURRENT@ #undef SR_LIB_VERSION_CURRENT
/** The libsigrok libtool 'revision' version number. */ /** The libsigrok libtool 'revision' version number. */
#define SR_LIB_VERSION_REVISION @SR_LIB_VERSION_REVISION@ #undef SR_LIB_VERSION_REVISION
/** The libsigrok libtool 'age' version number. */ /** The libsigrok libtool 'age' version number. */
#define SR_LIB_VERSION_AGE @SR_LIB_VERSION_AGE@ #undef SR_LIB_VERSION_AGE
/** The libsigrok libtool version ("current:revision:age") as string. */ /** The libsigrok libtool version ("current:revision:age") as string. */
#define SR_LIB_VERSION_STRING "@SR_LIB_VERSION@" #undef SR_LIB_VERSION_STRING
/** @} */ /** @} */