相关疑难解决方法(0)

目标下的makefile变量赋值

我在Makefile中的目标中运行以下命令.

target1:
        <run some command which creates ids.log>
        $(eval id1 := $(shell cat ids.log | head -1))
        @echo id is $(id1)
        <some other command which uses the value $(id1)>
Run Code Online (Sandbox Code Playgroud)

我的任务是获取"ids.log"中的第一行并将其保存在变量id1中,这样我就可以使用我将在此目标中执行的命令中的值.

运行此命令时出错"cat:ids.log:没有这样的文件或目录".看起来$(eval ..)命令在make的开头执行而不是作为目标make的一部分执行.由于在完成目标make之前不会创建ids.log,因此我们会收到此错误.

任何人都可以帮助我如何获取我执行的shell命令的值并将其放入变量以供按需使用?

variables makefile eval

4
推荐指数
1
解决办法
1353
查看次数

标签 统计

eval ×1

makefile ×1

variables ×1