autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strategy to specify major, minor, and patch versions


From: Eric Blake
Subject: Re: Strategy to specify major, minor, and patch versions
Date: Wed, 27 Aug 2014 09:10:27 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

On 08/27/2014 03:52 AM, Zé wrote:
> 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], address@hidden, [],
[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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]