[英]Makefile generate numerical list of files
I have a Makefile that I use for building a book I am writing into EPUB and Kindle formats. 我有一个Makefile,可用来构建以EPUB和Kindle格式编写的书。
However, my list of source files is getting really long: 但是,我的源文件列表越来越长:
CHAPTERS = \
1.md \
2.md \
...
30.md \
I am trying to generate this list programmatically, and I got it working with: 我正在尝试以编程方式生成此列表,并且可以使用:
CHAPTERS = $(addsuffix .md, $(shell seq 1 30))
But can't help but feel I feel like there is a simpler way. 但是不禁觉得我有一种更简单的方法。
Is there a simpler method to achieve numerical file generation (ie can this be reduced to a single command instead of 2 nested commands)? 是否有一种更简单的方法来实现数字文件生成(即可以将其简化为单个命令,而不是2个嵌套命令)?
Coincidentally, the GNUmake Table Toolkit features such a function: 巧合的是, GNUmake Table Toolkit具有以下功能:
$(call interval,start,range[,step]) $(通话间隔,开始,范围[,步骤])
$(call interval,5,5) --> 5 6 7 8 9
$(call interval,2,3,100) --> 2 102 202
Of course, simple is just a relative measure... 当然, 简单只是一个相对的措施...
Is there a simpler method to achieve numerical file generation
有没有更简单的方法来实现数字文件生成
You can do without shell. 您可以不使用shell。 Whether it's simpler or not...
是否更简单...
mygen=$(words $3)$1 $(if $(word $2,$3),,$(call mygen,$1,$2,w $3))
CHAPTERS:=$(call mygen,.md,30,w)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.