sys-process/glances: revbump 3.1.4.1, add missing doc dep
[gentoo.git] / app-editors / vim / vim-8.2.0638.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 VIM_VERSION="8.2"
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 PYTHON_REQ_USE="threads(+)"
8 USE_RUBY="ruby24 ruby25 ruby26 ruby27"
9
10 inherit vim-doc flag-o-matic bash-completion-r1 python-single-r1 ruby-single desktop xdg-utils
11
12 if [[ ${PV} == 9999* ]] ; then
13         inherit git-r3
14         EGIT_REPO_URI="https://github.com/vim/vim.git"
15 else
16         SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> ${P}.tar.gz
17                 https://dev.gentoo.org/~zlogene/distfiles/app-editors/vim/vim-8.2.0360-gentoo-patches.tar.xz"
18         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~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"
19 fi
20
21 DESCRIPTION="Vim, an improved vi-style text editor"
22 HOMEPAGE="https://vim.sourceforge.io/ https://github.com/vim/vim"
23
24 SLOT="0"
25 LICENSE="vim"
26 IUSE="X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux sound tcl terminal vim-pager"
27 REQUIRED_USE="
28         python? ( ${PYTHON_REQUIRED_USE} )
29         vim-pager? ( !minimal )
30 "
31
32 RDEPEND="
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 )
39         lua? (
40                 luajit? ( dev-lang/luajit:2= )
41                 !luajit? ( dev-lang/lua:0[deprecated] )
42         )
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= )
52         X? ( x11-libs/libXt )
53 "
54
55 DEPEND="
56         ${RDEPEND}
57         sys-devel/autoconf
58         nls? ( sys-devel/gettext )
59 "
60
61 pkg_setup() {
62         # people with broken alphabets run into trouble. bug 82186.
63         unset LANG LC_ALL
64         export LC_COLLATE="C"
65
66         # Gnome sandbox silliness. bug #114475.
67         mkdir -p "${T}"/home || die "mkdir failed"
68         export HOME="${T}"/home
69
70         use python && python-single-r1_pkg_setup
71 }
72
73 src_prepare() {
74         if [[ ${PV} != 9999* ]] ; then
75                 # Gentoo patches to fix runtime issues, cross-compile errors, etc
76                 eapply "${WORKDIR}"/patches/
77         fi
78
79         # Fixup a script to use awk instead of nawk
80         sed -i -e \
81                 '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' \
82                 "${S}"/runtime/tools/mve.awk || die "mve.awk sed failed"
83
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"
89
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)
93         sed -i -e \
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'
100
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)
104         sed -i -e \
105                 's/ libc\.h / /' \
106                 "${S}"/src/configure.ac || die 'sed failed'
107
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"
114         done
115
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"
119                         #!/bin/sh
120                         sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
121                                         vim \\
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' -
126                         _EOF_
127         fi
128
129         # Try to avoid sandbox problems. Bug #114475.
130         if [[ -d "${S}"/src/po ]]; then
131                 sed -i -e \
132                         '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
133                         "${S}"/src/po/Makefile || die "sed failed"
134         fi
135
136         cp -v "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk || die "cp failed"
137
138         sed -i -e \
139                 "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
140                 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
141
142         eapply_user
143 }
144
145 src_configure() {
146         local myconf=()
147
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
151
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
154         # multiple archs...
155         replace-flags -O3 -O2
156
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
165
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
170                         addwrite $file
171                 fi
172         done
173
174         if use minimal; then
175                 myconf=(
176                         --with-features=tiny
177                         --disable-nls
178                         --disable-canberra
179                         --disable-acl
180                         --enable-gui=no
181                         --without-x
182                         --disable-darwin
183                         --disable-luainterp
184                         --disable-perlinterp
185                         --disable-pythoninterp
186                         --disable-mzschemeinterp
187                         --disable-rubyinterp
188                         --disable-selinux
189                         --disable-tclinterp
190                         --disable-gpm
191                 )
192         else
193                 use debug && append-flags "-DDEBUG"
194
195                 myconf=(
196                         --with-features=huge
197                         $(use_enable sound canberra)
198                         $(use_enable acl)
199                         $(use_enable cscope)
200                         $(use_enable gpm)
201                         $(use_enable lua luainterp)
202                         $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
203                         $(use_with luajit)
204                         $(use_enable nls)
205                         $(use_enable perl perlinterp)
206                         $(use_enable python python3interp)
207                         $(use_with python python3-command $(type -P $(eselect python show --python3)))
208                         $(use_enable racket mzschemeinterp)
209                         $(use_enable ruby rubyinterp)
210                         $(use_enable selinux)
211                         $(use_enable tcl tclinterp)
212                         $(use_enable terminal)
213                 )
214
215                 # --with-features=huge forces on cscope even if we --disable it. We need
216                 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
217                 if ! use cscope; then
218                         sed -i -e \
219                                 '/# define FEAT_CSCOPE/d' src/feature.h || die "sed failed"
220                 fi
221
222                 # don't test USE=X here ... see bug #19115
223                 # but need to provide a way to link against X ... see bug #20093
224                 myconf+=(
225                         --enable-gui=no
226                         --disable-darwin
227                         $(use_with X x)
228                 )
229         fi
230
231         # let package manager strip binaries
232         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
233
234         # keep prefix env contained within the EPREFIX
235         use prefix && myconf+=( --without-local-dir )
236
237         econf \
238                 --with-modified-by=Gentoo-${PVR} \
239                 "${myconf[@]}"
240 }
241
242 src_compile() {
243         # The following allows emake to be used
244         emake -j1 -C src auto/osdef.h objects
245
246         emake
247 }
248
249 src_test() {
250         einfo
251         einfo "Starting vim tests. Several error messages will be shown"
252         einfo "while the tests run. This is normal behaviour and does not"
253         einfo "indicate a fault."
254         einfo
255         ewarn "If the tests fail, your terminal may be left in a strange"
256         ewarn "state. Usually, running 'reset' will fix this."
257         einfo
258
259         # Don't let vim talk to X
260         unset DISPLAY
261
262         emake -j1 -C src/testdir nongui
263 }
264
265 # Call eselect vi update with --if-unset
266 # to respect user's choice (bug 187449)
267 eselect_vi_update() {
268         einfo "Calling eselect vi update..."
269         eselect vi update --if-unset
270         eend $?
271 }
272
273 src_install() {
274         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
275
276         # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
277         #       managed by eselect-vi
278         dobin src/vim
279         dosym vim /usr/bin/vimdiff
280         dosym vim /usr/bin/rvim
281         dosym vim /usr/bin/rview
282         if use vim-pager ; then
283                 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
284                 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
285                 insinto ${vimfiles}/macros
286                 doins runtime/macros/manpager.sh
287                 fperms a+x ${vimfiles}/macros/manpager.sh
288         fi
289
290         domenu runtime/vim.desktop
291
292         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
293
294         # keep in sync with 'complete ... -F' list
295         bashcomp_alias vim ex vi view rvim rview vimdiff
296 }
297
298 pkg_postinst() {
299         # Update documentation tags (from vim-doc.eclass)
300         update_vim_helptags
301
302         # Call eselect vi update
303         eselect_vi_update
304
305         # update desktop file mime cache
306         xdg_desktop_database_update
307 }
308
309 pkg_postrm() {
310         # Update documentation tags (from vim-doc.eclass)
311         update_vim_helptags
312
313         # Call eselect vi update
314         eselect_vi_update
315
316         # update desktop file mime cache
317         xdg_desktop_database_update
318 }