Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a Makefile:

foo:
        touch foo
        touch bar

%/:
        mkdir -p $@

dir/%: % | dir/
        rm -f $@
        ln $< $@

foobar: dir/foo dir/bar

But it 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

What am I missing?

question from:https://stackoverflow.com/questions/65944715/target-fails-to-build-in-some-cases

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
452 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...