help-make
[Top][All Lists]
Advanced

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

RE: make: *** No rule to make target 'dir/bar', needed by 'foobar'. Stop


From: Cook, Malcolm
Subject: RE: make: *** No rule to make target 'dir/bar', needed by 'foobar'. Stop.
Date: Thu, 28 Jan 2021 21:47:11 +0000

This does not directly answer your question...

My general advice is to not try to find ways to have directories as targets or 
as dependencies of rules.

One pattern that I find addresses many use cases is to unconditionally shell 
out to create all directories that will be used in the makefile, as:

$(shell mkdir -p dir) 

> -----Original Message-----
> From: Help-make <help-make-bounces+mec=stowers.org@gnu.org> On
> Behalf Of Brian J. Murrell
> Sent: Thursday, January 28, 2021 12:10
> To: help-make@gnu.org
> Subject: make: *** No rule to make target 'dir/bar', needed by 'foobar'.
> Stop.
> 
> I wonder if somebody can explain to me why this Makefile:
> 
> foo:
>       touch foo
>       touch bar
> 
> %/:
>       mkdir -p $@
> 
> dir/%: % | dir/
>       rm -f $@
>       ln $< $@
> 
> foobar: dir/foo dir/bar
> 
> 
> doesn't work as one might think it should:
> 
> $ rm -rf dir foo bar; make foobar
> touch foo
> touch bar
> mkdir -p dir/
> rm -f dir/foo
> ln foo dir/foo
> make: *** No rule to make target 'dir/bar', needed by 'foobar'.  Stop.
> 
> Everything looks good for dir/bar to be created:
> 
> $ ls -l foo bar dir/
> -rw-rw-r--. 1 brian brian    0 Jan 28 12:53 bar
> -rw-rw-r--. 2 brian brian    0 Jan 28 12:53 foo
> 
> dir/:
> total 0
> -rw-rw-r--. 2 brian brian 0 Jan 28 12:53 foo
> 
> Subsequently trying to create dir/bar even works:
> 
> $ make dir/bar
> rm -f dir/bar
> ln bar dir/bar
> 
> Any ideas?  What am I missing?
> 
> Cheers,
> b.


reply via email to

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