[Top][All Lists]

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

Re: compiling in the build time

From: Ralf Wildenhues
Subject: Re: compiling in the build time
Date: Fri, 4 Nov 2005 17:32:10 +0100
User-agent: Mutt/1.5.9i

Hi Tim,

* Tim Van Holder wrote on Fri, Nov 04, 2005 at 04:33:49PM CET:
> Ralf Wildenhues wrote:
> > 
> > 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.

Yes, of course.

> 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.

Well, create a stamp that is updated by config.status so after a
reconfigure you'll update.  For any in-project libraries, just add them
to the list of dependencies.  I'd also recommend putting things like
some config.h #define's and maybe flags like CFLAGS etc in the data.
For example, mutt does this very nicely.

> 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)

foo_OBJECTS is not published interface of Automake, so it may change.
You could use sth like
  $(patsubst %.c,%.$(OBJEXT), $(filter-out builddate.c, $(foo_SOURCES)))
with GNU make, though.

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

List files manually, I guess.  Portable make is quite limited there.

> 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.

Why do you care about the actual build time?

When I read a bug report, I want to know the time the sources were last
updated, i.e., which version the user has, not when he built whatever
old source.  Adding something like a svn version helps even more.

> Perhaps you can get away with:
> foo_SOURCES: foo.c bar.c
> foo_LDADD: xyzzy.a

(you mean `=' instead of `+', I guess; `:=' is not portable, by the

> 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).

That is no problem per se.  But if you use make dependencies instead of
the *_DEPENDENCIES variables, you have to write the updating rules
yourself, and update CLEANFILES, I believe.  And the same issue about
unpublished *_OBJECTS.

Maybe Automake should publish *_OBJECTS?
I do not know what issues might be hidden here, to be honest.


reply via email to

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