Will GNU Make automatically add additional preconditions?

The following snippet of an example is presented in "Managing Projects with GNU Make (3rd Edition)" on page 21.

count_words: counter.o lexer.o -lfl

      

The author says he make

will automatically add count_words.o

to the list of preconditions on an implicit rule. Quoted:

..., make identifies four prerequisites: count_words.o (this condition is not in the makefile, but is enforced by an implicit rule), counter.o, lexer.o, and -lfl.

However, my test doesn't match this. Here's my test:

prog: abc.o
    @echo $^
abc.o:
    @echo abc.o built.
prog.o:
    @echo prog.o bulit.

      

Exit after startup make

:

abc.o is built.

abc.o

make

not looking prog.o

for a purpose prog

. What is the problem? Is there something wrong with my test?

By the way, my test is on Cygwin

p GNU Make 4.1

.

+3


source to share


1 answer


You have given a recipe for your purpose prog

. The author is not for the purpose count_words

. This is the difference.

The author expected the built-in rule to %: %.o

take effect. You have redefined this with your rule.



Remove @echo $^

from recipe prog

and try again.

+3


source







All Articles