Hi Sebastien, On 24/8/21 2:49 am, Sébastien Hinderer wrote:
Dear all, I am trying to define a package version properly by first defining its components separately (major and minor version number, patchlevel, and extra). The major and minor numbers are assumed to be always present. The patchlevel and the extra bits are optional. In pseudo-shell code, the version would built like this: major=x minor=y patch=z extra=rc2 extra_prefix='+' # Could also be a '~' version="$major.$minor" if [ -n "$patchlevel"]; then version="$version.$patchlevel"; fi if [ -n "$extra" ]; then version="$version${extra_prefix}${extra}" fi I would like to express all this in m4, more precisely in aclocal.m4, so that the configure script has proper version information. At the moment I don't manage to do so and failed to find an exemple of a macro whose body can take several lines but with the spaces at the begin of the lines (except the first one) being ignored. So I resorted to format but I didn't manage to make that work either and it any way feels too complex to be correct. Here is how the code looks like at the moment: # Package version define(`PKG_VERSION_MAJOR', `4')dnl define(`PKG_VERSION_MINOR', `14')dnl define(`PKG_VERSION_PATCH_LEVEL', `0')dnl define(`PKG_VERSION_EXTRA', `dev0-2021-06-03')dnl define(`PKG_VERSION_EXTRA_PREFIX', `+')dnl could also be `~' define(`PKG_VERSION', ``format(dnl PKG_VERSION_MAJOR.PKG_VERSION_MINOR`%s%s',dnl ifelse(PKG_VERSION_PATCH_LEVEL,`',`',.PKG_VERSION_PATCH_LEVEL),dnl ifelse(PKG_VERSION_PATCH_LEVEL,`',`',dnl PKG_VERSION_EXTRA_PREFIX`'PKG_VERSION_EXTRA)dnl )''dnl )dnl
We are doing something similar in yat. You might be able to borrow some of the code from here
https://dev.thep.lu.se/yat/browser/trunk/m4/my_version.m4 Cheers, Peter