Post by ZéWhat's the best way to set up an autoconf project so that the major,
minor and patch version numbers are made available to the entire package
(automake and source code) and used to define the VERSION and
PACKAGE_VERSION variables?
Here's how libvirt does it:
AC_INIT([libvirt], [1.2.8], [libvir-***@redhat.com], [],
[http://libvirt.org])
# First extract pieces from the version number string
LIBVIRT_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
LIBVIRT_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
LIBVIRT_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
LIBVIRT_VERSION=$LIBVIRT_MAJOR_VERSION.$LIBVIRT_MINOR_VERSION.$LIBVIRT_MICRO_VERSION$LIBVIRT_MICRO_VERSION_SUFFIX
LIBVIRT_VERSION_NUMBER=`expr $LIBVIRT_MAJOR_VERSION \* 1000000 +
$LIBVIRT_MINOR_VERSION \* 1000 + $LIBVIRT_MICRO_VERSION`
AGE=`expr $LIBVIRT_MAJOR_VERSION '*' 1000 + $LIBVIRT_MINOR_VERSION`
REVISION=$LIBVIRT_MICRO_VERSION
CURRENT=`expr $LIBVIRT_SONUM + $AGE`
LIBVIRT_VERSION_INFO=$CURRENT:$REVISION:$AGE
AC_SUBST([LIBVIRT_MAJOR_VERSION])
AC_SUBST([LIBVIRT_MINOR_VERSION])
AC_SUBST([LIBVIRT_MICRO_VERSION])
AC_SUBST([LIBVIRT_SONUM])
AC_SUBST([LIBVIRT_VERSION])
AC_SUBST([LIBVIRT_VERSION_INFO])
AC_SUBST([LIBVIRT_VERSION_NUMBER])
which may be more than what you needed, but sure seems to fit the bill.
That took the 'AC_INIT is canonical, derive everything else from it'
approach. It should also be possible to do the reverse: declare m4
macros and shell variables up front for major/minor/patch, then generate
AC_INIT by calling those macros rather than open-coding the version.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org