Makefile:
TARGET = test1 TARGET += test3 all: $(TARGET) @echo $^ @echo $(TARGET) test1: test3: TARGET += test2
执行结果:
$ make test1 test3 test1 test3 test2
Makefile 中,等号赋值的变量,会在整个 Makefile 文件展开后,再决定变量的值,如 @echo $(TARGET) 打印 test1 test3 test2 。
但是,不解的是,为什么依赖中的 TARGET 仅仅为 test1 test3 ?
![]() | 1 SJ2050cn 2020-12-16 18:04:51 +08:00 ![]() |
2 liyongjun0803 OP @SJ2050cn 学到了,感谢! |