当前位置:网站首页>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 .
边栏推荐
- JS conversion of letters and numbers
- Add a custom button to jvxetable
- On the optimization and use of idea
- F1C100S自制开发板调试过程
- Global and Chinese market of ULTRACENTRIFUGES 2022-2028: Research Report on technology, participants, trends, market size and share
- Use of Arthas
- The next change direction of database - cloud native database
- JS 互相引用的问题
- 专升本高数(三)
- An article to get you started VIM
猜你喜欢

Customize the buttons of jvxetable and the usage of $set under notes

专升本高数(四)

HOOK Native API

QT中foreach的使用

The next change direction of database - cloud native database

QT中foreach的使用

On the optimization and use of idea

The broadcast module code runs normally in autojs4.1.1, but an error is reported in pro7.0 (not resolved)

如何实现远程协同办公,收好这份攻略!

mysql 主从数据库同步失败的原因
随机推荐
Global and Chinese markets for advanced wound care 2022-2028: Research Report on technology, participants, trends, market size and share
On the role of database tables
[ten minutes] manim installation 2022
2. 成功解决 BUG:Exception when publishing, ...[Failed to connect and initialize SSH connection...
How to realize remote collaborative office, keep this strategy!
Cross domain, CORS, jsonp
Deep learning: implementation skills of deep neural network
2. successfully solved bug:exception when publishing [Failed to connect and initialize SSH connection...
Utf8 error in Oracle migration of Jincang Kingbase database
什么是外链和内链?
Tp6 framework integrates JWT for token authentication
Tri rapide, index groupé, recherche de la plus grande valeur K dans les données
Use of custom MVC
Principle, advantages and disadvantages of three operating modes of dc/dc converter under light load
Mysql 带上库名称跨库操作可能出现的问题
How does the trading platform for speculation in spot gold ensure capital security?
Principle of device driver
shell统计某个字符串最后一次出现的位置之前的所有字符串
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
Utilisation de foreach en Qt