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

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

 



On 08/28/2014 02:05 AM, Zé wrote:

>> 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.
> 
> That would be preferable.  Is there any way to pull that off?  I've
> tried with variables, but nothing behaved quite as I expected it to
> behave.  For example, say there these variables are declared in
> configure.ac prior to calling AC_INIT:
> 
> MAJOR_VERSION = 1
> MINOR_VERSION = 0
> PATCH_VERSION = 0
> 
> let's say the intended outcome is to pass the version number to AC_INIT,
> so that it would be equivalent to:
> 
> AC_INIT([foo], [1.0.0])

Untested:

# M4 macros, for use during autoconf time...
m4_define([MAJOR_VERSION], [1])
m4_define([MINOR_VERSION], [0])
m4_define([PATCH_VERSION], [0])
AC_INIT([foo], MAJOR_VERSION.MINOR_VERSION.PATCH_VERSION)

# Now reflect it for use during configure time...
m4_divert_text([DEFAULTS], [
[MAJOR_VERSION]=MAJOR_VERSION
[MINOR_VERSION]=MINOR_VERSION
[PATCH_VERSION]=PATCH_VERSION
])

But that approach will let you use the m4 macros that expand as needed
(calling AC_INIT([foo], [1.0.0]) as desired) as well as letting your
configure start with shell variables (a line such as MAJOR_VERSION=1).
Actually, picking _different_ names for the m4 macros than for the shell
variables may make use of it less confusing, particularly if you also
end up wanting to AC_DEFINE a substitution variable for use in C code.
Hope that gives you some ideas.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux