当前位置:网站首页>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 .
边栏推荐
- Quickly master nodejs installation and getting started
- XSS range (II) xss.haozi
- Summary of knowledge points of Engineering Economics
- Double write consistency of MySQL and redis
- 白马过隙的时光
- Driverless obstacle avoidance technology
- IOT components
- Some records during the development of ros2/ros1
- 0728~ sorting out interview questions
- HTTP breakpoint resume and cache problems
猜你喜欢

6 years of testing experience, teaching you how to test ~ how to control the project

Read the recent trends of okaleido tiger and tap the value and potential behind it

idea替换所有文件中的内容

Understand the evolution of redis architecture in one article

Source code and display of 18 classic programs in C language vs2019

Understanding service governance in distributed development

用于校园流浪猫信息记录和分享的小程序源码/微信云开发中大猫谱小程序源码

Multimodal unsupervised image to image translation

【OpenCV】使用OpenCV调用手机摄像头

OSPF实验
随机推荐
云开发打工人必备上班摸鱼划水微信小程序源码
golang 协程的实现原理
以科技传递温度,vivo亮相数字中国建设峰会
九宫格心形拼图小程序源码/带流量主微信小程序源码
第九天笔记
Some records during the development of ros2/ros1
Only when you are far away will you miss
Stm32c8t6 encoder motor speed measurement and Arduino photoelectric module speed measurement
XSS靶场(二)xss.haozi
QT屏幕自适应自动布局,拖动窗口自动变大变小(一)
Source code and display of 18 classic programs in C language vs2019
ECCV 2022 | AirDet:无需微调的小样本目标检测方法
全新UI四方聚合支付系统源码/新增USDT提现/最新更新安全升级修复XSS漏洞补单漏洞
Flink内核源码(七)Flink SQL提交流程
h. 264 code stream explanation
idea配置web容器与war打包
STM32C8T6编码器电机测速与arduino光电模块测速
Others' happiness
time_ Wait and close_ Cause of wait
(作业)C语言:atoi和strncpy、strncat、strncmp的模拟实现