当前位置:网站首页>1147_ Makefile learning_ Target files and dependent files in makefile
1147_ Makefile learning_ Target files and dependent files in makefile
2022-07-03 17:23:00 【grey_ csdn】
All learning summary : https://github.com/GreyZhang/g_makefile
Let's start with a simple example :
hello:
echo "hello world"
If you create a file named Makefile The file of , Enter the above content to save . after , Start the command line and enter the directory where the file is located make( perhaps gmake etc. ) The following effect appears :
It can be seen that the original command statement is printed on the interactive interface , At the same time, the result of statement execution is printed . I understand this somewhat , It should be possible to add a @ Symbol to deal with the echo of the command itself .
This is a makefile Part of the basic grammar of . According to the explanation here , The target file can be multiple . Between target files , Use spaces to distinguish . such , In fact, there is a problem worth confirming : If the name of the file itself has spaces , What should be done here ? Again , Similar problems also exist in dependent files . Next , Another thing to note is that the command starts from TAB The beginning, not the space .
Let's take another example :
Result of operation :
This example has a note when running , That is in Windows You need to use a bash Simulation environment of . because Windows There is also a command system in echo, But with the bash Medium echo Their behavior is different . If you don't pay attention to this , The above example cannot be executed successfully .
Here is an interesting mode of thinking , That is, the execution sequence written in the comment . In this way ,Makefile The execution and derivation process of is a little recursive in programming .
Here are two other examples , Easier to understand . First every time make Will execute the output , Because the target file never exists . The second one will print for the first time because the target file does not exist , create a file . From the second execution , It will not output but prompt that the file has been updated .
Considering dependence and time relationship , The above implementation process is very understandable . But here we can also see another problem :Makefile The implementation of does not mean that the target file will be updated to the latest .
some_file: other_file
echo "This will run second, because it depends on other_file"
touch some_file
other_file:
echo "This will run first"
touch other_file
The example above , It involves the dependence on other files . The effect of operation :
This example can actually show the relationship between File Dependencies , If the file is not ready , So update . If the file is ready , Then don't update . If the timestamp of the dependent file changes , The target file will also be updated .
A better test method described above is like this , Directly by formulating target To generate other_file, After performing gmake Handle default target, That's the first one target. such , Not only can we see makefile For the management concept of file timestamp , At the same time, you can also see the specified target Processing function .
such , Another concept about object file is introduced .make clean Is a common operation , In fact, it is only used to deal with the specified target nothing more .clean Not at all makefile A keyword or reserved word in .
边栏推荐
- Host based intrusion system IDS
- [combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
- 29: Chapter 3: develop Passport Service: 12: develop [obtain user account information, interface]; (use VO class to package the found data to meet the requirements of the interface for the returned da
- kubernetes资源对象介绍及常用命令(三)
- [RT thread] NXP rt10xx device driver framework -- pin construction and use
- Simple configuration of postfix server
- vs code 插件 koroFileHeader
- 2021 ICPC regional competition (Shanghai) g.edge groups (tree DP)
- 新库上线 | CnOpenData中国保险机构网点全集数据
- 线程池:业务代码最常用也最容易犯错的组件
猜你喜欢
Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
鸿蒙第四次培训
QT学习日记9——对话框
Great changes! National housing prices fell below the 10000 yuan mark
Notes on problems -- watching videos on edge will make the screen green
人生还在迷茫?也许这些订阅号里有你需要的答案!
Golang单元测试、Mock测试以及基准测试
線程池:業務代碼最常用也最容易犯錯的組件
How to read the source code [debug and observe the source code]
The largest matrix (H) in a brush 143 monotone stack 84 histogram
随机推荐
Hongmeng third training
Squid service startup script
線程池:業務代碼最常用也最容易犯錯的組件
VM11289 WAService. js:2 Do not have __ e handler in component:
Redis: operation commands for list type data
Redis:关于列表List类型数据的操作命令
Test your trained model
鸿蒙第四次培训
An example of HP array card troubleshooting
[combinatorics] recursive equation (special solution form | special solution solving method | special solution example)
How SVN views modified file records
Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
Free data | new library online | cnopendata complete data of China's insurance intermediary outlets
Electronic technology 20th autumn "Introduction to machine manufacturing" online assignment 3 [standard answer]
【RT-Thread】nxp rt10xx 设备驱动框架之--rtc搭建和使用
Play with fancy special effects. This AE super kit is for you
[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework
STM32H7 HAL库SPI DMA发送一直处于busy的解决办法
互聯網醫院HIS管理平臺源碼,在線問診,預約掛號 智慧醫院小程序源碼
[combinatorics] recursive equation (the problem of solving recursive equation with multiple roots | the problem is raised)