当前位置:网站首页>1151_ Makefile learning_ Static matching pattern rules in makefile
1151_ Makefile learning_ Static matching pattern rules in makefile
2022-06-30 03:17:00 【grey_ csdn】
All learning summary : https://github.com/GreyZhang/g_makefile
About this part, I wanted to look at the examples first , After consulting some materials, I think it is more appropriate to start from the document itself .

First take a look at this section of the document , Several useful knowledge summaries can be sorted out from this document .1, First, pay attention to the basic syntax format of this usage and the specific functions of each part , This paper makes a summary of the function of this expression form : Each target that matches the target pattern is extracted as part of the name , This part is called stem, take stem Replace with each dependency match to derive the dependency file .2, Each matching pattern usually contains only one %, If it is used to deal with target,% Can be used to match any part of a name , But not % The winning part should match 100% .3, Except for 1 The replacement rules summarized in , There is another possibility : There is no in the dependency rule %, So all of target All the dependent files are the same . This expression is still legal .4, If you want to match in the matching pattern % character , You can add one \ Realization . If not \% Is parsed into % The symbol itself can be used as a match \\%. however , This is not to say \\ yes \ Escape usage of , If you want to use two \ Direct input \\ that will do .
Let's take a few examples .
CC := gcc
objects = foo.o bar.o all.o
all: $(objects)
# These files compile via implicit rules
foo.o: foo.c
bar.o: bar.c
all.o: all.c
all.c:
echo "int main() { return 0; }" > all.c
%.c:
touch [email protected]
clean:
rm -f *.c *.o all
First , This is an expression pattern that I have probably seen before . The only difference is the use of wildcards , Use %.c To handle the default C Code target. This is the default , No document found for the time being , It has something to do with the conclusion of my test . In the next comparison example, we can make a better comparison .
CC := gcc
objects = foo.o bar.o all.o
all: $(objects)
# These files compile via implicit rules
# Syntax - targets ...: target-pattern: prereq-patterns ...
# In the case of the first target, foo.o, the target-pattern matches foo.o and sets the "stem" to be "foo".
# It then replaces the '%' in prereq-patterns with that stem
$(objects): %.o: %.c
all.c:
echo "int main() { return 0; }" > all.c
%.c:
touch [email protected]
clean:
rm -f *.c *.o all
This is the one above Makefile Another way to express , Static matching pattern rules are used . I've written a very simple and crude Makefile In the generation tool of , This is a good improvement . If we can use this rule to deal with ,Makefile The simplicity of will increase a lot . However , Now that it has been automatically generated , Whether it is concise or not is not a special concern . The running effect of this example is the same as before , The effect is as follows :

Through this example , In fact, I can see a conclusion from my previous test . That's it , This method of fuzzy matching follows the previous one target There are different ways in the duplicate name test . Logically speaking ,%.c Can match all C file ,all.c It will also be added for the second processing . This should lead to a target Duplicate name of , If duplicate names are detected , A warning should appear as in the previous test . There are no warnings , Add a echo By comparing the output prompts, you can also find that there are all.c This part will ignore the right all.c To deal with . It looks like all.c The processing of has a higher priority and will cancel the subsequent expression of fuzzy matching .
边栏推荐
- Gulang bilibilibili Live Screen Jackie
- Mysqldump principle
- [untitled]
- Some technology sharing
- Jvxetable增加自定义按钮
- Add a custom button to jvxetable
- Hands on in-depth learning notes (XV) 4.1 Multilayer perceptron
- 2022 tool fitter (Advanced) and tool fitter (Advanced) certificate examination
- Differences between comparable and comparator
- Code for generating test and training sets
猜你喜欢

Compile a DLL without import table

How to set password complexity and timeout exit function in Oracle

Auto.js学习笔记16:按项目保存到手机上,不用每次都保存单个js文件,方便调试和打包

浅谈IDEA的优化和使用

golang bilibili直播彈幕姬

Golang BiliBili live broadcast bullet screen

自定义MVC的使用

专升本语文资源整理

Redis高并发分布式锁(学习总结)

O & M (21) make winpe startup USB flash disk
随机推荐
NLP text summary: data set introduction and preprocessing [New York Times annotated corpus]
Tri rapide, index groupé, recherche de la plus grande valeur K dans les données
On the role of database tables
2022 new test questions for safety management personnel of metal and nonmetal mines (small open pit quarries) and certificate examination for safety management personnel of metal and nonmetal mines (s
行政路线编码 字母+数字的排序方式
OP-diode-限制摆幅
OP diode limit swing
Which is a good foreign exchange trading platform? Is it safe to have regulated funds?
Azure developer news flash list of events of developers in June
【直播笔记0629】 并发编程二:锁
prompt learning 一个空格引发的血案
Sorting method of administrative route code letter + number
Note the use of export/import and class inheritance in ES6
golang bilibili直播弹幕姬
O & M (20) make and start USB flash disk and install win10
Global and Chinese market of centrifugal pumps 2022-2028: Research Report on technology, participants, trends, market size and share
Use compose to realize the effect of selecting movie seats by panning tickets
自定义MVC的使用
专升本高数(四)
Gulang bilibilibili Live Screen Jackie