help-make
[Top][All Lists]
Advanced

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

Re: print project compile date


From: John Calcote
Subject: Re: print project compile date
Date: Mon, 31 Aug 2009 22:03:45 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.1) Gecko/20090715 Thunderbird/3.0b3

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

reply via email to

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