c++ - Makefile文件修改后,编译程序是否需要重新clean后,编译?
巴扎黑
巴扎黑 2017-04-17 11:30:07
0
1
636

Makefile文件修改后,编译程序是否需要重新clean后,编译?

可否从Makefile的工作原理上剖析一下 ,是否每次都需要对工程代码,修改->make clean->make -j

巴扎黑
巴扎黑

reply all(1)
巴扎黑

Makefile is basically a bunch of dependencies:

target : dependencies
    action

To put it simply, make will check whether the dependencies and target are new or old. If the target is older, then the action will be executed.
For a typical program, the target is mostly an executable program or object file, the dependencies are mostly source code (maybe header files, etc.), the actions are mostly compilation commands, such as gcc -o $@ $^, and the Makefile itself is rarely appears in this dependency relationship.
From this point of view, your changes to the Makefile may have no impact on the target itself. Remake is not necessarily necessary, but it is possible that your changes to the Makefile have caused changes in dependencies. In this case, you may need to start over. Again.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template