如何在makefile中引用perl $ symbol [英] How to quote a perl $symbol in a makefile
问题描述
在Makefile中,我有一条规则,可以通过以下方式通过LaTeX纸制作图形列表: 从脚本输出到perl表达式,该表达式将数字编号$ f ++递增,并在图形$ f:之前添加行.
In a Makefile, I have a rule to make a figure list from a LaTeX paper by piping the output from a script to a perl expression that increments figure numbers $f++ and prepends Figure $f: to the lines.
在命令行中,它可以正常运行,如下所示:
From a command line, it works fine, as follows:
% texdepend -format=1 -print=f MilestonesProject | perl -pe 'unless (/^#/){$f++; s/^/Figure $f: /}' > FIGLIST
生成FIGLIST:
# texdepend, v0.96 (Michael Friendly (friendly@yorku.ca))
# commandline: texdepend -format=1 -print=f MilestonesProject
# FIGS =
Figure 1: fig/langren-google-overlay2.pdf
Figure 2: fig/mileyears4.png
Figure 3: fig/datavis-schema-3.pdf
Figure 4: fig/datavis-timeline2.png
...
我不知道如何在Makefile中执行此操作,因为perl表达式中的$ f内容由make解释,我不知道如何引用它 使它变得不可见.
I can't figure out how to make this work in a Makefile, because the $f stuff in the perl expression gets interpreted by make and I can't figure out how to quote it or otherwise make it invisible to make.
我最近在我的Makefile中尝试:
My most recent attempt in my Makefile:
## Generate FIGLIST; doesnt work due to Make quoting
FIGLIST:
$(TEXDEPEND) -format=1 -print=f $(MAIN) | perl -pe 'unless (/^#/){\$f++; s/^/Figure \$f: /}' > FIGLIST
有人可以帮忙吗?
-迈克尔
推荐答案
加倍美元符号.
## Generate FIGLIST
FIGLIST:
$(TEXDEPEND) -format=1 -print=f $(MAIN) \
| perl -pe 'unless (/^\#/){$$f++; s/^/Figure $$f: /}' > $@
您可能还需要反斜杠转义注释符号.我这样做是为了以防万一.
You may need to backslash-escape the comment sign as well. I did so just in case.
另请参见 http: //www.gnu.org/software/make/manual/html_node/Variables-in-Recipes.html#Variables-in-Recipes
这篇关于如何在makefile中引用perl $ symbol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!