【问题标题】:Makefile wildcard with variable insideMakefile通配符,里面有变量
【发布时间】:2015-10-14 08:25:34
【问题描述】:

我正在尝试使用 Makefile 获取每个文件夹中的所有文件:

Test = $(wildcard */)

install: all
  @for dir in $(TEST); do \
    echo $$dir; \
    echo $(wildcard $$dir); \
  done

第一个 echo 输出正确:folder1/ folder2/ folder3/ 但在第二个 echo 中与通配符一起使用时,我得到空输出(每个文件夹包含许多文件)。 有什么建议为什么这不起作用以及如何存档?

【问题讨论】:

    标签: makefile wildcard


    【解决方案1】:

    $(wildcard)ma​​ke 函数,在解析 makefile 时会计算一次。

    dir 是一个shell 变量,它只存在于在评估收据时(使用shell)。

    因为 make 不知道 shell 变量,$(wildcard $$dir) 中的模式由 make 字面解释:$$dir

    如果您想输出dir 变量指向的目录中的文件列表,您应该使用shell 实用程序。例如。 ls $$dir.

    【讨论】:

    • 我试过echo $(shell ls $$dir);,它输出folder1/folder2/folder3/你能举个例子吗?
    • 我需要在INSTALL 中使用ls $$dir 的结果。例如:$(INSTALL) $(ls $$dir) $(<path>)。有可能吗?
    • 试试$(INSTALL) $$dir/* $(path)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多