Makefile given the target change without any rules

I was answering another question -   Dependency ordering error for multiuser work on SO and I posted the following makefile. The OP replied that if -j

it was not specified on the command line, it would not build the target dir1/out/file.bar

. In Perplexed, I verified that it works with -j2

but not with -j1

. I looked it over and I don't see what I missed. I thought I'd post it here in case anyone knows, as I am very curious ...

$(shell mkdir dir1 >& /dev/null; touch dir1/file.foo; \
        mkdir dir2 >& /dev/null; touch dir2/file.foo)


OUTDIRS = dir1/out dir2/out
OUTPUTS = dir1/out/file.bar dir2/out/file.bar

.DEFAULT_GOAL := all

$(OUTPUTS) : | $(OUTDIRS)

$(OUTDIRS) :
        @echo "making $@"
        sleep 1
        mkdir -p $@
        @echo "done making $@"


%.bar : ../%.foo
        @echo "copying $< to $@"
        @cp $< $@

all : outputs
        @echo "done $@"

outputs : $(OUTPUTS)
        @echo "created all output files"

clean :
        @rm -rf dir1 dir2

      

I am running make 3.81 and the OP was using 3.82. I tried working with make -d -j1 -r

, and got the following snippet:

     Finished prerequisites of target file `dir1/out/file.bar'.
    Must remake target `dir1/out/file.bar'.
    Successfully remade target file `dir1/out/file.bar'.
    Considering target file `dir2/out/file.bar'.
     File `dir2/out/file.bar' does not exist.
      Considering target file `dir2/out/../file.foo'.
       Finished prerequisites of target file `dir2/out/../file.foo'.
      No need to remake target `dir2/out/../file.foo'.
      Pruning file `dir1/out'.
      Pruning file `dir2/out'.
     Finished prerequisites of target file `dir2/out/file.bar'.
    Must remake target `dir2/out/file.bar'.
copying dir2/out/../file.foo to dir2/out/file.bar
    Successfully remade target file `dir2/out/file.bar'.

      

It seems like it rewrote dir1 / out / file.bar, but it didn't run any targets / recipes to do it ... I'm wondering what I was missing ...

+3
makefile


source to share


No one has answered this question yet

See similar questions:

1
Dependency ordering error for multiuser work

or similar:

285
gcc makefile error: "There is no rule to create a target ..."
144
How do I run a makefile on Windows?
88
GNU Makefile Rule Generating Multiple Targets from a Single Source File
13
GNU make bug: target variables not expanded in implicit rules?
3
make an implicit rule with v. phony
3
Using "Empty Target" in a Makefile
2
GNU make always thinks that a non-file target has changed (possible error?)
1
block -jN on second run when using order precondition in sub-sub-target
0
What's missing: make: *** No rule for creating target
0
copy only changed files between directories using Makefile



All Articles
Loading...
X
Show
Funny
Dev
Pics