help-make
[Top][All Lists]
Advanced

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

Re: Automatic build time inclusion


From: Eric West
Subject: Re: Automatic build time inclusion
Date: Sun, 12 Feb 2006 18:37:10 -0500
User-agent: KMail/1.9.1

On Sunday 12 February 2006 15:23, Martin Willers wrote:
> Hi!
>
> Does anyone have an elegant method to include the time of
> build (really, time of final link stage) automatically into
> a program target?
> It would be easy to just prepend a phony target as prerequisite
> which creates a build_time.h or so.
>
> However, I want it to capture the time and re-link only when
> any of the main target's prerequisites has changed.
>
> What I have now is:
>
> program: $(OBJECTS)
>         echo "const char build_time[] = \"`date`\";" > build.c
>         $(CC) -c build.c
>         $(CC) -o $@ $(OBJECTS) build.o
>
> However, with this approach, I have to use an explicit
> compiler call to compile build.c - it would be nicer if I could
> let a pattern rule force compilation of build.c.
>
> Is there a better way to do this?

A bit off topic from Make help...

If your preprocessor supports them, there are the __DATE__ and __TIME__ 
defines. 

For example:
static char id[] = "@(#)"__DATE__" "__TIME__;
#include <stdio.h>


int
main()
{
        printf("id  = %s\n", id);
        return 0;
}


  --Eric




reply via email to

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