bug-make
[Top][All Lists]
Advanced

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

Re: make -t and directories


From: Alejandro Colomar
Subject: Re: make -t and directories
Date: Sat, 11 Mar 2023 14:50:44 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

Hi Dmitry,

On 3/11/23 14:36, Dmitry Goncharov wrote:
> On Fri, Mar 10, 2023 at 7:55 PM Alejandro Colomar
> <alx.manpages@gmail.com> wrote:
>> How about using `mkdir -p` instead of touch(1) for nonexistent files?
> 
> mkdir -p would create a directory where a file is supposed to be.
> Let's say you have hello.c, but no hello.o.If you run make -t it'll
> create an empty hello.o. Then you can update hello.c and run make
> again and it'll build a new hello.o from the new hello.c. If there
> was a directory called 'hello.o' then a file 'hello.o' cannot be
> created.

Hmm, that's right.  I didn't consider that.  How about running mkdir
for targets whose last byte is a '/'? [1]

Then, with a Makefile like:

$ cat Makefile 
.PHONY: all
all: dir/file

.PHONY: clean
clean:
        rm -rf dir

dir/:
        mkdir $@

dir/file: | dir/
        echo foo >$@

$ make -t
touch dir/
make: touch: open: dir/: Is a directory

I would get the expected behavior.  Something ending in '/' can
only be a directory, so the correct behavior should be to mkdir(1)
it if empty.  touch(1) fails to do anything with a non-existing dir:

$ touch foo/
touch: setting times of 'foo/': No such file or directory

> 
> In your particular case, why don't you build your directories before
> you run make -t?

Because the actual Makefile is not as simple as this reproducer.  :-)

> $ make dir
> $ make -t

I removed the 'builddirs' target long ago because it wasn't easy to
maintain, and I didn't see any benefits.  It was something useful
for recursive make, but now I have a single Makefile, as recommended
by Paul, I'm much happier.  :)

> 
> regards, Dmitry

Kind regards,

Alex


[1]:

Which BTW reminds me we had some discussion about slashes, in which I
had something pending to answer but didn't have time for it, and then
forgot.  Maybe it would be interesting to resurrect it.

 

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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