make-alpha
[Top][All Lists]
Advanced

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

Re: Questions About rename_file


From: Paul Smith
Subject: Re: Questions About rename_file
Date: Sun, 20 Mar 2022 10:02:27 -0400
User-agent: Evolution 3.42.4 (by Flathub.org))

On Thu, 2022-03-17 at 10:37 -0700, Jon Forrest wrote:
> 1) The documentation says:
> 
> "if the file does not exist, and it is found via directory search"
> 
> How can a file be found via directory search if it does not exist?
> Do you mean if the file does not exist in the file hash?

This entire page is talking about files where the target specified in
the makefile does not exist, but there is a target found via VPATH.

So if your makefile says:

  VPATH = /other/dir
  foo:

And there is no file "./foo" then "the file does not exist", but if
there is a file "/other/dir/foo" then it is "found via directory
search".

> 
> 2) The documentation says:
> 
> "If an out-of-date target is found by directory search in a directory
> that also appears in GPATH, then that pathname is not thrown away.
> The target is rebuilt using the expanded path.".
> 
> What's an expanded path in this case?

The expanded path is the one found by applying directory search; in the
above example it would be "/other/dir/foo".

> 3) When a file is renamed by rename_file(), rename_file() calls
> rehash_file() which tries to merge the file structures of the two
> files
> together. The comment in the code says:
> 
> /* TO_FILE already exists under TO_HNAME.
>     We must retain TO_FILE and merge FROM_FILE into it.  */
> 
> Perhaps naively I'm surprised that this merging is done.
> Just because FROM_FILE and TO_FILE have the same name
> doesn't mean it makes sense to merge their file
> structures. The history of the two files could be completely
> different.

I'm not sure I understand what this means, but I don't think it's true.
The entire point of using directory search is that in the makefile you
write filenames (targets) without paths, but that doesn't mean you are
talking about two different targets.  Even using multiple paths you
really meant to be talking about the same target.  In other words if
you have:

  VPATH = /other/dir

  foo: foo.c
  /other/dir/foo: foo.h

those two targets are actually the same thing, just written with
different paths.

If you don't want this ambiguity then you shouldn't use this feature
and instead you should write out all your targets explicitly.

> I would have expected it to be an error for FROM_FILE
> to be renamed to TO_FILE. Indeed the code, calls error() to print
> error messages but goes on to do the merging.

It's only an error if both targets provide a recipe, just like it's
ALWAYS an error if the same target is given a recipe in two different
places in a makefile.



reply via email to

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