What does the syntax of a makefile rule of the form "A: B: C" mean?
I am going through the CyanogenMod code to try and get the device with the latest version. There is a rule in the make / core / binary.mk Makefile that looks like this:
$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) \ | $(my_compiler_dependencies) $(transform-$(PRIVATE_HOST)c-to-o)
Although I'm pretty new to Makefiles, I've never seen rules of the form A: B: C. I thought this originally meant that C is a list of preconditions (both normal and ordinal) for targets B, and targets B are prerequisites for A, but I figured this couldn't be the case, since (I don't think) Make has some implicit rules for generating .o files from other .o files.
What does this syntax mean?
source to share
As stated in my comment on this question, I found the answer shortly after asking the question. This syntax is documented in the GNUMake documentation of the generally static template .
Basically, the syntax is
target: target-pattern: prerequisites-patterns
For each target, the target (section B) is applied to the target. The target pattern must contain the 1% character to match the substring in the target name. Other characters in the target pattern are used to match the target. The matching substring for "%" (known as "stem") will be used to replace the occurrence of unexperienced "%" characters in prerequisite patterns. To build an example from the GNUMake documentation ...
s.foo.o: s.%.o: %.c s.%.c
In this case, the template s.% Will be applied to the target s.foo.o. c. This means the stem will be set to "foo". Subsequently, the pivot is replaced with a list of prerequisites for generating prerequisites: foo.c and s.foo.c. The above syntax becomes equivalent:
s.foo.o: foo.c s.foo.c
source to share