问题
$(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