$(info makefile 111 ---------------)
ccc:
@echo "compile ccc start !!!!!!!"
@echo "ccc"
@echo "compile ccc end !!!!!!!"
%:
@echo "compile aaa start !!!!!!!"
@make ccc
@echo "compile aaa end !!!!!!!"
$(info makefile 222 ---------------)
执行make aaa, 结果:
aistudio@jupyter-223358-6314570:~/test_make$ make aaa
makefile 111 ---------------
makefile 222 ---------------
compile aaa start !!!!!!!
make[1]: Entering directory '/home/aistudio/test_make'
makefile 111 ---------------
makefile 222 ---------------
compile ccc start !!!!!!!
ccc
compile ccc end !!!!!!!
make[1]: Leaving directory '/home/aistudio/test_make'
compile aaa end !!!!!!!
执行顺序:
1. 解析第一遍Makefile;
2. 找到目标: %;
3. 依次执行目标%下的语句;
4. 执行到make时,递归,再解析一遍Makefile,找到目标ccc,执行完ccc下的语句后返回;
5. %下的make执行完后,返回。