使用makemake/autoconf有条件的makefile [英] Makefile conditional with automake/autoconf

查看:84
本文介绍了使用makemake/autoconf有条件的makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我是否可以在Makefile.am中插入条件块,以便将其进一步传递给由自动工具创建的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行,并且make最终失败,并显示以下消息:

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.

  1. 将以上命令更改为python setup.py --root=${DESTDIR}/// --prefix=${DESTDIR}///$(prefix).三斜杠可能是必要的,因为AFAIK,POSIX允许双斜杠具有特殊含义,但三个或三个以上连续斜杠则不需要.

  1. 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:-///} && python setup.py --root=${DESTDIR} --prefix=${DESTDIR}$(prefix)

在我看来并且由于对整体情况的了解有限,可能没有任何必要.由于configure的原始调用者可以准确地指定他真正想要使用的prefix.如果未指定,则Autoconf已经默认为绝对路径(/usr/local).所以,我想,我不太明白为什么会遇到问题.

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 which prefix 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.

这篇关于使用makemake/autoconf有条件的makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆