linux - gnu makefile 通过要忽略的文件夹列表过滤源文件列表

标签 linux makefile gnu

假设我有以下变量:

SOURCES = folder1/a.c folder1/b.c folder2/c.c folder3/d.c folder3/e.c
FILTERS = folder2 folder3

现在我想设置一个只包含folder1/a.c folder1/b.c 的变量。我试过 $(filter-out folder2%,$(SOURCES)) 并且确实删除了不需要的 folder2 项目。那么也许我可以通过这种方式以某种方式循环筛选器?

或者有更好的方法吗?

最佳答案

你可以只使用:

OUTPUT := $(filter-out $(addsuffix /%,$(FILTERS)),$(SOURCES))

filter-out 可以采用多个过滤器并将它们全部应用。我建议您使用 /% 而不仅仅是 % 这样您就不会捕获恰好以目录名称开头的文件名。

关于linux - gnu makefile 通过要忽略的文件夹列表过滤源文件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54187360/

相关文章:

linux - Linux 看门狗

c++ - Mac 上 make 失败

c - 在哪里可以获取 gnu.org Simple Makefile 的源文件和头文件?

c++ - ubuntu 18.04 上的 gcc/g++ 7.3.0 链接错误

php - 在远程机器 php 上运行 bash 脚本

python - 使用 Python 查找损坏的符号链接(symbolic link)

linux - sed 命令在 gitlab runner 上无法正确执行

c++ - ftp 服务器的 makefile - 修改头文件时编译

c++ - Cmake 找不到使用 "link_directories"的库

Linux 排序 : how to sort numerically but leave empty cells to the end