GNU make kind-of-double colon

只谈情不闲聊 提交于 2019-12-07 09:59:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!