Wednesday, August 10, 2022

Re: Building VIM 9 on Ubuntu

Vim — the editor

Vim: Compiling HowTo

for Vim on Unix-like systems
Last change: 2015-12-24 02:23 UTC
Back to "The Vim Editor"
Back to Welcome page
  1. Once and for all:
    • Before you compile anything, make sure you have the required software tools. On most Linux distributions, the administrator who installs the Linux software has a choice of "packages" which he may choose to install, or not. In order to be able to compile Vim, you need not only the archive-manipulating tools tar, bzip2 and gzip, a compiler (usually gcc) and its associate linker and libraries, you also need "development" packages for everything that Vim will use. This means, for example, that you cannot compile gvim if the x11-devel package isn't installed (as well as several other packages), that you cannot compile Vim with Python interface if the python-devel package isn't installed, etc. The configure log (see below) will tell you what it couldn't find, it usually means there is a missing "development" package.
    • Create a separate directory structure for development. The text below assumes that this directory structure starts (for Vim) at ~/.build/vim/. Change that prefix whenever it appears below if you use something else.
    • Environment variables: I use environment variables to set configuration options, so I don't need to change any "Vim" files. I believe that this method is "cleaner"; also, since configuration options don't change much from one release to the next, it allows keeping one's configuration even when going from release to release (and the Makefile is downloaded again). For that, I create a shell script, ~/.build/vim/myenviro, which contains as many lines as there are environment variables to set, in the form
       	export variable='value' 
      There is one difficulty: you cannot just "run" this script (by giving its name to bash as a command name) you must "source" it each time you are ready to start a new compilation. But this actually belongs in a further paragraph, and we shall repeat it there. Here's the sample script I use; it is fairly general, and any features for which you don't have the required "development" packages will be eliminated at configure-time:
       #!/bin/bash export CONF_OPT_GUI='--enable-gnome-check' export CONF_OPT_PERL='--enable-perlinterp' export CONF_OPT_PYTHON='--enable-pythoninterp' export CONF_OPT_TCL='--enable-tclinterp' # /usr/bin/tclsh (softlink) is correctly set export CONF_OPT_RUBY='--enable-rubyinterp' export CONF_OPT_LUA='--enable-luainterp' export CONF_OPT_MZSCHEME='--disable-mzschemeinterp' #export CONF_OPT_PLTHOME='--with-plthome=/usr/local/plt' export CONF_OPT_CSCOPE='--enable-cscope' export CONF_OPT_MULTIBYTE='--enable-multibyte' export CONF_OPT_FEAT='--with-features=huge' export CONF_OPT_COMPBY='"--with-compiledby=antoine.mechelynck@gmail.com"' 
      You may use that, except that you will of course have to put your name, not mine, in the last line; and you may or may not have to insert something like --with-tclsh=tclsh8.6 at the end of the CONF_OPT_TCL line if configure does not detect the TCL version correctly.
    • If you are using the Xubuntu distribution, you may want to check Taylor Venable's Vim HowTo, especially if you want Vim to interface with MzScheme.
    • Getting the Vim sources: see Getting the Vim source with Mercurial at the Vim Tips wiki.
    • If you want to compile more than one Vim with different feature sets: run make -C src shadow to create a "shadow" directory, which will be named src/shadow and populated with soft links to the contents of src/ ; then immediately rename src/shadow to something else (without changing its location or contents). This way, you can create as many "shadow directories" as you want. Then you will (whenever you compile) cd to the proper shadowdir, source the appropriate environment-setting script, and run make there. You can even run several compilation runs in parallel, each in its own shell, with its own shadowdir and its own configure environment. One line you will probably want to use in this case will be (for instance)
       	export CONF_ARGS2='--with-vim-name=vi' 
      to avoid ending up with several executables all of the same name. Note that you can only have at most one value for each environment variable, but you can concatenate several configure command-line argument (space-separated) in one quoted value, e.g.
       	export CONF_ARGS2='--with-vim-name=vim-mod --with-modified-by="John Doe & Mary Roe"' 
      Notice the use of both single and double quotes in the above example.
  2. Every time:
    1. cd to your top Mercurial directory (the parent of .hg/ src/ runtime/ etc.)
    2. See if there are any changes:
       	hg incoming 
    3. If there are: get them, either (if you made no changes to the source)
      	(date && hg pull -u) 2>&1 |tee -a ../hgvim.log
      or if you did (and have installed the fetch extension)
      	(date && hg fetch --switch-parent) 2>&1 |tee -a ../hgvim.log
    4. Have a look at the Makefiles (vim71/Makefile and vim71/src/Makefile) and write down any features you might want to change (in the myenviro script mentioned earlier). Make any needed changes, then source the script (it's not enough to just "run" it):
       	source myenviro       
    5. Now's the big one: Let's compile. The current directory is still the "top" directory inside your Mercurial repository (see below if you are compiling in a shadow directory).
      • If you made any changes in the configure options since last time, or if you added or removed software packages:
         	make reconfig 2>&1 |tee ../make-vim.log 
      • If you didn't, or if this is the first time for this release:
         	make 2>&1 |tee ../make-vim.log 
    6. The programs we just compiled should end up in the src/ subdirectory. Now let's check that everything went well:
      • less make.log
        — At the end, you should see the make for the .po files (multilingual messages), and above that, the link.
      • ls -l src/vim
        should show you the newly compiled Vim executable, with today's date.
      • src/vim --version |more
        — this will show you the details of the features actually compiled-in. If you miss some feature that is important to you, go back to the configure log (near the top of the make.log), and check what went wrong. As noted earlier, you may need to install some "development" package from your Linux (or other) distribution. (There is another, longer, configure log at src/auto/config.log ).
    7. If everything seems OK, we can "install" the newly-compiled Vim:
      • Close down any running instance of vim or gvim.
      • make install 2>&1 |tee install.log
      • Make sure that the new version will be invoked by default: ls -l `which vim` should show your new Vim executable, dated a few minutes ago. If you see something else, which -a vim will show you all Vim executables in the $PATH, in the order found. You may for instance want to make a soft link in some directory early in the path (let's say as /usr/local/bin/vim) pointing to your new executable. You may also (if it isn't done yet) want to create soft links from the various executable names mentioned at and below ":help ex", all pointing to vim.
    8. That's all folks !
    If you compile in a shadow directory (let's say src/tiny for an executable named vi), the above doesn't change much:
    • Getting the sources and keeping them up-to-date is done only once for all shadow dirs, since all the sources in them are links to the sources in src/, so the following assumes the sources are already up-to-date:
       	cd src/tiny 		let's source the configure arguments into this shell's environment: 		this file does not exist by default, you must have set it up 		like mycfg in the above case, but with the configure arguments for this particular build: 	source tinycfg.sh 	make 2>&1 |tee tinymake.log 		Check that all went well: 	./vi --version |more 		and if it looks OK: 	make installvimbin 2>&1 |tee tinyinst.log 	ls -l `which vi` 
    • Since the runtime files are shared by all Vim executables (with a common version and patchlevel but different featuresets), we run make install only once, for the "main" version, which is compiled as above from src/, or maybe from the first shadow directory (src/full or src/default, or whatever suits you).
    • Just like above, you may use make config before plain make to do only the configure part, or make reconfig to reconfigure and recompile. As above, the first time you run make (without arguments) in any particular shadow dir, it will run make config implicitly if it hasn't yet been done there, so be sure to set your environment correctly.

Back to "The Vim Editor" Back to Welcome page
On Wed, Aug 10, 2022 at 3:10 PM 'J S' via vim_use
<vim_use@googlegroups.com> wrote:
>
> I tried building the latest VIM on a Ubuntu system, and it worked, except...
>
> I followed the instructions on the VIM page, which consists of 3 steps:
>
> 1) git clone http://...
> 2) cd vim/src
> 3) make
>
>
> This worked, and 8 minutes later, I had a new vim executable. However, I noticed that the first thing the "make" did was to run the usual "configure" script, which is good, but the thing is, I usually like to pass some args to "configure", such as setting the "prefix" to something under my $HOME (so that I can later do "make install" without "sudo")
>
> I also noticed that the resulting binary did not include the GUI. Now, I think that VIM without a GUI is virtually useless (Yes, I know, some people may disagree with this, but that's irrelevant). The version of VIM that is already installed on my system (which is old) is the "gtk3" version, and I would like the new version to also be GTK3. Note that installing Vim9 from a repo is not an option here; I need to compile it myself.
>
> Now, I figured out that if I do:
>
> 1) make distclean
> 2) ./configure ...
> 3) make
>
> It will re-do the make, using the version of the configure stuff that I ran manually (i.e., it won't run it again). This is good. However, despite trying several times, I was not able to make a GUI version of Vim9. (I keep getting the error message "GUI not enabled at compile time")
>
> Therefore, my questions and comments are:
>
> 1) Can someone give me a good list of all the dependencies and packages that I need to install on my Ubuntu 18.04 (Yes, I know that is old, but that also cannot be changed) system so that I can build a GTK3 version of Vim9? (N.B. This is the most important paragraph of this post; everything else is just information!)
>
> 2) I hate the fact that it goes ahead and builds it (which takes a non-trivial amount of time and computing resources - as I said, about 8 to 10 minutes) even though the resulting file is junk (useless). I know that Vim is not alone in this behavior - other modern programs are like this - where if they figure out that you don't have the necessary dependencies installed, they go ahead and silently fail (i.e., build an output file that is junk). I wish there were a way - a ./configure option - that would tell it to fail immediately if it is not going to work.
>
> Note: I was using the ./configure option: --enable-gui=gtk3
> I also tried adding: --with-x
>
> Note that when I added those options, it did make the resulting file much larger (18 meg vs only 3 meg originally), but it still refused to run the GUI.
>

In adition to Gary's reply about how to get the nessary "development"
packages on Ubuntu, I recommend _not_ to tun configure with arguments
on the command-line, but to set the configure arguments by means of
environment variables so that even if "make" decides to rerun
configure, it will do so with your preferred settings. This way, if
you decide that it is necessary to recompile "your own version of Vim"
from scratch rather than recompiling only the changed modules, "make
reconfig" (with the appropriate environment settings) will do it.
Otherwise, just "make" will normally trigger an incremental compile,
though in some cases make may decide to rerun configure (and usually
it will find out that auto/config.cache is unchanged and compile only
the changed modules anyway).

I used to have a how-to page about that but my ISP has removed all
"user sites" since then. I'm attaching my backup copy of it.

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXtarAGWU5DXL21vcC8fhAsFWA9ccyUPw%2BYAwiW7Hrn81w%40mail.gmail.com.

No comments:

Post a Comment