help-make
[Top][All Lists]
Advanced

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

Automatic build time inclusion


From: Martin Willers
Subject: Automatic build time inclusion
Date: Sun, 12 Feb 2006 21:23:43 +0100
User-agent: KMail/1.9

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?

-- 
 Martin




reply via email to

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