6.28. Vim-8.0

The Vim package contains a powerful text editor.

6.28.1. Installation of VIM

We will cross-compile Vim so that we can have a text editor in /tools. Vim is not technically necessary in the temporary system, in that it is not there to satisfy any package dependencies in the final system, but we believe that a text editor is an extremely useful tool to have there.

The following patch merges all updates from the 8.0 Branch from the Vim developers:

patch -Np1 -i ../vim-8.0-branch_update-1.patch

The configure script is full of logic that aborts at the first sign of cross compiling. Work around this by setting the cached values of several tests with the following command:

cat > src/auto/config.cache << "EOF"
vim_cv_getcwd_broken=no
vim_cv_memmove_handles_overlap=yes
vim_cv_stat_ignores_slash=no
vim_cv_terminfo=yes
vim_cv_toupper_broken=no
vim_cv_tty_group=world
vim_cv_tgent=zero
EOF

Change the default location of the vimrc configuration file to /tools/etc:

echo '#define SYS_VIMRC_FILE "/tools/etc/vimrc"' >> src/feature.h

Prepare Vim for compilation:

./configure \
    --build=${CLFS_HOST} \
    --host=${CLFS_TARGET} \
    --prefix=/tools \
    --enable-gui=no \
    --disable-gtktest \
    --disable-xim \
    --disable-gpm \
    --without-x \
    --disable-netbeans \
    --with-tlib=ncurses

The meaning of the new configure options:

--enable-gui=no --disable-gtktest --disable-xim --disable-gpm --without-x --disable-netbeans

These options prevent Vim from trying to link to libraries that might be on the host but won't exist inside the temporary build environment.

--with-tlib=ncurses

Tells Vim to use Ncurses as its terminal library.

Compile the package:

make

Install the package:

make -j1 install

Many users are accustomed to using vi instead of vim. Some programs, such as vigr and vipw, also use vi. Create a symlink to permit execution of vim when users habitually enter vi and allow programs that use vi to work:

ln -sv vim /tools/bin/vi

Create a temporary vimrc to make it function more the way you may expect it to. This is explained more in the final system:

cat > /tools/etc/vimrc << "EOF"
" Begin /tools/etc/vimrc

set nocompatible
set backspace=2
set ruler
syntax on

" End /tools/etc/vimrc
EOF

Details on this package are located in Section 10.124.3, “Contents of Vim.”