使 autogen.sh 在 Linux 和 Mac OS 上可移植
我尝试安装的软件包具有以下 autogen.sh (仅显示第一行):
#! /bin/sh
libtoolize --automake
但是,在 Mac 上,一次 GNU libtool 已安装(例如通过 MacPorts),libtoolize 已重命名为 glibtoolize。按照这个答案,我因此想要将上面的 autogen.sh 修改为:
#! /bin/sh
if [ $(hash libtoolize 2>&-) -eq 0 ]
then
libtoolize --automake
else
glibtoolize --automake
fi
但它返回 ./autogen.sh: line 6: [: -eq: unary operator Expected
。我在这里做错了什么?
the package I am trying to install has the following autogen.sh (only the first lines are showed):
#! /bin/sh
libtoolize --automake
However, on Mac, once GNU libtool has been installed (via MacPorts for instance), libtoolize is renamed as glibtoolize. Following this answer, I hence want to modify the autogen.sh above into:
#! /bin/sh
if [ $(hash libtoolize 2>&-) -eq 0 ]
then
libtoolize --automake
else
glibtoolize --automake
fi
But it returns ./autogen.sh: line 6: [: -eq: unary operator expected
. What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我无法发表评论(还没有足够的代表),但我想指出,现在,如果您通过简单调用 autoreconf 工具来替换 autogen.sh 脚本,实际上可能是最好的,该工具是专门为替换而创建的所有这些 autogen.sh、bootstrap.sh 等脚本都在那里。它是任何 autoconf 的一部分(不确定从什么时候开始,但肯定是 autoconf 2.63 的一部分(当前是 2.68)。
I cannot comment (not enough rep yet), but I'd like to point out that these days, it might actually be best if you replaced the autogen.sh script by a simple call to the autoreconf tool, which was specifically created to replace all those autogen.sh, bootstrap.sh etc. scripts out there. It is part of any autoconf (not sure since when, but definitely was part of autoconf 2.63 (current is 2.68).
您遇到的问题是
$(hash libtoolize 2>&-)
没有输出,因此该行被简单地解释为:if [ -eq 0 ]
返回该命令的代码可以通过
$?
访问,因此您可以这样做:但是,您也可以这样做:
The problem you have is
$(hash libtoolize 2>&-)
has no output, and so that line is interpreted as simply:if [ -eq 0 ]
The return code of the command is accessible via
$?
, so you could do:However, you could just as well do this: