From: Daniel Elstner Date: Fri, 14 Aug 2015 15:53:06 +0000 (+0200) Subject: Build: Make version.h a configuration header X-Git-Tag: libsigrok-0.4.0~443 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b2478a23db9a966678aa6cb8c4f0b53b13b13fa6;p=libsigrok.git 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. --- diff --git a/.gitignore b/.gitignore index 706cf9da..66fb4d39 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,8 @@ map missing stamp-h1 autostuff/ -version.h +/include/libsigrok/version.h +/include/libsigrok/stamp-h2 ChangeLog INSTALL tests/check_main @@ -41,8 +42,9 @@ Makefile.in # KDE backup files *.kate-swp -# KDevelop project files +# IDE project files *.kdev4 +/Makefile.am.user # Files generated by building C++ bindings doxy/ diff --git a/configure.ac b/configure.ac index 45ee40cf..fe07938f 100644 --- a/configure.ac +++ b/configure.ac @@ -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], [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_AUX_DIR([autostuff]) @@ -66,6 +66,13 @@ LT_INIT # We require at least 0.22, as "Requires.private" behaviour changed there. 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). # Carefully read the libtool docs before updating these numbers! # 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_REVISION=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_CURRENT) -AC_SUBST(SR_LIB_VERSION_REVISION) -AC_SUBST(SR_LIB_VERSION_AGE) -AC_SUBST(SR_LIB_VERSION) -AC_SUBST(SR_LIB_LDFLAGS) + +AC_SUBST([SR_LIB_VERSION], ["$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"]) +AC_SUBST([SR_LIB_LDFLAGS], ["-version-info $SR_LIB_VERSION"]) + +AC_DEFINE_UNQUOTED([SR_LIB_VERSION_CURRENT], [$SR_LIB_VERSION_CURRENT], [.]) +AC_DEFINE_UNQUOTED([SR_LIB_VERSION_REVISION], [$SR_LIB_VERSION_REVISION], [.]) +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], [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(AM_LIBTOOLFLAGS, '--silent') -SR_PACKAGE_VERSION_MAJOR=sr_package_version_major -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_CONFIG_FILES([Makefile libsigrok.pc bindings/cxx/libsigrokcxx.pc]) AC_OUTPUT diff --git a/include/libsigrok/version.h.in b/include/libsigrok/version.h.in index d0440913..1c977bd8 100644 --- a/include/libsigrok/version.h.in +++ b/include/libsigrok/version.h.in @@ -37,32 +37,32 @@ */ /** 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. */ -#define SR_PACKAGE_VERSION_MINOR @SR_PACKAGE_VERSION_MINOR@ +#undef SR_PACKAGE_VERSION_MINOR /** 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. */ -#define SR_PACKAGE_VERSION_STRING "@SR_PACKAGE_VERSION@" +#undef SR_PACKAGE_VERSION_STRING /* * Library/libtool version macros (can be used for conditional compilation). */ /** 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. */ -#define SR_LIB_VERSION_REVISION @SR_LIB_VERSION_REVISION@ +#undef SR_LIB_VERSION_REVISION /** 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. */ -#define SR_LIB_VERSION_STRING "@SR_LIB_VERSION@" +#undef SR_LIB_VERSION_STRING /** @} */