1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_6,3_7} )
7 PYTHON_REQ_USE="threads(+)"
8 USE_RUBY="ruby24 ruby25 ruby26"
10 inherit vim-doc flag-o-matic bash-completion-r1 python-single-r1 ruby-single desktop xdg-utils
12 if [[ ${PV} == 9999* ]] ; then
14 EGIT_REPO_URI="https://github.com/vim/vim.git"
16 SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> ${P}.tar.gz
17 https://dev.gentoo.org/~radhermit/vim/vim-8.0.0938-gentoo-patches.tar.bz2"
18 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
21 DESCRIPTION="Vim, an improved vi-style text editor"
22 HOMEPAGE="https://vim.sourceforge.io/ https://github.com/vim/vim"
26 IUSE="X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux sound tcl terminal vim-pager"
28 python? ( ${PYTHON_REQUIRED_USE} )
29 vim-pager? ( !minimal )
33 >=app-eselect/eselect-vi-1.1
34 >=sys-libs/ncurses-5.2-r2:0=
35 nls? ( virtual/libintl )
36 acl? ( kernel_linux? ( sys-apps/acl ) )
37 cscope? ( dev-util/cscope )
38 gpm? ( >=sys-libs/gpm-1.19.3 )
40 luajit? ( dev-lang/luajit:2= )
41 !luajit? ( dev-lang/lua:0[deprecated] )
43 !minimal? ( ~app-editors/vim-core-${PV} )
44 vim-pager? ( app-editors/vim-core[-minimal] )
45 perl? ( dev-lang/perl:= )
46 python? ( ${PYTHON_DEPS} )
47 racket? ( dev-scheme/racket )
48 ruby? ( ${RUBY_DEPS} )
49 selinux? ( sys-libs/libselinux )
50 sound? ( media-libs/libcanberra )
51 tcl? ( dev-lang/tcl:0= )
58 nls? ( sys-devel/gettext )
62 # people with broken alphabets run into trouble. bug 82186.
66 # Gnome sandbox silliness. bug #114475.
67 mkdir -p "${T}"/home || die "mkdir failed"
68 export HOME="${T}"/home
70 use python && python-single-r1_pkg_setup
74 if [[ ${PV} != 9999* ]] ; then
75 # Gentoo patches to fix runtime issues, cross-compile errors, etc
76 eapply "${WORKDIR}"/patches/
79 # Fixup a script to use awk instead of nawk
81 '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' \
82 "${S}"/runtime/tools/mve.awk || die "mve.awk sed failed"
84 # Read vimrc and gvimrc from /etc/vim
85 echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' \
86 >> "${S}"/src/feature.h || die "echo failed"
87 echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' \
88 >> "${S}"/src/feature.h || die "echo failed"
90 # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
91 # Hopefully this pattern won't break for a while at least.
92 # This fixes bug 29398 (27 Sep 2003 agriffis)
94 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
95 "${S}"/runtime/doc/syntax.txt \
96 "${S}"/runtime/doc/tagsrch.txt \
97 "${S}"/runtime/doc/usr_29.txt \
98 "${S}"/runtime/menu.vim \
99 "${S}"/src/configure.ac || die 'sed failed'
101 # Don't be fooled by /usr/include/libc.h. When found, vim thinks
102 # this is NeXT, but it's actually just a file in dev-libs/9libs
103 # This fixes bug 43885 (20 Mar 2004 agriffis)
106 "${S}"/src/configure.ac || die 'sed failed'
108 # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
109 # correctly. To avoid some really entertaining error messages about stuff
110 # which isn't even in the source file being invalid, we'll do some trickery
111 # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
112 find "${S}" -name '*.c' | while read c; do
113 echo >> "$c" || die "echo failed"
116 # conditionally make the manpager.sh script
117 if use vim-pager; then
118 cat > "${S}"/runtime/macros/manpager.sh <<-_EOF_ || die "cat EOF failed"
120 sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
122 -c 'let no_plugin_maps = 1' \\
123 -c 'set nolist nomod ft=man ts=8' \\
124 -c 'let g:showmarks_enable=0' \\
125 -c 'runtime! macros/less.vim' -
129 # Try to avoid sandbox problems. Bug #114475.
130 if [[ -d "${S}"/src/po ]]; then
132 '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
133 "${S}"/src/po/Makefile || die "sed failed"
136 cp -v "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk || die "cp failed"
139 "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
140 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
148 # Fix bug 37354: Disallow -funroll-all-loops on amd64
149 # Bug 57859 suggests that we want to do this for all archs
150 filter-flags -funroll-all-loops
152 # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
153 # everyone since previous flag filtering bugs have turned out to affect
155 replace-flags -O3 -O2
157 # Fix bug 18245: Prevent "make" from the following chain:
158 # (1) Notice configure.ac is newer than auto/configure
159 # (2) Rebuild auto/configure
160 # (3) Notice auto/configure is newer than auto/config.mk
161 # (4) Run ./configure (with wrong args) to remake auto/config.mk
162 sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
163 rm src/auto/configure || die "rm failed"
164 emake -j1 -C src autoconf
166 # This should fix a sandbox violation (see bug 24447). The hvc
167 # things are for ppc64, see bug 86433.
168 for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc*; do
169 if [[ -e "${file}" ]]; then
185 --disable-pythoninterp
186 --disable-mzschemeinterp
193 use debug && append-flags "-DDEBUG"
197 $(use_enable sound canberra)
201 $(use_enable lua luainterp)
202 $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
205 $(use_enable perl perlinterp)
206 $(use_enable python pythoninterp)
207 $(use_enable python python3interp)
208 $(use_with python python-command $(type -P $(eselect python show --python2)))
209 $(use_with python python3-command $(type -P $(eselect python show --python3)))
210 $(use_enable racket mzschemeinterp)
211 $(use_enable ruby rubyinterp)
212 $(use_enable selinux)
213 $(use_enable tcl tclinterp)
214 $(use_enable terminal)
217 # --with-features=huge forces on cscope even if we --disable it. We need
218 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
219 if ! use cscope; then
221 '/# define FEAT_CSCOPE/d' src/feature.h || die "sed failed"
224 # don't test USE=X here ... see bug #19115
225 # but need to provide a way to link against X ... see bug #20093
233 # let package manager strip binaries
234 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
236 # keep prefix env contained within the EPREFIX
237 use prefix && myconf+=( --without-local-dir )
240 --with-modified-by=Gentoo-${PVR} \
245 # The following allows emake to be used
246 emake -j1 -C src auto/osdef.h objects
253 einfo "Starting vim tests. Several error messages will be shown"
254 einfo "while the tests run. This is normal behaviour and does not"
255 einfo "indicate a fault."
257 ewarn "If the tests fail, your terminal may be left in a strange"
258 ewarn "state. Usually, running 'reset' will fix this."
261 # Don't let vim talk to X
264 emake -j1 -C src/testdir nongui
267 # Call eselect vi update with --if-unset
268 # to respect user's choice (bug 187449)
269 eselect_vi_update() {
270 einfo "Calling eselect vi update..."
271 eselect vi update --if-unset
276 local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
278 # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
279 # managed by eselect-vi
281 dosym vim /usr/bin/vimdiff
282 dosym vim /usr/bin/rvim
283 dosym vim /usr/bin/rview
284 if use vim-pager ; then
285 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
286 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
287 insinto ${vimfiles}/macros
288 doins runtime/macros/manpager.sh
289 fperms a+x ${vimfiles}/macros/manpager.sh
292 domenu runtime/vim.desktop
294 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
296 # keep in sync with 'complete ... -F' list
297 bashcomp_alias vim ex vi view rvim rview vimdiff
301 # Update documentation tags (from vim-doc.eclass)
304 # Call eselect vi update
307 # update desktop file mime cache
308 xdg_desktop_database_update
312 # Update documentation tags (from vim-doc.eclass)
315 # Call eselect vi update
318 # update desktop file mime cache
319 xdg_desktop_database_update