Skip to main content
Topic: Tips on compiling vi from source (Read 556 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Tips on compiling vi from source

Tips on compiling vi from source

The vi editor is probably the most famous editor on UNIX with a long history attached to it.

Since the software itself is really old, there are some modifications that have to be made in order for it to be compiled and run on a modern Linux system.

First start by modifying the Makefile and change the following variables:
Code: [Select]
INSTALL = install
TERMLIB = ncurses

The Makefile by default specifies TERMLIB as “termlib”, which to my knowledge is old, obsolete and non-existent on a modern Linux distro.

Next modify two macros in config.h to prevent a “terminal too wide” error from vi:
Code: [Select]
#ifndef VMUNIX
#define TUBELINES       70 --- do not modify this
#define TUBECOLS        160 --- do not modify this
#define TUBESIZE        6000
#else   /* VMUNIX */
#define TUBELINES       47  --- modify this
#define TUBECOLS        174  --- modify this
#define TUBESIZE        16000
#endif  /* VMUNIX */

The above macro values works on a suckless terminal on the dwm window manager, however if you still get the “terminal too wide” error, run the following command to see the amount you need to set in the macros:
Code: [Select]
set | grep -E 'COLUMN|LINES'
TUBECOLS corresponds to COLUMNS and TUBELINES corresponds to LINES.

EDIT:

I have also created an “uninstall” target that you can add to your Makefile if you want:
Code: [Select]
uninstall:
        rm $(DESTDIR)$(MANDIR)/man1/edit.1\
                $(DESTDIR)$(MANDIR)/man1/vedit.1\
                $(DESTDIR)$(MANDIR)/man1/view.1\
                $(DESTDIR)$(BINDIR)/edit\
                $(DESTDIR)$(BINDIR)/vedit\
                $(DESTDIR)$(BINDIR)/vi\
                $(DESTDIR)$(BINDIR)/view\
                $(DESTDIR)$(MANDIR)/man1/ex.1\
                $(DESTDIR)$(MANDIR)/man1/vi.1\
                $(DESTDIR)$(BINDIR)/ex\
                $(DESTDIR)$(LIBEXECDIR)/exrecover\
                $(DESTDIR)$(LIBEXECDIR)/expreserve
        rmdir $(LIBEXECDIR)\
                $(PRESERVEDIR)

Re: Tips on compiling vi from source

Reply #1
The Artix package has various patches on the build, but not like yours:
https://gitea.artixlinux.org/packagesV/vi/src/branch/master/x86_64/core
Is the Artix package working OK for you, or does it help to have those extra modifications? I wonder if the  fix-tubesize-short-overflow.patch is fixing the terminal too wide error in a different way, because I've never seen that using the vi package, although I don't use it often.

Re: Tips on compiling vi from source

Reply #2
The Artix package has various patches on the build, but not like yours:
https://gitea.artixlinux.org/packagesV/vi/src/branch/master/x86_64/core
Is the Artix package working OK for you, or does it help to have those extra modifications? I wonder if the  fix-tubesize-short-overflow.patch is fixing the terminal too wide error in a different way, because I've never seen that using the vi package, although I don't use it often.

>>Is the Artix package working OK for you, or does it help to have those extra modifications?

I haven't actually tried the Artix package version, but it does look like those patches could be useful.

Still, I haven't ran into any problems so far with the modified source version.