LoginSignup
6
10

More than 5 years have passed since last update.

Vimをビルドしてみよう

Last updated at Posted at 2015-09-07

はじめに

UtilSnipsを使うためにVimをビルドしてみました。

UtilSnipsを使うためにはバージョン7.4以上、かつ、FeatureにPythonが含まれるVimが必要になります。

OSX YosemiteのデフォルトのVimのバージョンは7.3ですので、UtilSnipsを使うためには新しいVimが必要です。

RudixでVimをインストールしてみたところ、バージョンは7.4でしたが、FeatureにPythonが含まれていませんでした。

Vimをビルドしたことがなかったので、ビルドしてみました。できるだけ、OSX YosemiteのデフォルトのVimのFeatureに近いものを目指しましたので、もしかしたら需要があるかもしれません。

ソースコード

ビルドするために、ソースコードが必要になります。

$ git clone https://github.com/vim/vim.git
$ cd vim
$ git pull

Makefile

Featureを設定するためにsrc/Makefileを編集します。

./Makefileではなく./src/Makefileを編集します。

diff --git a/src/Makefile b/src/Makefile
index 03cf2d9..e4a43a5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -324,7 +324,7 @@ CClink = $(CC)
 # Uncomment this line when you don't want to get the GUI version, although you
 # have GTK, Motif and/or Athena.  Also use --without-x if you don't want X11
 # at all.
-#CONF_OPT_GUI = --disable-gui
+CONF_OPT_GUI = --disable-gui

 # Uncomment one of these lines if you have that GUI but don't want to use it.
 # The automatic check will use another one that can be found.
@@ -425,7 +425,7 @@ CClink = $(CC)
 # However, this may still cause problems, such as "import termios" failing.
 # Build two separate versions of Vim in that case.
 #CONF_OPT_PYTHON = --enable-pythoninterp
-#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic
+CONF_OPT_PYTHON = --enable-pythoninterp=dynamic
 #CONF_OPT_PYTHON3 = --enable-python3interp
 #CONF_OPT_PYTHON3 = --enable-python3interp=dynamic

@@ -434,7 +434,7 @@ CClink = $(CC)
 # First one for static linking, second one for loading when used.
 # Note: you need the development package (e.g., ruby1.9.1-dev on Ubuntu).
 #CONF_OPT_RUBY = --enable-rubyinterp
-#CONF_OPT_RUBY = --enable-rubyinterp=dynamic
+CONF_OPT_RUBY = --enable-rubyinterp=dynamic
 #CONF_OPT_RUBY = --enable-rubyinterp --with-ruby-command=ruby1.9.1

 # TCL
@@ -444,7 +444,7 @@ CClink = $(CC)

 # CSCOPE
 # Uncomment this when you want to include the Cscope interface.
-#CONF_OPT_CSCOPE = --enable-cscope
+CONF_OPT_CSCOPE = --enable-cscope

 # WORKSHOP - Sun Visual Workshop interface.  Only works with Motif!
 #CONF_OPT_WORKSHOP = --enable-workshop
@@ -452,7 +452,7 @@ CClink = $(CC)
 # NETBEANS - NetBeans interface. Only works with Motif, GTK, and gnome.
 # Motif version must have XPM libraries (see |workshop-xpm|).
 # Uncomment this when you do not want the netbeans interface.
-#CONF_OPT_NETBEANS = --disable-netbeans
+CONF_OPT_NETBEANS = --disable-netbeans

 # SNIFF - Include support for SNiFF+.
 #CONF_OPT_SNIFF = --enable-sniff
@@ -462,7 +462,7 @@ CClink = $(CC)
 # It's automatically enabled with normal features, GTK or IME support.
 # Note: Compile on a machine where setlocale() actually works, otherwise the
 # configure tests may fail.
-#CONF_OPT_MULTIBYTE = --enable-multibyte
+CONF_OPT_MULTIBYTE = --enable-multibyte

 # NLS - National Language Support
 # Uncomment this when you do not want to support translated messages, even
@@ -475,7 +475,7 @@ CClink = $(CC)
 # HANGUL - Input Hangul (Korean) language using internal routines.
 # Uncomment one of these when you want to input a multibyte language.
 #CONF_OPT_INPUT = --enable-xim
-#CONF_OPT_INPUT = --disable-xim
+CONF_OPT_INPUT = --disable-xim
 #CONF_OPT_INPUT = --enable-hangulinput

 # FONTSET - X fontset support for output of languages with many characters.
@@ -494,14 +494,14 @@ CClink = $(CC)
 # sysmouse - For mouse support on FreeBSD and DragonFly console via sysmouse
 # Uncomment this when you do not want do include sysmouse support, even
 # though you have /dev/sysmouse and includes.
-#CONF_OPT_SYSMOUSE = --disable-sysmouse
+CONF_OPT_SYSMOUSE = --disable-sysmouse

 # FEATURES - For creating Vim with more or less features
 # Uncomment one of these lines when you want to include few to many features.
 # The default is "normal".
 #CONF_OPT_FEAT = --with-features=tiny
 #CONF_OPT_FEAT = --with-features=small
-#CONF_OPT_FEAT = --with-features=normal
+CONF_OPT_FEAT = --with-features=normal
 #CONF_OPT_FEAT = --with-features=big
 #CONF_OPT_FEAT = --with-features=huge

@@ -513,7 +513,7 @@ CClink = $(CC)
 # Also disable the GUI above, otherwise it will be included anyway.
 # When both GUI and X11 have been disabled this may save about 15% of the
 # code and make Vim startup quicker.
-#CONF_OPT_X = --without-x
+CONF_OPT_X = --without-x

 # X WINDOWS DIRECTORY - specify X directories
 # If configure can't find you X stuff, or if you have multiple X11 derivatives
@@ -527,7 +527,7 @@ CClink = $(CC)
 # Vim will try to use XSMP to catch the user logging out if there are unsaved
 # files.  Uncomment this line to disable that (it prevents vim trying to open
 # communications with the session manager).
-#CONF_OPT_XSMP = --disable-xsmp
+CONF_OPT_XSMP = --disable-xsmp

 # You may wish to include xsmp but use exclude xsmp-interact if the logout
 # XSMP functionality does not work well with your session-manager (at time of
@@ -931,7 +931,7 @@ TOOLS = xxd/xxd$(EXEEXT)
 ### prefix the top directory for the data (default "/usr/local")
 #
 # Uncomment the next line to install Vim in your home directory.
-#prefix = $(HOME)
+prefix = /usr/local/vim

 ### exec_prefix    is the top directory for the executable (default $(prefix))
 #

ビルド

デフォルトでは/usr/localにインストールされますが、今回は/usr/local/vimにインストールします。念のためディレクトリを用意しておきます。

$ sudo mkdir -p /usr/local/vim

次のコマンドラインでビルドします。

$ cd src
$ make distclean
$ make
$ sudo make install

インストールできたら、エイリアスかシンボリックリンクでVimを実行できるように設定します。

疑問点

ビルドしてみて、いくつか疑問点があります。

  • /usr/local/vim/libが空だけど、大丈夫?
  • Compilation, LinkingがデフォルトのVimと違うけど、大丈夫?

今のところはNetrwにrelativenumberが表示されない点以外はデフォルトと同じ感じです。

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep  7 2015 16:46:51)
MacOS X (unix) version
Included patches: 1-854
Compiled by hoge@huga.local
Normal version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_netterm   +syntax
-arabic          +file_in_path    -mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           -mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
+builtin_terms   -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         -gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    -netbeans_intg   +title
+clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    -keymap          +postscript      +virtualedit
+comments        -langmap         +printer         +visual
-conceal         +libcall         -profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             -rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    -signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
-emacs_tags      -mouseshape      -sniff           -xsmp
+eval            -mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/vim/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -O2 -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -L/usr/local/lib  -o vim        -lm -lncurses  -liconv -framework Cocoa           

まとめ

Vimをビルドしてみました。UtilSnipsも動作しました(^^)

参照URL

6
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
10