title: Is it possible to add a dependency to another Makefile?
body: <p>I'm not asking if it is possible to <a href="https://stackoverflow.com/q/2206128/477168">call Makefile from another Makefile</a>.</p>
  
  <p>Suppose I have a rule for generating an executable which looks like this:</p>
  
  <pre><code>my-prog: some.o local.o dependencies.o
  </code></pre>
  
  <p>Note that I'm exploiting <a href="https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html" rel="nofollow noreferrer">built-in rules</a> here.</p>
  
  <p>Now suppose I start using a third-party library. I'd like to keep this built-in syntax and just add the external rule to the dependency list:</p>
  
  <pre><code>my-prog: some.o local.o dependencies.o somelib/libsomelib.a
  </code></pre>
  
  <p>But that won't work:</p>
  
  <pre><code>No rule to make target 'somelib/libsomelib.a', needed by 'my-prog'.
  </code></pre>
  
  <p>I know that I can solve this issue by calling explicitly the other Makefile:</p>
  
  <pre><code>my-prog: some.o local.o dependencies.o
      $(MAKE) -C somelib/ libsomelib.a
      $(CC) $(LDFLAGS) -o $@ $^ somelib/libsomelib.a
  </code></pre>
  
  <p>But that's what I'm trying to avoid. Any ideas?</p>