2

I am trying to build vim with the following options on my Fedora 23

I want +python +python3 +perl +lua +ruby +gui +conceal +gui for some plugins.

I could not find a version with all those built in (so I do it myself)

The journey started by following Valloric

sudo yum install -y ruby ruby-devel lua lua-devel luajit \
    luajit-devel ctags git python python-devel \
    python3 python3-devel tcl-devel \
    perl perl-devel perl-ExtUtils-ParseXS \
    perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \
    perl-ExtUtils-Embed

I also have ncurses (raw,devel,static,...)

Then

$ cd $HOME/Sources
$ git clone https://github.com/vim/vim.git
$ cd vim
$ ./configure --with-tlib=ncurses \
              --with-features=huge \
              --enable-fail-if-missing \
              --enable-luainterp=yes \
              --enable-mzschemeinterp \
              --enable-perlinterp \
              --enable-pythoninterp=yes \
              --with-python-config-dir=/usr/lib64/python2.7/config \
              --enable-python3interp=yes \
              --enable-tclinterp=yes \
              --enable-rubyinterp=yes \
              --enable-cscope \
              --enable-multibyte \
              --enable-gui=auto \
              --prefix=$HOME/Build/vim \
              --with-compiledby=statquant | tee configure.log

The following is printed on screen:

/home/statquant/Sources/vim/src/config-PyMake3137:1478: warning: overriding recipe for target 'Modules/_math.o'
/home/statquant/Sources/vim/src/config-PyMake3137:1475: warning: ignoring old recipe for target 'Modules/_math.o'
/home/statquant/Sources/vim/src/config-PyMake3137:1517: warning: overriding recipe for target 'Modules/timemodule.o'
/home/statquant/Sources/vim/src/config-PyMake3137:1482: warning: ignoring old recipe for target 'Modules/timemodule.o'
configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

Then I

make | tee make.log

I realized that it actually built vim in $HOME/Sources/vim/src instead of $HOME/Build/vim (maybe I was wrong to expect that)

When I run :version on ./vim -g (vim has been build with GUI support) there is NO python NO python3 .... enter image description here

configure.log is there, make.log is there

EDIT1: the following works, I now only miss +perl +ruby

./configure --with-features=huge \
       --enable-tclinterp=yes \
       --enable-luainterp=yes \
       --enable-pythoninterp=yes \
       --enable-python3interp=yes \
       --with-compiledby=statquant \
       --prefix=$HOME/Build/vim \

make install # and yes it installs in $HOME/Build/vim  

enter image description here

EDIT2 Here is what happen when I try to add

  1. +perl

I can run

./configure --with-features=huge \
            --enable-tclinterp=yes \
            --enable-luainterp=yes \
            --enable-pythoninterp=yes \
            --enable-python3interp=yes \
            --enable-perlinterp=yes \
            --prefix=$HOME/Build/vim \
            --with-compiledby=statquant | tee configure.log

It appears to work (no error) : configure.log

make | tee make.log
[...]
cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined
<command-line>:0:0: note: this is the location of the previous definition
cc1: some warnings being treated as errors
make[1]: *** [objects/option.o] Error 1
Makefile:2907: recipe for target 'objects/option.o' failed
make[1]: Leaving directory '/home/statquant/Sources/vim/src'
make: *** [first] Error 2
Makefile:26: recipe for target 'first' failed

I get no vim built in /home/statquant/Sources/vim/src : make.log

  1. +ruby

    ./configure --with-features=huge \ --enable-tclinterp=yes \ --enable-luainterp=yes \ --enable-pythoninterp=yes \ --enable-python3interp=yes \ --enable-rubyinterp=yes \ --prefix=$HOME/Build/vim \ --with-compiledby=statquant | tee configure.log

It does not even run configure

checking --with-tlib argument... empty: automatic terminal library selection
checking for tgetent in -ltinfo... no
checking for tgetent in -lncurses... no
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

Here is the log: configure.log

statquant
  • 13,672
  • 21
  • 91
  • 162
  • Does it work if you don't mess with `CFLAGS`, i.e. run `./configure` without the one-shot assignment? – Jens Jan 24 '16 at 11:40
  • To make sense of error messages of `configure` you need the context, which you redirected to `configure.log`. Try running `configure` without redirection to see which specific checks produce that error output. Or just look at `config.log`, it might contain all relevant information. – xaizek Apr 17 '16 at 15:18
  • Each time you get a fix for something the question changes. This makes it almost impossible to help and a lottery for the bonus. Can you post the error messages you're getting please. – Harry Apr 17 '16 at 18:40
  • Could you post your newest config.log file? It's weird that +ruby and +perl is not available if your configure process is passed with those flags and no errors occured and make also passed. Since it's only some flags playing here, FEAT_RUBY and FEAT_PERL. Once defined to 1 in confdefs.h then :version should show them as +. – Wei Shen Apr 21 '16 at 00:17
  • Do you want latest VIM? Why are you building it yourself?... – Gustavo Rubio Apr 22 '16 at 09:40

5 Answers5

2

Ok... so here's the thing. VIM is one of those programs that has a huge amount of patches, Fedora enforces some security checks at GCC level that won't allow you to build it (easily) from source code, my advice: rebuild the source rpm, is not that hard:

Install required dependencies to rebuild VIM

These packages are required for you to build VIM within F23

sudo dnf install gtk2-devel ncurses-devel lua-devel perl-devel perl-ExtUtils-Embed perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder python-devel python3-devel tcl-devel ruby-devel 

Install racket repository

I see you are passing the --enable-mzschemeinterp flag which requires racket, which is not included on the official repos.

cat >/etc/yum.repos.d/rpm-sphere.repo <<EOF
[rpm-sphere]
name=RPM Sphere
baseurl=http://download.opensuse.org/repositories/home:/zhonghuaren/Fedora_23/
gpgkey=http://download.opensuse.org/repositories/home:/zhonghuaren/Fedora_23/repodata/repomd.xml.key
enabled=1
gpgcheck=1
EOF

Install RPM developer tools:

These are required to install the tools to build/rebuild rpms

sudo dnf install @development-tools
sudo dnf install fedora-packager
sudo dnf install rpmdevtools

Setup your RPM build root

Create a file on your home folder called rpmmacros like so:

vim ~/.rpmmacros

Add the following contents to it:

%_topdir    /home/statquant/Src/rpm

Then create the folder /home/statquant/Src/rpm

Create RPM build necessary folders

You need to have these folders so the source code and spec files are stored when you install the source rpm:

mkdir -p ~/Src/rpm
cd ~/Src/rpm
mkdir BUILD RPMS SOURCES SPECS SRPMS
mkdir RPMS/{noarch,x86,x86_64}

Download VIM source RPM:

dnf dnl --source vim

This will download the source rpm to the current folder, say vim-7.4.1718-1.fc23.src.rpm

Once it has been downloaded, install it:

rpm -ivh vim-7.4.1718-1.fc23.src.rpm

Once installed the RPM should have created the file /home/statquant/Src/rpm/SPECS/vim.spec open this file.

Modify configure options

You'll see that the SPEC file has the configure options and the make commands to build the actual thing. This file is huge and it has a lot of patches. You can go ahead and modify the areas where the configure command is, there are 3:

  • One for vim minimal
  • One for vim enhanced
  • One for the GUI version of vim

Make sure you modify accordingly. I did a test build with your options. You can download my SPEC file here, and vim, vim-enhanced and gvim worked just fine.

Rebuild the RPM

Once you modified (or copied from my template) the spec file you want to build the RPM based of that spec, go to /home/statquant/Src/rpm and then:

rpmbuild -ba SPECS/vim.spec

It will take a while, after that, you should see some ouput saying that the packages were built successfully, in my case:

Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/gustavo/Src/rpm/BUILDROOT/vim-7.4.1718-1.fc23.x86_64
Wrote: /home/gustavo/Src/rpm/SRPMS/vim-7.4.1718-1.fc23.src.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-common-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-minimal-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-enhanced-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-filesystem-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-X11-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-debuginfo-7.4.1718-1.fc23.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.tNsBuH
+ umask 022
+ cd /home/gustavo/Src/rpm/BUILD
+ cd vim74
+ rm -rf /home/gustavo/Src/rpm/BUILDROOT/vim-7.4.1718-1.fc23.x86_64
+ exit 0

Install the new version

So now you have the packages built following fedora recommendations and patches, you can just go ahead and reinstall them (in case you already have the default fedora vim version which is probably true) like so:

cd /home/statquant/Src/rpm/RPMS/x86_64/
sudo dnf reinstall ./vim-common-7.4.1718-1.fc23.x86_64.rpm
sudo dnf reinstall ./vim-enhanced-7.4.1718-1.fc23.x86_64.rpm
etc...

Please note the dot and slash meaning that dnf is trying to install a local package instead of searching through its database which would download the versions you already have.

Notes

Out of security concern I did not uploaded my custom-built packages but if you don't mind or want to try them out ping me and I can upload them so you save yourself all this hassle... I already had all RPM build tools because I build some for me here.

You may also want to create a COPR repository so that you automate this process and if you need to format your disk, reinstall fedora, install it on a new machine etc. you can just add the repository and use dnf to install your custom package.

If you have any other questions let me know, good luck!

Update there are comments in the spec file beginning with # options for so you can jump to the actual configure options

Gustavo Rubio
  • 10,209
  • 8
  • 39
  • 57
  • Nice, yes happy to get the rpm from you, I'll also execute your notes – statquant Apr 22 '16 at 20:04
  • @statquant alright, I setup a copr repo (like ppa for fedora) and once the build machine finishes I'll let you know, that way you can just use the dnf package manager as if you were installing regular vim ;) – Gustavo Rubio Apr 22 '16 at 20:24
  • the spec file creates three different binaries: vim-minimal, vim-enhanced and gvim, in this case gvim is the one built with X11 support through GTK. vim-enhanced is the regular, command line only. AFAIK there is a shell script called vim that will run either of those depending on the arguments given, at least on fedora – Gustavo Rubio Apr 22 '16 at 21:33
  • Hey, I followed you and works well, thanks. Question: 1. vim-enhanced is built without GUI and vim-X11 can only be called with GUI. Why when I build it myself do I have both at once ? 2. if I want +client-server+clipboard+xterm_*, which are - for now what do I do 3. /usr/share/vim/vim74/syntax seems missing where are the syntax (for syntax.vim) 4. Can I use this rpm on say a commercial redhat distro ? – statquant Apr 22 '16 at 21:36
  • I have a problem with the build, looks like (for example) the docs are not picked up, as vim looks in /usr/share instead of ~/.vim this is strange as I use Vundle that set the rtp for all plugins. Also filetypes are not recognized... there are a lot of things missing... – statquant Apr 22 '16 at 23:39
0

You have enabled -Werror=format-security. This treats any susceptible usage of format of printf or scanf currently treated as `error.

You can either fix the usage in if_perl.c, I believe this is generated file. or remove the flag -Werror=format-security

dlmeetei
  • 9,905
  • 3
  • 31
  • 38
0

The python problem was this...

--with-python-config-dir=/usr/lib64/python2.7/config \
--enable-python3interp=yes \

Version 2 config with a version 3 interpreter.

Your missing the ncurses-devel library, I can see that you dropped it from configure.

sudo yum install ncurses-devel

configure actually worked for me even when I didn't have the perl dev packages installed ie it didn't fail asking me to install them which I found odd. Do you have all the dev packages you need installed.

sudo yum install perl-devel
sudo yum install ruby-devel
Harry
  • 11,298
  • 1
  • 29
  • 43
  • @statquant, `--prefix` sets path where application will be *installed*, not build. `vim` will be copied to `$HOME/Build/vim` after you do `make install`. If you want all files to be there (out-of-tree build), you need to run `configure` from that directory (and possibly change `--prefix`). – xaizek Apr 17 '16 at 15:08
0

If you are missing some dev package for ruby or perl the configure script say something like : "disabling this option". Just did this with ruby. After installing the ruby-dev package the ruby option is enabled in vim. Same with libperl-dev.

steiner
  • 170
  • 7
  • Are you 100% sure you have libperl-dev or similar dev pkg installed ? By me, installing this and adding the simple --enable-perlinterp=yes worked like a charm – steiner Apr 22 '16 at 11:15
  • Have you seen that I have `perl perl-devel perl-ExtUtils-ParseXS \ perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \ perl-ExtUtils-Embed` – statquant Apr 22 '16 at 11:21
0

There is now a Vim issue filed about this: https://github.com/vim/vim/issues/1081

I'm using a work-around that I mentioned in a comment to that issue: https://github.com/vim/vim/issues/1081#issuecomment-269920486

I've copied most of that comment below in case it may be helpful.

I ran into this problem on Fedora 25 (x86_64). Vim's configure script asks ruby about LDFLAGS without a corresponding query regarding CFLAGS: https://github.com/vim/vim/blob/v8.0.0134/src/auto/configure#L7174

rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG['LDFLAGS']"`

Since Fedora 23, all RPMs have been "hardened" by default: https://fedoraproject.org/wiki/Changes/Harden_All_Packages

When an RPM is built, the %configure macro used in the RPM SPEC file is automatically adjusted to provide CFLAGS, LDFLAGS, and several other environment variables using hardened settings. When using Fedora's ruby package, the above query using rbconfig returns hardened linker flags. Because Vim's configure script doesn't use a corresponding rbconfig to query ruby's CFLAGS, the compiling and linking flags are mismatched, leading to the error:

configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

In src/auto/config.log, this mismatch of flags causes this error:

configure:11318: checking for tgetent in -lncurses
configure:11343: gcc -o conftest -g -O2  -L. -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro    -L/usr/local/lib conftest.c -lncurses   -lselinux  >&5
/usr/bin/ld: /tmp/cckpDslF.o: relocation R_X86_64_PC32 against undefined symbol `tgetent' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

I can successfully build with a work-around, but I don't know enough about autoconf to suggest a proper fix to the configure script. The work-around involves first installing some RPM-related packages:

sudo dnf install -y rpm-build redhat-rpm-config

Next, set these variables at the shell prompt via:

eval $(rpmbuild --eval '%{configure}' | egrep '^\s*[A-Z]+=')

The above uses rpmbuild --eval '%{configure}' to query the definition of the %configure macro which begins with a number of environment variable assignments. This provides the same default compilation environment that is provided in the %configure macro. Now running the below invocation succeeds:

./configure --quiet --with-features=huge --enable-rubyinterp
Michael Henry
  • 496
  • 3
  • 8