Makefile conditional with automake/autoconf(使用 automake/autoconf 条件生成文件)
问题描述
谁能告诉我是否有办法向 Makefile.am 插入条件块,以便将其进一步传递给由 autotools 创建的 Makfile?
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?
这是一个例子:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
这似乎是 Makefile 做有条件的事情的常用方法.Automake 会切断 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: * 缺少 `endif'.停下来.
Makefile:390: * missing `endif'. Stop.
有什么想法吗?
推荐答案
由于它也被标记为 Autoconf,如果可能的话,我建议将条件放在 configure.ac 中.类似这样:
Since it's tagged as Autoconf also, I suggest putting the condition in configure.ac, if that is possible. Similar to so:
AM_CONDITIONAL([CONDITION_NAME], [test x"${SOMEVAR}" != x])
然后,您的 Makefile.am 将包含
Then, your Makefile.am would contain
if CONDITION_NAME
<conditional code>
else
<else :)>
endif
更新
问题与
python setup.py --root=$(DESTDIR) --prefix=$(DESTDIR)$(prefix)
从某个地方被调用.如果 DESTDIR
为空,则前缀可能会扩展为相对路径,这不是您想要的.您已确认它是从您的 Makefile.am 调用的.那么你可以做两件事.
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.
将上述命令改为
python setup.py --root=${DESTDIR}///--prefix=${DESTDIR}///$(prefix)
.三斜线可能是必要的,因为 AFAIK,POSIX 允许双斜线具有特殊含义,但不允许三个或更多连续斜线.
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.
把上面的命令改成DESTDIR=${DESTDIR:-//
本文标题为:使用 automake/autoconf 条件生成文件


基础教程推荐
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01