On Nov 4, 2010, Benjamin Bihler <benjamin.bih...@twt-gmbh.de> wrote:
> As to the third suggestion: I use the __DATE__ and __TIME__
> macros in my code as a kind of version information. Therefore
> the compilation result differs with every compilation, although
> my source file does not change. Is there yet a better method to
> store the compilation time stamp in a library without fiddling
> with make targets?

We do fiddle with make targets, but in this way:

--[Makefile.am]---------------------------------------------------->8=======
some_SOURCES=app.c
# ensure to compile-in the current date
app.$(OBJEXT): $(LIBDEPS) $(l...@mainmodulename@_a_SOURCES) Makefile
=======8<-------------------------------------------------------------------

app.c includes some

--[app.c]---------------------------------------------------------->8=======
   const char *const version = SYS_VERSION
#if defined(DEBUG)
   " (DEBUG), compiled " __DATE__ " " __TIME__
#endif
   /* non-debug (but release-) versions are guaranteed to have a
    * unique dedicated SYS_VERSION */
   ;
=======8<-------------------------------------------------------------------

I'm not sure if this is best (correct), but seems to work well.

I think the big advantage over .PHONY is that is does not
re-genereate the binary (a new binary, actually!) if nothing was
changed at all, which IMHO would be a bad habit.

oki,

Steffen

Reply via email to