Suppose you defined these three variables (and if you did not, the rule will not work very well):
SRC = source_dir OBJ = object_dir SRCS = source_dir/foo.cpp source_dir/bar.cpp
Now consider the purpose
OBJS = $(SRCS:$(SRC)/%.cpp=$(OBJ)/%.o)
This is a reference to substitution ; he says, "for something in $(SRCS) that has the form $(SRC)/%.cpp , change it to $(OBJ)/%.o ". So, OBJS will be evaluated to object_dir/foo.o object_dir/bar.o
Now the rule:
$(OBJS):$(OBJ)/%.o: $(SRC)/%.cpp | print-opts $(cc-command)
Thuis is a static rule of patterns . It defines a list of goals ( $(OBJS) ), a target pattern ( $(OBJ)/%.o ) and a background pattern ( $(SRC)/%.cpp ). Map the target to the target template and use this to create the name of the desired condition. So if Make Use this rule to build object_dir/foo.o , the stem will be foo , and source_dir/foo.cpp will be a source_dir/foo.cpp .
(You did not ask about | print-opts , so I assume it has already been cleared.)
source share