在配置中使用特定版本的程序

use*_*014 5 software-installation configure

我想将 bison 安装到我没有 root 权限的机器上。当我尝试使用时configure,出现以下错误:

checking for GNU M4 that supports accurate traces... configure: error: no acceptable m4 could be found in $PATH.
GNU M4 1.4.6 or later is required; 1.4.16 or newer is recommended.
GNU M4 1.4.15 uses a buggy replacement strstr on some systems.
Glibc 2.9 - 2.12 and GNU M4 1.4.11 - 1.4.15 have another strstr bug.
Run Code Online (Sandbox Code Playgroud)

我发现我的M4版本是1.4.13。我在我的主文件夹中安装了一个较新的版本 (1.4.17) 并想configure使用这个本地版本,为此我在配置脚本中找到了这个:

M4          Location of GNU M4 1.4.6 or later. Defaults to the first program
            of 'm4', 'gm4', or 'gnum4' on PATH that meets Autoconf needs.
Run Code Online (Sandbox Code Playgroud)

所以我使用了命令:

../configure --prefix=$HOME/local/bison M4='$HOME/local/m4/bin/'
Run Code Online (Sandbox Code Playgroud)

我认为可以这样做(如果我错了,请纠正我)。

在此之后,我收到此错误:

checking for flex... flex
checking whether lex is flex... no
checking lex output file root... lex.yy
checking lex library... none needed
checking whether yytext is a pointer... no
configure: error: Flex is required
Run Code Online (Sandbox Code Playgroud)

我在本地安装了 flex$HOME/local/flex并尝试修改该PATH变量。

PATH=$HOME/local/flex/bin/:$PATH
Run Code Online (Sandbox Code Playgroud)

,但我仍然遇到同样的错误。所以我不知道如何告诉 configure 使用这个位置。我不认为这次有像 for 那样的选择m4。即使有,如果可以指定一个位置configure来查找任意程序(优先级高于/usr/bin),我仍然会感兴趣?

War*_*ung 2

你很接近了。

首先,该M4变量需要设置为实际 M4 程序文件的路径,而不是它所在的目录。可能比您的情况更常见的用途是在PATH、所以你需要命名实际的可执行文件。在 BSD 类型的操作系统上,通常先拥有平台m4,然后再使用 GNU M4 程序,gm4例如,可能称为 。您可能希望在构建 GNU Bison 时使用 M4 的 GNU 版本,这个变量可以让您做到这一点。否则,在我们的示例系统中,脚本将首先找到 BSD 版本。

其次,我认为您的PATH修改被忽略了。除非您export执行PATH,否则新值将仅对 shell 可用。您有两种方法可以解决此问题:

 export PATH=$HOME/local/flex/bin/:$PATH
Run Code Online (Sandbox Code Playgroud)

或者:

 PATH=$HOME/local/flex/bin/:$PATH ../configure --flags-and-stuff-here
Run Code Online (Sandbox Code Playgroud)

第二个版本仅对脚本进行了更改configure。脚本启动的任何程序都不会看到更改的值PATH,除非导出新值。

就我个人而言,我会在您的启动脚本中采用第一种方法(例如~/.bash_profile),因为您也希望在安装 Bison 后也能使用您的个人版本的 Flex。注销,然后重新登录,然后尝试运行flex来测试它。如果可行,Bisonconfigure脚本也应该首先找到该版本。