当前位置:网站首页>12. Writing rules - static mode
12. Writing rules - static mode
2022-07-29 02:47:00 【Qimu king · Prince】
Writing rules - Static mode
Static mode makes it easier to define multi-objective rules , It can make our rules more flexible and flexible .
Let's take a look at grammar first :
<targets ...>: <target-pattern>: <prereq-patterns ...>
<commands>
....
targets Defines a series of object files , There can be wildcards . It's a collection of goals ;
target-parrtern It's pointed out targets The pattern of , That is, the target set pattern of ;
prereq-parrterns It's a dependency pattern of goals , It's right target-parrtern The formed pattern defines the dependency target again .
Let's take an example .
If our <target-parrtern> Defined as “%.o”, It means our <target> All of the collections are based on “.o” At the end of the ,
And if our <prereq-parrterns> Defined as “%.c”, It means right <target-parrtern> The formed target set is defined twice ,
The calculation method is :
take <target-parrtern> In the pattern “%”( That is to remove [.o] This ending ), And add [.c] This ending , The formation of a new collection .
therefore , our “ Target mode ” or “ Dependency patterns ” There should be “%” This character , If your file name contains “%” So you can use the backslash “\” Transference , To mark the real “%” character .
Take an example :
objects = foo.o bar.o
all: $(objects)
$(objects): %.o: %.c
$(CC) -c $(CFLAGS) $< -o [email protected]
It points out our goal from $object In order to get ,“%.o” Make it clear that you want all of them to “.o” End goal , That is to say “foo.o bar.o”,
That's the variable $object The pattern of sets ;
And dependency patterns “%.c” Then take the mode “%.o” Of “%”, That is to say “foo bar”, And add “.c” The suffix ,
therefore , Our dependency goal is “foo.c bar.c”.
And in the order “$<” and “[email protected]” It's the automation variable ,
“$<” Represents all dependent target sets ( That is to say “foo.c bar.c”),
“[email protected]” Represents the target set ( That is to say “foo.o bar.o”).
therefore , The expanded rules above are equivalent to the rules below :
foo.o : foo.c
$(CC) -c $(CFLAGS) foo.c -o foo.o
bar.o : bar.c
$(CC) -c $(CFLAGS) bar.c -o bar.o
Just imagine , If our “%.o” There are hundreds , We just need to use this very simple one “ Static mode rules ” You can write a bunch of rules , It's so efficient .“ Static mode rules ” The usage of is very flexible , If it works well , That would be a very powerful function .
边栏推荐
猜你喜欢

2022/07/28 learning notes (day18) common APIs

C语言实现三子棋游戏

Mqtt routine

Deliver temperature with science and technology, vivo appears at the digital China Construction Summit

HTTP cache

Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译

IOT components

(作业)C语言:atoi和strncpy、strncat、strncmp的模拟实现

K210——声源定位、声音识别

Source code and display of 18 classic programs in C language vs2019
随机推荐
Brief answer of Engineering Economics
MySQL和Redis的双写一致性
xxxxx
家庭亲戚关系计算器微信小程序源码
What are the TCP retransmission mechanisms?
laravel框架中实现封装公共方法全局调用
6-21漏洞利用-mysql弱口令破解
PHP幸运抽奖系统带后台源码
FTP协议详解
2022/07/28 learning notes (day18) common APIs
Why is redis fast? Message queue, single thread
10.书写规则-文件搜寻
Code implementation - the greatest common factor of polynomials (linear algebra)
ES6 detailed quick start!
Flink生产环境经典问题汇总
MPEG音频编码三十年
Ordinary happiness
NVIDIA-VPI(Vision Programming Interface)
Ffmpeg+sdl+qt is a simple video player
Master-slave replication and its principle