[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Force a file to be compiled always

From: Steffen Dettmer
Subject: Re: Force a file to be compiled always
Date: Wed, 10 Nov 2010 15:32:52 +0100

On Nov 4, 2010, Benjamin Bihler <address@hidden> 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:

# ensure to compile-in the current date
app.$(OBJEXT): $(LIBDEPS) $(address@hidden@_a_SOURCES) Makefile

app.c includes some

   const char *const version = SYS_VERSION
#if defined(DEBUG)
   " (DEBUG), compiled " __DATE__ " " __TIME__
   /* non-debug (but release-) versions are guaranteed to have a
    * unique dedicated SYS_VERSION */

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]