Makefile - How to call other makefiles with dependencies

Hey, I have a simple β€œmaster” Makefile that just calls other makefiles. I am trying to do the following to assemble components in the correct order:

LIB_A = folder_a LIB_B = folder_b LIB_C = folder_c MY_TARGETS = $(LIB_A) $(LIB_B) $(LIB_C) .PHONY: $(LIB_A) $(LIB_A): @$(MAKE) -C $@ ; .PHONY: $(LIB_B) $(LIB_B): @$(MAKE) -C $@ ; .PHONY: $(LIB_C) $(LIB_C): $(LIB_A) $(LIB_B) @$(MAKE) -C $@ ; .PHONY: all all: $(MY_TARGETS) 

However, when I do, only LIB_A is created.

(I don't even get the last folder_b error message or anything else).

Any clues?

+7
source share
2 answers

You need to make all default value. You can do this in one of the following ways:

  • move it as the first target in the file
  • Add .DEFAULT_GOAL := all

Alternatively, you can run make all instead of just make .

+8
source

Neil Butterworth solved the problem, but you can also make this make file a bit more concise:

 LIB_A = folder_a LIB_B = folder_b LIB_C = folder_c MY_TARGETS = $(LIB_A) $(LIB_B) $(LIB_C) .PHONY: all $(MY_TARGETS) all: $(MY_TARGETS) $(MY_TARGETS): @$(MAKE) -C $@ ; $(LIB_C): $(LIB_A) $(LIB_B) 
+8
source

All Articles