英文:
How to make a comma-separated list with quotes in (GNU) Makefile
问题
Here's the translated Makefile section you provided:
我有一个简单的Makefile:
MARKDOWNS = $(shell find . -type f -name "*.md" ! -name "index.md" ! -name "README.md")
all: list
list:
echo $(MARKDOWNS)
我的目录中有这些`*.md`文件:
$ ls *.md
foo.md bla.md ra.md
因此,Makefile 给了我:
./foo.md ./bla.md ./ra.md
但期望的输出是:
"./foo.md", "./bla.md", "./ra.md"
如何将 `$(MARKDOWNS)` 转换为实现这一目标?我使用 GNU Make 4.4.1。
Please note that the translated content maintains the structure of the original text. If you need further assistance with the Makefile or have any questions, feel free to ask.
英文:
I have a simply Makefile:
MARKDOWNS = $(shell find . -type f -name "*.md" ! -name "index.md" ! -name "README.md")
all: list
list:
echo $(MARKDOWNS)
My directory has this *.md
files:
$ ls *.md
foo.md bla.md ra.md
So, the Makefile gives me:
./foo.md ./bla.md ./ra.md
But the desired output were
"./foo.md", "./bla.md", "./ra.md"
How can I transform $(MARKDOWNS)
to achive that? I use GNU Make 4.4.1.
答案1
得分: 1
Certainly, here is the translated code portion:
也许不是最简单的解决方案,但有效:
MARKDOWNS = $(shell find . -type f -name "*.md" ! -name "index.md" ! -name "README.md" | sed 's/^/"/;s/$$/",/' | tr '\n' ' ' | sed 's/..$$//')
all: list
list:
echo '$(MARKDOWNS)'
英文:
Maybe not the simplest solution but works:
MARKDOWNS = $(shell find . -type f -name "*.md" ! -name "index.md" ! -name "README.md" | sed 's/^/"/;s/$$/",/' | tr '\n' ' ' | sed 's/..$$//')
all: list
list:
echo '$(MARKDOWNS)'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论