編譯VIM

weixin_33766168發表於2019-01-06

編譯VIM最麻煩的只有一個問題:
各個語言的位置和開發庫的位置

注意:語言本身的位置好說,但是dev開發庫就不一樣了。
比如,一般我們本機只安裝python,而不會安裝python-dev。這是兩個完全不一樣的概念。第一個我們直接使用的語言,第二個是本機編譯、開發能夠引用的開發lib庫。
所以,根據語言支援的需要,我們要安裝這些開發庫:

  • python-dev
  • python3-dev
  • ruby-dev
  • perl-dev
  • lua-dev
  • libncurses5-dev

如果安裝好這些依賴,且明白各自的位置後,剩下的VIM編譯是超級簡單的。
如果編譯出現問題,也絕對是這些位置出現了問題。

樹莓派編譯VIM包括Python/Lua/Ruby/Perl支援

# 下載原始碼
cd /tmp
wget https://github.com/vim/vim/archive/v8.1.0561.tar.gz
tar -xzvf v8.1.0561.tar.gz
cd vim-8.1.0561

# 下載語言支援的開發庫(和本機的各種語言使用無關)
sudo apt-get install -y libncurses5-dev liblua5.3-dev libperl-dev python-dev python3-dev ruby-dev

# 定義各個語言的開發庫位置

# 修復lua位置
sudo mv $(which lua) "$(which lua)_old"
sudo ln -s /usr/bin/lua5.3 /usr/bin/lua
sudo ln -s /usr/include/lua5.3 /usr/include/lua
sudo ln -s /usr/lib/arm-linux-gnueabihf/liblua5.3.so /usr/local/lib/liblua.so

# 修復python位置
sudo ln -s /usr/lib/python2.7/config-arm-linux-gnueabihf /usr/lib/python2.7/config
sudo ln -s /usr/lib/python3.4/config-3.4m-arm-linux-gnueabihf /usr/lib/python3.4/config

# Build
./configure \
    --prefix=/opt/vim-8.1 \
    --enable-gui=auto \
    --enable-luainterp \
    --enable-python3interp \
    --enable-pythoninterp=dynamic \
    --enable-perlinterp=dynamic \
    --enable-rubyinterp=dynamic \
    --enable-cscope \
    --enable-multibyte \
    --enable-fontset \
    --enable-largefile \
    --enable-fail-if-missing \
    --with-features=huge \
    --with-python-config-dir=/usr/lib/python2.7/config \
    --with-python3-config-dir=/usr/lib/python3.4/config \
    --disable-netbeans && \
    echo '[ OK ]'

make && sudo make install && echo '[ OK ]'

# 將舊版本的vim替換
sudo mv $(which vim) "$(which vim)_old"
sudo ln -s /opt/vim-8.1/bin/vim /usr/bin/vim

Mac編譯VIM包括Python/Lua/Ruby/Perl支援

# Download
cd /tmp
wget https://github.com/vim/vim/archive/v8.1.0561.tar.gz
tar -xzvf v8.1.0561.tar.gz
cd vim-8.1.0561

# Build
./configure \
--prefix=/opt/vim-8.1 \
--enable-multibyte \
--enable-perlinterp=dynamic \
--enable-rubyinterp=dynamic \
--with-ruby-command=/usr/local/bin/ruby \
--enable-pythoninterp=dynamic \
--with-python-config-dir=/usr/lib/python2.7/config \
--enable-python3interp \
--with-python3-config-dir=/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin \
--enable-luainterp \
--with-lua-prefix=/usr/local/Cellar/lua/5.3.5_1 \
--enable-cscope \
--enable-gui=auto \
--with-features=huge \
--enable-fontset \
--enable-largefile \
--disable-netbeans \
--enable-fail-if-missing && \
echo '[ OK ]'

make && sudo make install && echo '[ OK ]'

如果本機沒有lua的話:

brew install lua

然後仔細檢視lua路徑,一般是/usr/local/Cellar/lua*,把它替換到configure的引數中去。

如果Python沒有配置好的話,則到/usr/local/Cellar/python目錄下搜尋config-*檔案:

find /usr/local/Cellar/python -name "config-*"

然後我得到的是/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin。把它替換到configure的引數中相應位置。

相關文章