Why does this MakeFile rule have two colons?

倾然丶 夕夏残阳落幕 提交于 2021-02-05 08:28:10

问题


$(EXEX) : main% : $(OBJS) pp%.o
    gcc $(FLAGS) $^ -o $@

I am just trying to understand the above. As I understand it, everything in EXEX are targets which will be built using the following pattern.

main, OBJS and pp.o are prerequisites for things in EXEX. The second line will compile $^(meaning all the prereqs) using gcc with all the flags in FLAGS as object files in order to build $@ which is the contents of EXEX. There need to be rules to build all those -o's.

My question is why are there two colons? Is this two rules? Does main% mean = main with any file ending? Why do we need the % in pp%.o, what does it mean in this case? It seems to have many many purposes.


回答1:


This is a static pattern rule. See the linked GNU make documentation.



来源:https://stackoverflow.com/questions/59039841/why-does-this-makefile-rule-have-two-colons

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