问题描述
有没有办法告诉自动制作不要解释Makefile.am的一部分?
Is there a way to tell automake not to interpret part of the Makefile.am?
具体来说,我正在尝试在Makefile.am中对有条件的Makefile进行编码.正如其他人所注意到的那样,这是行不通的,因为automake会解释endif构造.
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.
是否有任何方法可以转义或引用Makefile.am文件中的字符串,以便自动制作将它们原样复制到目标Makefile中?具体来说,我不希望它以如下形式解释endif:
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
推荐答案
自动制作有条件的原因是因为某些恐龙没有制作.也就是说,如果您确实必须执行此操作,则可以将代码段定义为configure.ac
中的变量,并将AC_SUBST
定义为Makefile
中的变量.这样,自动制作将没有机会看到它.请记住使用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
and AC_SUBST
it into your Makefile
. That way, automake won't get a chance to see it. Remember to use AM_SUBST_NOTMAKE
to avoid creating a line like FOO = @FOO@
.)
dnl In configure.ac:
snippet='
ifeq ($(somevar),Y)
foo
endif
'
AC_SUBST([snippet])
AM_SUBST_NOTMAKE([snippet])
和:
## In Makefile.am:
@snippet@
我真诚地希望有比这更好的方法.
I sincerely hope there's a better way than this.
这篇关于有没有办法告诉automake不要解释automakefile的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!