且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 automake/autoconf 条件生成文件

更新时间:2022-05-11 01:41:54

由于它也被标记为 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.