最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】mac中升级make到最新版

Mac crifan 9087浏览 0评论

折腾:

【基本解决】Makefile中从独立文件比如json中读取配置变量

期间,mac中用-include或sinclude去导入(故意不存在的文件),但是竟然还是报错。

而官网都解释的很清楚了,应该写法是对的:

GNU make: Include

怀疑是make版本太低导致的

去看看现有版本:

➜  selenium_summary git:(master) ✗ 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

是3.81,我记得好像新版都应该是4.1之类的吧?

所以去mac中升级make:

➜  selenium_summary git:(master) ✗ brew upgrade make
Updating Homebrew...
Error: make not installed

mac 升级 make

c++ – Updating Make Version 4.1 on Mac – Stack Overflow

brew install make --with-default-names

报错:

Error: invalid option: –with-default-names

直接去安装:

➜  selenium_summary git:(master) ✗ brew install make
==> Downloading https://homebrew.bintray.com/bottles/make-4.2.1_1.mojave.bottle.3.tar.gz
==> Downloading from https://akamai.bintray.com/c4/c457485b491cccb4a03059e38244b14e7c7f54abb377fa31874848cc786b54ff?__gda__
######################################################################## 100.0%
==> Pouring make-4.2.1_1.mojave.bottle.3.tar.gz
==> Caveats
GNU "make" has been installed as "gmake".
If you need to use it as "make", you can add a "gnubin" directory
to your PATH from your bashrc like:


    PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
==> Summary
🍺  /usr/local/Cellar/make/4.2.1_1: 15 files, 959.4KB

看到位置了,去看看版本:

➜  selenium_summary git:(master) ✗ ls /usr/local/bin/make*
/usr/local/bin/make_chlayout_test
➜  selenium_summary git:(master) ✗ ll /usr/local/bin/make*
lrwxr-xr-x  1 crifan  admin    45B 10 14  2018 /usr/local/bin/make_chlayout_test -> ../Cellar/ffmpeg/4.0.2/bin/make_chlayout_test
➜  selenium_summary git:(master) ✗ /usr/local/bin/make_chlayout_test --version
Unknown option: version
Usage:
    tools/make_chlayout_test *channels* *out_options*

➜  selenium_summary git:(master) ✗ ll /usr/local/Cellar/make/4.2.1_1/*

-rw-r–r–  1 crifan  staff   2.9K  6 11  2016 /usr/local/Cellar/make/4.2.1_1/AUTHORS

-rw-r–r–  1 crifan  staff    34K  6 11  2016 /usr/local/Cellar/make/4.2.1_1/COPYING

-rw-r–r–  1 crifan  staff    46K  6 11  2016 /usr/local/Cellar/make/4.2.1_1/ChangeLog

-rw-r–r–  1 crifan  staff   559B  5 28 22:14 /usr/local/Cellar/make/4.2.1_1/INSTALL_RECEIPT.json

-rw-r–r–  1 crifan  staff    67K  5 28 22:14 /usr/local/Cellar/make/4.2.1_1/NEWS

-rw-r–r–  1 crifan  staff   6.6K  6 11  2016 /usr/local/Cellar/make/4.2.1_1/README

/usr/local/Cellar/make/4.2.1_1/bin:

total 384

-rwxr-xr-x  1 crifan  staff   190K  6 11  2016 gmake

/usr/local/Cellar/make/4.2.1_1/include:

total 8

-rw-r–r–  1 crifan  staff   2.8K  6 11  2016 gnumake.h

/usr/local/Cellar/make/4.2.1_1/libexec:

total 0

drwxr-xr-x  3 crifan  staff    96B  6 11  2016 gnubin

drwxr-xr-x  3 crifan  staff    96B  6 11  2016 gnuman

lrwxr-xr-x  1 crifan  staff     6B  6 11  2016 man -> gnuman

/usr/local/Cellar/make/4.2.1_1/share:

total 0

drwxr-xr-x  5 crifan  staff   160B  6 11  2016 info

drwxr-xr-x  3 crifan  staff    96B  6 11  2016 man

➜  selenium_summary git:(master) ✗ ll /usr/local/Cellar/make/4.2.1_1/bin/gmake

-rwxr-xr-x  1 crifan  staff   190K  6 11  2016 /usr/local/Cellar/make/4.2.1_1/bin/gmake

➜  selenium_summary git:(master) ✗ /usr/local/Cellar/make/4.2.1_1/bin/gmake –version

GNU Make 4.2.1

Built for x86_64-apple-darwin18.2.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.

➜  selenium_summary git:(master) ✗

是新版4.2.1

新旧版本对比:

➜  selenium_summary git:(master) ✗ 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

➜  selenium_summary git:(master) ✗ gmake –version

GNU Make 4.2.1

Built for x86_64-apple-darwin18.2.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.

那做个软链接替换:

➜  selenium_summary git:(master) ✗ mv /usr/bin/make /usr/bin/make_v381
mv: rename /usr/bin/make to /usr/bin/make_v381: Operation not permitted

竟然没权限

➜  selenium_summary git:(master) ✗ sudo mv /usr/bin/make /usr/bin/make_v381
Password:
mv: rename /usr/bin/make to /usr/bin/make_v381: Operation not permitted

加上了sudo也不行?

mac sudo mv Operation not permitted

Mac OS X 11中的/usr/bin 的“Operation not permitted” – 简书

初心者向け MacでOperation not permittedの解決方法 – Qiita

macos – Operation Not Permitted when on root – El Capitan (rootless disabled) – Stack Overflow

知道了方法了:

系统安全机制Rootless

不允许用root权限去改系统级的一些东西,比如make

想要关闭这个机制,则需要去:

重启mac

按住 Command+R,进入恢复模式

打开Terminal,去关闭:

csrutil disable

要恢复,用:

csrutil enable

暂时不用改了,还是去考虑加上path到/usr/bin前面吧

➜  selenium_summary git:(master) ✗ which gmake
/usr/local/bin/gmake
➜  selenium_summary git:(master) ✗ ls /usr/local/bin/*ake*
/usr/local/bin/automake           /usr/local/bin/gmake              /usr/local/bin/watchman-make
/usr/local/bin/automake-1.16      /usr/local/bin/make_chlayout_test
➜  selenium_summary git:(master) ✗ ll /usr/local/bin/*ake*
lrwxr-xr-x  1 crifan  admin    40B  5 22 10:13 /usr/local/bin/automake -> ../Cellar/automake/1.16.1_1/bin/automake
lrwxr-xr-x  1 crifan  admin    45B  5 22 10:13 /usr/local/bin/automake-1.16 -> ../Cellar/automake/1.16.1_1/bin/automake-1.16
lrwxr-xr-x  1 crifan  admin    32B  5 28 22:14 /usr/local/bin/gmake -> ../Cellar/make/4.2.1_1/bin/gmake
lrwxr-xr-x  1 crifan  admin    45B 10 14  2018 /usr/local/bin/make_chlayout_test -> ../Cellar/ffmpeg/4.0.2/bin/make_chlayout_test
lrwxr-xr-x  1 crifan  admin    42B  4 17  2018 /usr/local/bin/watchman-make -> ../Cellar/watchman/4.9.0/bin/watchman-make

去改试试

➜  selenium_summary git:(master) ✗ ln -s /usr/local/Cellar/make/4.2.1_1/bin/gmake /usr/local/bin/make
➜  selenium_summary git:(master) ✗ ll /usr/local/bin/*ake*
lrwxr-xr-x  1 crifan  admin    40B  5 22 10:13 /usr/local/bin/automake -> ../Cellar/automake/1.16.1_1/bin/automake
lrwxr-xr-x  1 crifan  admin    45B  5 22 10:13 /usr/local/bin/automake-1.16 -> ../Cellar/automake/1.16.1_1/bin/automake-1.16
lrwxr-xr-x  1 crifan  admin    32B  5 28 22:14 /usr/local/bin/gmake -> ../Cellar/make/4.2.1_1/bin/gmake
lrwxr-xr-x  1 crifan  admin    40B  5 28 22:30 /usr/local/bin/make -> /usr/local/Cellar/make/4.2.1_1/bin/gmake
lrwxr-xr-x  1 crifan  admin    45B 10 14  2018 /usr/local/bin/make_chlayout_test -> ../Cellar/ffmpeg/4.0.2/bin/make_chlayout_test
lrwxr-xr-x  1 crifan  admin    42B  4 17  2018 /usr/local/bin/watchman-make -> ../Cellar/watchman/4.9.0/bin/watchman-make

然后确认path中路径顺序:

...:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.....

确保:

/usr/local/bin

/usr/bin

之前,(需要重新打开终端才生效)这样默认make就是:

➜  ~ which make
/usr/local/bin/make
➜  ~ make --version
GNU Make 4.2.1
Built for x86_64-apple-darwin18.2.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.

新版了。

【总结】

mac中就make是3.81版本:

➜  selenium_summary git:(master) ✗ 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

去mac中升级make做法是:

brew install make

安装后的位置是:

/usr/local/Cellar/make/4.2.1_1/bin/make

或:

/usr/local/opt/make/libexec/gnubin/make

(其自己是个软链接:

➜  ~ ll /usr/local/opt/make/libexec/gnubin
total 0
lrwxr-xr-x  1 crifan  staff    15B  6 11  2016 make -> ../../bin/gmake

然后再去确保此处的:

<p>echo $PATH</p>
...:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.....

即:

/usr/local/bin

/usr/bin

之前

然后在/usr/local/bin新建一个make

ln -s /usr/local/Cellar/make/4.2.1_1/bin/gmake /usr/local/bin/make

或:

把:

/usr/local/opt/make/libexec/gnubin

加到PATH中最前面

(可编辑~/.bashrc,加上:

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

然后(重启终端)即可确认make是最新版:

➜  ~ which make
/usr/local/bin/make
➜  ~ make --version
GNU Make 4.2.1
Built for x86_64-apple-darwin18.2.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.

了。

转载请注明:在路上 » 【已解决】mac中升级make到最新版

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.196 seconds, using 22.30MB memory