[Top][All Lists]

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

Re: automatic linking links too many files

From: Philip Guenther
Subject: Re: automatic linking links too many files
Date: Mon, 25 May 2009 12:57:38 -0700

On Mon, May 25, 2009 at 5:56 AM, Federico Poloni <address@hidden> wrote:
> Thanks for the advice. I was not reporting this behavior as erroneous, but
> warning that it differs significantly from the documentation ("Each kind of
> file automatically made into `.o' object files will be
> automatically linked").

Yes, the behavior doesn't match the docs.  I guess the question now is
which should be changed.  The current behavior is  better than what is
documented for at least two cases---archive files and linker
scripts---though the latter is quite obscure.  Fixing the docs to say
that the default rule will treat all prerequisites of the executable
as linker inputs seems better to me.

> In fact, there is this neat workaround:
> -----Makefile contents
> $(phony foo):   textfile
> executable: $(phony foo)
> -----
> but that was not my point.

Umm, what do you think the above actually does?  There's no built-in
function $(phony), so all you've done is removed 'textfile' from
'executable's prerequisite list.  If you change textfile, executable
will *not* be rebuilt!

> Additional remark:
> An executable depending from a text file may actually be needed in real
> life: e.g. in order to use the Gtk+ component GtkBuilder, the executable
> must read a `foo.ui' xml file which should be built from a `foo.glade' file.

Can you briefly enumerate the actual commands that need to be invoked
in such a setup, indicating what files are the input and output files
in each step (if it's not obvious)?

I ask, because I suspect you're mixing *build-time* dependencies and
*run-time* dependencies.  In a makefile, the prerequisites for a
target, executable or otherwise, should only be those needed at
build-time.  If "foo.ui" is read at runtime by the executable itself,
then the foo.ui is *NOT* a prerequisite of the executable.

Philip Guenther

reply via email to

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