Reputation: 995
I am going through a SDK's Makefile and the <project>.elf
rule depends on the C_OBJS
,
and the C_OBJS
is defined as the following.
C_OBJS = $(C_FILES:%.c=$(BUILD_DIR)/%.o)
C_FILES
is a collection of all the C files.
What I am unable to figure out is that how does the Makefile know how to convert these C files to respective OBJS before linking them to form elf(as the elf rule only links them)
Upvotes: 0
Views: 69
Reputation: 6387
The $(C_FILES:%.c=$(BUILD_DIR)/%.o)
is shorthand for a patsubst
function. See here.
As far as knowing how to build the .o
files, unless you explicitly disable them, make will use a set of predefined implicit rules, one of which builds .o
files from .c
files.
Upvotes: 1