使用 automake/autoconf 条件生成文件
谁能告诉我是否有办法向 Makefile.am 插入条件块,以便将其进一步传递到由 autotools 创建的 Makfile?
这是一个例子:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
这似乎是执行条件操作的常见 Makefile 方式。 Automake 切断 endif 行,并且 make 最终失败,并显示如下消息:
Makefile:390: * 缺少 `endif'。停止。
有什么想法吗?
can anybody tell me if there is a way to insert a conditional block to Makefile.am so that it will be passed further to a Makfile created by autotools?
Here is an example:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
This seems to be a usual Makefile way of doing conditional things. Automake cuts endif line off and make fails eventually with a message like this:
Makefile:390: * missing `endif'. Stop.
any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于它也被标记为 Autoconf,因此如果可能的话,我建议将条件放入 configure.ac 中。与此类似:
然后,您的 Makefile.am 将包含
Update
有关
问题与从某处调用 。如果
DESTDIR
为空,则前缀可能会扩展为相对路径,这不是您想要的。您已确认它是从您的 Makefile.am 中调用的。然后你可以做两件事。将上述命令更改为
python setup.py --root=${DESTDIR}/// --prefix=${DESTDIR}///$(prefix)
。三斜杠可能是必要的,因为据我所知,POSIX 允许双斜杠具有特殊含义,但不允许三个或更多连续斜杠。将上述命令更改为
DESTDIR=${DESTDIR:-///} && python setup.py --root=${DESTDIR} --prefix=${DESTDIR}$(prefix)
值得注意的是,在我看来,以及对整个情况的有限理解,这些都不应该是必要的。由于
configure
的原始调用者能够准确指定他真正想要使用的前缀
。如果未指定,Autoconf 已默认为绝对路径 (/usr/local
)。所以,我想,我不太明白为什么你会遇到问题。Since it's tagged as Autoconf also, I suggest putting the condition in configure.ac, if that is possible. Similar to so:
Then, your Makefile.am would contain
Update
The problem has to do with
being called from somewhere. If
DESTDIR
is empty, the prefix may expand to a relative path, which is not what you want. You have confirmed it is being called from your Makefile.am. Then there's two things you can do.Change the above command to
python setup.py --root=${DESTDIR}/// --prefix=${DESTDIR}///$(prefix)
. Triple slashes may be necessary since, AFAIK, POSIX allows for double slashes to have a special meaning, but not for three or more consecutive slashes.Change the above command to
DESTDIR=${DESTDIR:-///} && python setup.py --root=${DESTDIR} --prefix=${DESTDIR}$(prefix)
It may be noteworthy that, in my opinion and limited understanding of the whole picture, none of that should be necessary. Since the original caller of
configure
was able to specify exactly whichprefix
he really wanted to use. If none is specified, Autoconf already defaults to an absolute path (/usr/local
). So, I guess, I don't quite understand why you run into your problem.我提出了我在 Is there a way to talk automake 不要解释部分 automakefile? 中偶然发现的另一种方法。但不幸的是,它不适用于 ifeq .. else .. endif 条件。
I propose another approach I found accidentally in Is there a way to tell automake not to interpret part of the automakefile?. But unfortunately it does not work with
ifeq .. else .. endif
conditionals.