* Vincent Torri wrote on Sun, Nov 01, 2009 at 12:00:13PM CET:
> I wanted to write an m4 macro to be put in a lot of our configure.ac
> files. The problem is that the code contain '$1' to compute the
> parts of the version of the package (major, minor, etc...). The code
> is the following:
>
> VMAJ=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $1);}'`
> VMIN=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $2);}'`
> VMIC=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $3);}'`
> SNAP=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $4);}'`
> version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN"
>
> So, actually, my first question is: is there a better way to compute
> the major, etc.. parts of the version number ?
Better in terms of less forks, but also typically harder to grok for
developers not fluent in shell handling:
save_IFS=$IFS
IFS=.
set x $PACKAGE_VERSION
IFS=$save_IFS
shift
VMAJ=$1 VMIN=$2 VMIC=$3 SNAP=$4
version_info=...
Note that this scribbles over the positional parameters.
> If not, how can I tell m4 to not expand $* in the printf command ?
If you are in a singly-m4-quoted environment: $[]* $[]1 or $[1] or so
If you are in a singly-m4-quoted environment: $][* $][1 ...
Cheers,
Ralf
_______________________________________________
Autoconf mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/autoconf