Creating build number with Momentics

Hi all,
I need some advise about the creation of a build number with Momentics.
My recipe look spretty much like the one Rob presented in his last book,
i.e. a version.c file with a version number in it, declared as a const
char*.
A utility increments the last part of it: “2.1.342” → “2.1.343”.
Here are the 2 options that I have, neither of them is satisfying:

  • Use of the PRE_BUILD macro in common.mk: this executes the utility
    that increments the build number AFTER everything is compiled, just
    before the linker is invoked. This makes the executable tagged with a
    version number that is 1 lower than the code.
  • Use of the PRE_CLEAN macro in common.mk: this execute the utility
    before the clean target is called, thus “tagging” the executable with
    the good version number when rebuilding the application. But this will
    more than likely lead to errors,forcing a rebuild to create a new build
    number.

Any suggestion to make this work as I would like it to?
Or is there another way around?

Thanks
Martin