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
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make