当前位置:网站首页>Remove then add string from variable of Makefile
Remove then add string from variable of Makefile
2022-06-22 05:40:00 【alex_ mianmian】
As we know, use sed command can change string.

When we want to use it in Makefile, how to use it?
Let's write a Makefile as following:
LDFLAGS = -Txxhello.lds -Lhello
IOT_LDFLAGS = $(LDFLAGS) | sed 's/-T.*lds/-Talex.lds/g'
all:
@echo $(LDFLAGS)
@echo $(IOT_LDFLAGS)now let's execute make:

Looks good, we got what we wanted.
However, when you plan to use $(IOT_LDFLAGS), you will find something different.
let's use echo instead of @echo in Makefile,here is the output:

Here we can see:
read line marks the $(LDFLAGS)
blue line marks the $(IOT_LDFLAGS)
@echo just show the result after echo executed. so $(IOT_LDFLAGS) is not '-Talex.lds -Lhello'.
The correct way is:
LDFLAGS = -Txxhello.lds -Lhello
#IOT_LDFLAGS = $(LDFLAGS) | sed 's/-T.*lds/-Talex.lds/g'
IOT_LDFLAGS = $(shell echo $(LDFLAGS) | sed 's/-T.*lds/-Talex.lds/g')
all:
echo $(LDFLAGS)
echo $(IOT_LDFLAGS)use $(shell xxxxx) to execute sed and return the result to $(IOT_LDFLAGS).
here is make result:

Now the $(IOT_LDFLAGS) is '-Talex.lds -Lhello'
边栏推荐
- 基于WebUploader实现大文件分片上传
- Talk about MySQL's locking rule "hard hitting MySQL series 15"
- Use of jedispool
- Link a static library‘s all sections
- 机器学习笔记 八:Octave实现神经网络的手写数字识别
- QEMU ARM interrupt system architecture 2
- 关于图片懒加载的实现(总结梳理)
- Get jedis from jedissentinelpool
- Tidb upgrade version
- 独立站 “ 去中心化 ” 模式崛起,席卷跨境企业转型浪潮
猜你喜欢

通达OA漏洞分析合集
![P1077 [noip2012 popularization group] flower display](/img/0d/f74a2036aa261ed327d9d74291aacc.png)
P1077 [noip2012 popularization group] flower display
![[cloud native] 2.2 kubeadm create cluster](/img/b2/a57b7e44f74357d5aedbb9ddcd95ff.png)
[cloud native] 2.2 kubeadm create cluster

C#中Cookie设置与读取
Wanzi detailed data warehouse, data lake, data middle platform and lake warehouse are integrated

Graduation season | a new start, no goodbye

OPTEE notes
![P1061 [NOIP2006 普及组] Jam 的计数法](/img/53/7ca41b2ed4084f49ebcc2dd47e5919.png)
P1061 [NOIP2006 普及组] Jam 的计数法

Cookie setting and reading in C #

想投放Facebook广告却不知从何入手?此文带你深入了解
随机推荐
想投放Facebook广告却不知从何入手?此文带你深入了解
Opencv function usage details 1~10, including code examples
旅行家的预算(洛谷)
Data storage (Advanced)
数据的存储(进阶)
亚马逊和独立站,不是简单的二选一
[graduation season · advanced technology Er] a graduate student's chatter
Tensorflow 2. Chapter 14: callbacks and custom callbacks in keras
机器学习笔记 七:强大的神经网络表述
Learning method 4 for promotion of big factories: play learning method
毕业季 | 新的开始,不说再见
Link a static library‘s all sections
[issue 26] 123hr experience of Tencent teg+ operation development
Why is "CPS alliance marketing" the most cost-effective promotion method?
强制删除 Terminating 状态的 namespace
Optimization direction of code walk through (convenient interface requests, long dynamic class judgment conditions, removal of useless consoles, separation of public methods)
Current market situation analysis and investment analysis prospect report of global and Chinese ceramic capacitor industry 2022-2027
A piece of code to solve the problem of automatic disconnection of Google colab
tmux -- ssh terminal can be closed without impact the server process
Parameter serialization