【问题标题】:Updating Make Version on Mac在 Mac 上更新 Make 版本
【发布时间】:2017-08-27 18:46:46
【问题描述】:

我正在尝试更新我的 mac 上的 make 版本,但遇到了问题。最低项目依赖是 4.1 但我的版本似乎是 3.81。我已将 Xcode 更新到最新版本并安装了命令行工具,但它似乎仍然是旧版本。

有没有人遇到过这个问题或知道解决方法?

【问题讨论】:

  • 要么自己编译最新版本,要么使用macportshomebrew之类的东西。
  • Apple 不太可能在他们的系统中发布更新版本的 GNU make,因为许可证已更改为 GPLv3,而 Apple 拒绝与该许可证有任何关系。我已经看到了问题报告,因为他们已经将错误的补丁应用到他们的版本中。我同意 user657267,从 homebrew 或 macports 获取副本。

标签: macos makefile


【解决方案1】:

这是我所做的,它适用于我的 MacOS:

Step1:安装homebrew(安装命令来自https://brew.sh/):

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step2:使用自制软件安装make

brew install make --with-default-names

万一它不起作用,试试这个:

brew install homebrew/dupes/make --with-default-names

第 3 步:您需要更改默认命令以使用正确的 make 而不是 MacBook 或 Mac 中的默认命令。

例如,如果您键入

make --version

你会看到:

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

默认版本的默认路径是什么。

所以,现在,在您的 .bash_profile(应该在您的主目录 /Users/your_name 下)中,添加以下行:

export PATH="/usr/local/bin:$PATH"

注意:如果您在安装 make 时看到以下消息:

GNU“make”已安装为“gmake”。如果您需要将其用作“make”,您可以将“gnubin”目录添加到您的 PATH 中 你的 bashrc 喜欢:

PATH="/usr/local/opt/make/libexec/gnubin:$PATH"

然后运行,

export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"

然后获取您的 .bash_profile。现在尝试检查您的版本:

make --version

它应该显示:

GNU Make 4.2.1
Built for x86_64-apple-darwin16.5.0
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later     <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

干杯。

【讨论】:

  • 我认为您不应该将/usr/local/Cellar/anything 放入您的PATH,而是应该放入/usr/local/bin。如果您在那里查看,您会在 Cellar 中看到指向当前版本的符号链接。这样,当您稍后升级到 make v4.3 时,您的 PATH 仍然是正确的,因为 homebrew 将重新符号链接新版本。此外,您的 PATH 对于 all homebrew 包也将是正确的。
  • @Mark Setchell,是的,这是更好的解决方案。我想我最初的想法是由用户来定义他/她是要单独执行此操作还是仅针对所有命令执行此操作。无论如何,更新了我的 PATH 变量。
  • 注意:--with-default-names 已从 brew 中删除。见Why was –with-default-names removed?
  • 我需要在 Catalina 上将 export PATH="/usr/local/opt/make/libexec/gnubin:$PATH" 添加到 ~/.profile 以在整个启动过程中持续存在。
  • 同样,我必须将/usr/local/opt/make/libexec/gnubin 添加到PATH。添加/usr/local/bin 无效。
【解决方案2】:

我尝试通过不同的方法进行修复,即下载较新版本的 GNU Make 我想升级到从官方 GNU 链接下载的源代码进行编译,而不是使用 homebrew。然后,在我的 Mac 上,我添加了 bash shell 的路径:

export PATH=/usr/local/bin

到我的 $HOME 目录中的“.bashrc”文件。

然后重置我的终端。而且,它奏效了。 homebrew 下载似乎存在一些问题,因为该公式会自动将“gmake”安装链接到错误的 bin,或者更准确地说,缺少 /usr/local/Cellar/etc./path 中的 bin。所以我认为这可能是它现在不起作用的原因。希望也许有人会尽快解决这个问题。

【讨论】:

    【解决方案3】:

    首先,当前版本:

    $ make --version                  
    GNU Make 3.81
    Copyright (C) 2006  Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.
    
    This program built for i386-apple-darwin11.3.0
    

    安装/配置步骤:

    brew install make
    export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
    

    结果:

    $ make -v
    GNU Make 4.3
    Built for x86_64-apple-darwin19.6.0
    Copyright (C) 1988-2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    

    【讨论】:

    • 注意:这基本上是@Patrick 答案的简化版本。
    猜你喜欢
    • 1970-01-01
    • 2017-06-11
    • 2021-01-05
    • 2022-12-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-05
    相关资源
    最近更新 更多