当前位置:网站首页>Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems

Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems

2022-08-10 22:00:00 Senior black cat

This article is compiled/written based on personal work/study experience and online data. Paid content is prohibited from being reproduced.
The column where this article is located "Black cat takes you to learn Makefile"

In the process of work/study, even if the makefile is deeply studied, there are still many miscellaneous problems. This article summarizes these problems for easy reference.

1 Pseudo-target.PHONY : Reason for clean

There are two reasons for using pseudo targets:
1. Avoid the command-only target defined in our Makefile (the purpose of this target is to execute a series of commands without creating this target) andThe actual file in the working directory has a name conflict.

2. Improve the efficiency of executing make, especially for a large-scale project, you may also care about the efficiency of compilation.

If we need to write such a rule: the defined command is not to create an object file, but to use make to specify a specific target to execute some specific commands.like below:
clean:rm *.o temp

The "rm" in the rule is not the command to create the file "clean", it just deletes all .o files and temp files in the current directory.When the file "clean" does not exist in the working directory, after we enter "make clean", "rm *.o temp" will always be executed.This is our original intention.

But when

原网站

版权声明
本文为[Senior black cat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208102109577244.html