1、在安装ninja的过程中需要先安装re2c(github地址:https://github.com/skvadrik/re2c):
git clone https://github.com/skvadrik/re2c.git
(也可直接下载最新的release压缩包,并解压。下载地址:https://github.com/skvadrik/re2c/releases)
打开终端,cd到re2c目录下执行:
./autogen.sh
这一步若报错:autoreconf: command not found,说明未安装automake,执行第2步安装automark;若执行成功直接执行第3步
2、通过homebrew安装automake,若未安装homebrew,先执行以下命令安装homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
已安装homebrew,安装automake:
brew install automake
安装libtool
brew install libtool
以上步骤完成之后,接着执行第1步
3、接着执行:
$ ./configure&&make&&make install
4、以上3步之后,rec2就安装完成了,接下来安装ninja,执行以下命令:
git clone https://github.com/ninja-build/ninja.git && cd ninja
Python安装:
./configure.py --bootstrap
CMake安装:
cmake -Bbuild-cmake -H.
cmake --build build-cmake
最后,将可执行文件拷贝到/usr/bin/目录下:
cp ninja /usr/bin/
(关于system文件夹的写入权限问题可参考: 如何评价 macOS Big Sur 关闭 SIP 后仍无法修改 System 文件夹下文件?)