问题
I've got a little problem understanding following gmake syntax:
OBJ = foo.o bar.o
$(OBJ): %.o: %.cpp
$(CC) -c -MMD -MP $(INCLUDES) $(CFLAGS) $< -o $@
@sed (...create empty targets in file...)
I'm not sure what $(...): %.o: %.cpp does!?
I think it might translate the "%.o: %.cpp" in correct %.cpp dependencies - does it? Google is not much of a help here - it finds just the usual double colon (target::) which is something different!
Any advice? Thanks!
回答1:
This is a static pattern rule.
$(OBJ)
is a list of targets. The %.o : %.cpp
means "for each target in the list that matches %.o
, it is dependent on %.cpp
" (where the %
is substituted accordingly).
来源:https://stackoverflow.com/questions/8801539/gnu-make-kind-of-double-colon