Search code examples
gitversioningautotoolsautoconfm4

How to insert Git-based version in autoconf-managed project?


How can I assign a dynamic, git-based version number to an autoconf project? Autoconf requires a static string argument to

AC_INIT([Title],[version],[name])

AC_INIT documentation says that one can use M4 to supply a shell-based version. M4 is beyond my ken. I'd like to version my software according to the results of this command

version=`git describe --abbrev=7 --dirty --always --tags`

This produces something like 4.6.6-alpha07-9-ga3e01a8.

I may not understand high level answers. I need a solution like "cut and paste this into your autoconf.ac and/or acinclude.m4".

Any help appreciated.


Solution

  • How about:

    AC_INIT([Title], [m4_esyscmd_s([git describe --abbrev=7 --dirty --always --tags])])
    

    should work for you.