A question on rule priority

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

A question on rule priority

Anton Shepelev
Hello, all

I have the following make file:
 test.o: test.c

  %.o:   %.c; tcc -c $< -o $@
  %.exe: %.o; tcc -o $@ $^
  %.exe: %.c; tcc $^ -o $@

and invoke it as:
  make test.exe
in a directory that has test.c, but has no test.o .
It runs these commands:

  tcc -c test.c -o test.o
  tcc -o test.exe test.o

But since paragraph 10.5.4 How Patterns Match of the manual
says that "a rule whose prerequisites actually exist or are
mentioned always takes priority over a rule with prerequisites
that must be made by chaining other implicit rules," I expected
make to follow the shortest path using the third pattern rule,
i.e.:  tcc test.c -o test.exe .

Why did make decide on build test.o from test.c and then test.exe
from test.o?

()  ascii ribbon campaign -- against html e-mail
/\  http://preview.tinyurl.com/qcy6mjc [archived]

Help-make mailing list
[hidden email]