有没有办法告诉 automake 不要解释 automakefile 的一部分?
有没有办法告诉 automake 不要解释 Makefile.am 的一部分?
具体来说,我正在尝试在 Makefile.am 中编码 Makefile 条件。 其他人已经注意到,这不起作用,因为 automake 解释了 endif 结构。
有没有办法转义或引用 Makefile.am 文件中的字符串,以便 automake 将它们逐字复制到目标 Makefile 中?具体来说,我不希望它以如下方式解释 endif:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
Is there a way to tell automake not to interpret part of the Makefile.am?
Specifically, I am trying to encode a Makefile conditional in a Makefile.am. As other people have noticed, this doesn't work because automake interprets the endif construct.
Is there any way to escape or quote strings in Makefile.am files so that automake copies them verbatim into the destination Makefile? Specifically I don't want it to interpret the endif in something like:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
automake 执行条件语句的原因是因为有些恐龙 make 不执行条件语句。也就是说,如果您确实必须这样做,您可以将代码片段定义为
configure.ac
中的变量,并将AC_SUBST
定义到您的Makefile
中。这样,automake就没有机会看到它。请记住使用AM_SUBST_NOTMAKE
来避免创建像FOO = @FOO@
这样的行。)并且:
我真诚地希望有比这更好的方法。
The reason automake does conditionals is because some dinosaur makes don't. That said, if you really must do this, you could define your snippet as a variable in
configure.ac
andAC_SUBST
it into yourMakefile
. That way, automake won't get a chance to see it. Remember to useAM_SUBST_NOTMAKE
to avoid creating a line likeFOO = @FOO@
.)and:
I sincerely hope there's a better way than this.
最简单的方法是在
ifdef
、ifeq
、ifneq
、else
和 < 之前插入一个空格代码>endif。这样,这些关键字就不会被 automake 解析器识别。一定要插入一个空格,它不能与制表符一起使用。来源:https://patchwork.kernel.org/patch/6709921/
The simplest way to do so is to insert a space before the
ifdef
,ifeq
,ifneq
,else
andendif
. That way, these keywords are not recognized by the automake parser. Be sure to insert a space, it won't work with a tab.source: https://patchwork.kernel.org/patch/6709921/
我设法找到了不同的解决方案。您可以将要转义的位放在单独的文件中,然后执行以下操作:
由于 automake 不理解
$(eval
它只会保持整行完整。因此您可以将任何您想要的内容放入另一个文件和 GNU make 会很高兴地读取它,注意你不能直接使用include
因为 Automake 确实理解这一点并且会进入另一个文件。I managed to find a different solution. You can put your to-be-escaped bits in a separate file and then do:
Since automake doesn't understand
$(eval
it just leaves the entire line intact. Thus you can put whatever you want into the other file and GNU make will happily read it. Note you can't just useinclude
directly since Automake does understand that and will go into the other file.怎么样:
How about:
在 automake (GNU automake) 1.16.5 中,当我用换行符和空格隔离关键字时,简单条件
ifeq ... endif
会通过 automake 传递到 Makefile 中,如下所示:如果我混合,情况尤其如此 : automake 条件语句与 make 条件语句,如上所示。
In automake (GNU automake) 1.16.5 simple conditionals
ifeq ... endif
do pass through automake into Makefile when I isolate the keywords with newline and spaces, like so:That is especially the case if I mix automake conditionals with make conditionals, like shown above.