Note that there are some explanatory texts on larger screens.

plurals
  1. POPattern rule depending on another pattern rule
    primarykey
    data
    text
    <p>consider the following fragment of my makefile:</p> <pre><code>gui_backend: $(BUILDDIR)/gui_backend $(BUILDDIR)/gui_backend: $(BUILDDIR)/gui_backend.o $(BUILDDIR)/config.pb.o $(CXX) $(LDFLAGS) -o $@ $^ $(BUILDDIR)/%.o: $(SRCDIR)/%.cc $(SRCDIR)/%.h | $(BUILDDIR) $(CXX) $(CXXFLAGS) -c -o $@ $&lt; $(SRCDIR)/%.pb.cc: $(PROTODIR)/%.proto $(PROTOC) $(PROTOOPTIONS) --cpp_out=$(SRCDIR) $&lt; </code></pre> <p>now if I call to <code>make gui_backend</code>, I get</p> <pre><code>make: *** No rule to make target `build/config.pb.o', needed by `build/gui_backend'. </code></pre> <p>Why doesn't make pick up on the <code>$(BUILDDIR)/%.o</code> pattern here? If I state things explicitly by adding the rule</p> <pre><code>$(BUILDDIR)/config.pb.o: $(SRCDIR)/config.pb.cc $(SRCDIR)/config.pb.h | $(BUILDDIR) $(CXX) $(CXXFLAGS) -c -o $@ $&lt; </code></pre> <p>it seems to work. However, I would like to keep the makefile as concise as possible.</p> <p>Running make with <code>-d</code> gives me the following (<a href="http://pastebin.com/kRXWvq33" rel="nofollow">complete output here</a>):</p> <pre><code>Considering target file `build/config.pb.o'. File `build/config.pb.o' does not exist. Looking for an implicit rule for `build/config.pb.o'. Trying pattern rule with stem `config.pb'. Trying implicit prerequisite `src/config.pb.cc'. Trying pattern rule with stem `config.pb'. Trying implicit prerequisite `build/config.pb.c'. Trying pattern rule with stem `config.pb'. Trying implicit prerequisite `build/config.pb.cc'. Trying pattern rule with stem `config.pb'. [...] Trying implicit prerequisite `build/SCCS/s.config.pb.o'. Trying pattern rule with stem `config.pb'. Trying implicit prerequisite `src/config.pb.cc'. Looking for a rule with intermediate file `src/config.pb.cc'. Avoiding implicit rule recursion. Trying pattern rule with stem `config'. Trying implicit prerequisite `src/proto/config.proto'. [...] </code></pre> <p>I'm running GNU Make 3.81, btw.</p> <p>Also, I just noticed that if I run <code>make src/config.pb.cc</code> and then <code>make build/config.pb.o</code> manually, it works.</p> <p>Why doesn't this work?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload