linux - 尝试从 gnu make 中的命令获取值时出错

标签 linux shell makefile gnu-make gnu

我有以下在 make gnu 文件上运行的代码

apps := $(shell tbd run apps)
apps := $(subst ],,$(subst [,,$(app)))

现在我想打印应用程序值,我尝试了

@echo $(app)

我得到了错误

Makefile:12: *** 命令在第一个目标之前开始。停止。

更新:

目前我的代码就像

apps := $(shell tbd run apps)
apps := $(subst ],,$(subst [,,$(apps)))


build:
    @for app in $(apps) ; do \
     bsd start $$app ; \
    done

如果我这样尝试,就会出现错误

start: 
   apps := $(shell tbd run apps)
   apps := $(subst ],,$(subst [,,$(apps)))

build:
    @for app in $(apps) ; do \
        bsd start $$app ; \
    done

最佳答案

您无法将 Makefile 函数调用有意义地放在 shell 调用中。我猜你真的只是在寻找

build:
    tbd run apps \
    | sed 's/\[//;s/\]//' \
    | xargs -n 1 bsd start

关于linux - 尝试从 gnu make 中的命令获取值时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52815860/

相关文章:

linux - 带有多个字符串和通配符的 Grep

json - 如何通过shell脚本编辑json文件来改变坐标点,其中原始点除以2

twitter-bootstrap - 从 github 克隆后编译 Twitter Bootstrap - 输出在哪里?

linux - 已安装 libwnck-3-dev 但仍然出现有关缺少 libwnck.h 的错误

linux - Nginx:为多个 Laravel 应用程序提供相同的 url,但在 Linux 中有两个不同的子位置

linux - 内核模块(.ko 文件)移植到 DLL 导出符号

shell - 将VxWorks Shell输出重定向到套接字

ruby - 为什么 shell 输出经常在其输出中使用 `mixed_characters'?

c++ - 为什么cmake不在makefile中加入库链接命令?

c - 无法编译包含问题的 C 代码