automake
[Top][All Lists]
Advanced

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

Re: compiling in the build time


From: Tim Van Holder
Subject: Re: compiling in the build time
Date: Fri, 04 Nov 2005 16:33:49 +0100
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Ralf Wildenhues wrote:
> Hi David, Warren.
> 
> * Warren Young wrote on Fri, Nov 04, 2005 at 01:49:42AM CET:
> 
>>David Byron wrote:
>>
>>>What I'm having trouble with is getting the builddate.c recipe to happen
>>>at the right time.  
>>
>>Could you make it depend on *.o except for builddate.o?  If any of those 
>>change, rebuild builddate.c, which will cause builddate.o to be rebuilt.
> 
> 
> Can't you just make it depend on the other source files?
> 
>   builddate.c: $(geoidx_SOURCES)
>           echo ...

Well, it all depends on what "the build timestamp" is supposed to mean.
If builds are only made from fresh source trees, depending on the
sources is fine.
However, if it is supposed to be the date of the last build (i.e. "make"
invocation) that produced a new executable, then depending on the
sources is not correct (example: initial make, then "rm *.o; make" two
days later).  Even depending on the objects is not enough, as one of
the libraries (or any other LDADD stuff) may have changed.
So the only "correct" way to have this work correctly is something like:

builddate.c: <whatever the target depends on except builddate.$(OBJEXT)>

which probably comes down to

builddate.c: $(filter-out builddate.$(OBJEXT),$(foo_OBJECTS)) \
             $(foo_LDADD)

(not sure how to do it outside of GNU make).

I do something similar in my (non-automake) makefiles; except that I
use __DATE__ and __TIME__ in the source, and it's the object that
depends on all other objects and libraries to trigger a recompile.

Perhaps you can get away with:

foo_SOURCES: foo.c bar.c
foo_LDADD: xyzzy.a

foo$(EXEEXT): build.$(OBJEXT)

build.$(OBJEXT): build.c $(foo_OBJECTS) $(foo_LDADD)

(but I'm not sure how kosher it is to have sources/objects that you
don't tell automake about).





reply via email to

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