In GNU.org’s Make manual, there’s a description of how to use one Makefile to call targets of another Makefile. You have to use $(MAKE) in order for it to work properly. I’ve found one little snag that’s not mentioned. If my target name is the same as the directory name where the other Makefile is, it will never work. It always says it’s up to date! If I change the target name, it works fine.
app1:
$(MAKE) -C app1/src
app2:
cd app1/src && $(MAKE)
Neither of these methods work! It always reports:
make: `app1′ is up to date.
Here’s the description from the gnu page:
5.7.1 How the MAKE Variable Works
Recursive make commands should always use the variable MAKE, not the explicit command name `make’, as shown here:
subsystem:
cd subdir && $(MAKE)The value of this variable is the file name with which make was invoked. If this file name was /bin/make, then the command executed is `cd subdir && /bin/make’. If you use a special version of make to run the top-level makefile, the same special version will be executed for recursive invocations. As a special feature, using the variable MAKE in the commands of a rule alters the effects of the `-t’ (`–touch’), `-n’ (`–just-print’), or `-q’ (`–question’) option. Using the MAKE variable has the same effect as using a `+’ character at the beginning of the command line. See Instead of Executing the Commands. This special feature is only enabled if the MAKE variable appears directly in the command script: it does not apply if the MAKE variable is referenced through expansion of another variable. In the latter case you must use the `+’ token to get these special effects.