Hi Kevin,
On 8/31/2009 7:09 PM, Kevin wrote:
Hi, all:
I have a question about print the project compile date.
I have a project which contains 2 files: "a.c" and "b.c"*. *I want to
print project compile date in one of these 2 files. I put it in a.c:
>>>>>>>>>>>>>>>>>>>>>>>
// This is a.c
#include <stdio.h>
int main()
{
printf("%s\n", __DATE__);
return 0;
}
<<<<<<<<<<<<<<<<<<<<<<<
And b.c looks like this:
>>>>>>>>>>>>>>>>>>>>>>>
// This is b.c
#include <stdio.h>
int do_something(void)
{
//......;
}
<<<<<<<<<<<<<<<<<<<<<<<
If only "b.c" is modified, and no change in "a.c" at all, when I
recompile the project, the printed date doesn't reflect the latest
changes in project (in my case "b.c").
I am wondering how to print the project compile date/time to show the
latest modification in project files?
Basically, you're telling us that you want a.c to compile every time you
build your project, so that you get the latest date/time stamp from the
latest build. I guess the exception to this might be that you only want
to "update" a.c if the program needs to be rebuilt for any other reason,
otherwise, you want make to act as it always does if everything is
already up to date - that is, do nothing.
I am using powerpc-eabi-gcc, and my Makefile looks like this:
>>>>>>>>>>>>>>>>>>>>>>>
APP = showdate
SRCS = a.c b.c
OBJS = $(SRCS:.c=.o)
$(APP): $(OBJS)
$(CC) $^ -o $@
<<<<<<<<<<<<<<<<<<<<<<<
Is there a mechanism in GNU tools to pass the compile date/time info
and no need to change source file? Can I do it in Makefile? Or any
other better choices?
Try adding this line to the *end* of your Makefile (untested):
a.c: $(APP)
John
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make