*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / app-editors / vim / vim-8.1.1486.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 VIM_VERSION="8.1"
6 PYTHON_COMPAT=( python{2_7,3_6,3_7} )
7 PYTHON_REQ_USE="threads(+)"
8 USE_RUBY="ruby24 ruby25 ruby26"
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/~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"
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 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         tcl? ( dev-lang/tcl:0= )
51         X? ( x11-libs/libXt )
52 "
53
54 DEPEND="
55         ${RDEPEND}
56         sys-devel/autoconf
57         nls? ( sys-devel/gettext )
58 "
59
60 pkg_setup() {
61         # people with broken alphabets run into trouble. bug 82186.
62         unset LANG LC_ALL
63         export LC_COLLATE="C"
64
65         # Gnome sandbox silliness. bug #114475.
66         mkdir -p "${T}"/home || die "mkdir failed"
67         export HOME="${T}"/home
68
69         use python && python-single-r1_pkg_setup
70 }
71
72 src_prepare() {
73         if [[ ${PV} != 9999* ]] ; then
74                 # Gentoo patches to fix runtime issues, cross-compile errors, etc
75                 eapply "${WORKDIR}"/patches/
76         fi
77
78         # Fixup a script to use awk instead of nawk
79         sed -i -e \
80                 '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' \
81                 "${S}"/runtime/tools/mve.awk || die "mve.awk sed failed"
82
83         # Read vimrc and gvimrc from /etc/vim
84         echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' \
85                 >> "${S}"/src/feature.h || die "echo failed"
86         echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' \
87                 >> "${S}"/src/feature.h || die "echo failed"
88
89         # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
90         # Hopefully this pattern won't break for a while at least.
91         # This fixes bug 29398 (27 Sep 2003 agriffis)
92         sed -i -e \
93                 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
94                 "${S}"/runtime/doc/syntax.txt \
95                 "${S}"/runtime/doc/tagsrch.txt \
96                 "${S}"/runtime/doc/usr_29.txt \
97                 "${S}"/runtime/menu.vim \
98                 "${S}"/src/configure.ac || die 'sed failed'
99
100         # Don't be fooled by /usr/include/libc.h.  When found, vim thinks
101         # this is NeXT, but it's actually just a file in dev-libs/9libs
102         # This fixes bug 43885 (20 Mar 2004 agriffis)
103         sed -i -e \
104                 's/ libc\.h / /' \
105                 "${S}"/src/configure.ac || die 'sed failed'
106
107         # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
108         # correctly. To avoid some really entertaining error messages about stuff
109         # which isn't even in the source file being invalid, we'll do some trickery
110         # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
111         find "${S}" -name '*.c' | while read c; do
112             echo >> "$c" || die "echo failed"
113         done
114
115         # conditionally make the manpager.sh script
116         if use vim-pager; then
117                 cat > "${S}"/runtime/macros/manpager.sh <<-_EOF_ || die "cat EOF failed"
118                         #!/bin/sh
119                         sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
120                                         vim \\
121                                                 -c 'let no_plugin_maps = 1' \\
122                                                 -c 'set nolist nomod ft=man ts=8' \\
123                                                 -c 'let g:showmarks_enable=0' \\
124                                                 -c 'runtime! macros/less.vim' -
125                         _EOF_
126         fi
127
128         # Try to avoid sandbox problems. Bug #114475.
129         if [[ -d "${S}"/src/po ]]; then
130                 sed -i -e \
131                         '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
132                         "${S}"/src/po/Makefile || die "sed failed"
133         fi
134
135         cp -v "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk || die "cp failed"
136
137         sed -i -e \
138                 "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
139                 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
140
141         eapply_user
142 }
143
144 src_configure() {
145         local myconf=()
146
147         # Fix bug 37354: Disallow -funroll-all-loops on amd64
148         # Bug 57859 suggests that we want to do this for all archs
149         filter-flags -funroll-all-loops
150
151         # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
152         # everyone since previous flag filtering bugs have turned out to affect
153         # multiple archs...
154         replace-flags -O3 -O2
155
156         # Fix bug 18245: Prevent "make" from the following chain:
157         # (1) Notice configure.ac is newer than auto/configure
158         # (2) Rebuild auto/configure
159         # (3) Notice auto/configure is newer than auto/config.mk
160         # (4) Run ./configure (with wrong args) to remake auto/config.mk
161         sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
162         rm src/auto/configure || die "rm failed"
163         emake -j1 -C src autoconf
164
165         # This should fix a sandbox violation (see bug 24447). The hvc
166         # things are for ppc64, see bug 86433.
167         for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc*; do
168                 if [[ -e "${file}" ]]; then
169                         addwrite $file
170                 fi
171         done
172
173         if use minimal; then
174                 myconf=(
175                         --with-features=tiny
176                         --disable-nls
177                         --disable-acl
178                         --enable-gui=no
179                         --without-x
180                         --disable-darwin
181                         --disable-luainterp
182                         --disable-perlinterp
183                         --disable-pythoninterp
184                         --disable-mzschemeinterp
185                         --disable-rubyinterp
186                         --disable-selinux
187                         --disable-tclinterp
188                         --disable-gpm
189                 )
190         else
191                 use debug && append-flags "-DDEBUG"
192
193                 myconf=(
194                         --with-features=huge
195                         $(use_enable acl)
196                         $(use_enable cscope)
197                         $(use_enable gpm)
198                         $(use_enable lua luainterp)
199                         $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
200                         $(use_with luajit)
201                         $(use_enable nls)
202                         $(use_enable perl perlinterp)
203                         $(use_enable python pythoninterp)
204                         $(use_enable python python3interp)
205                         $(use_with python python-command $(type -P $(eselect python show --python2)))
206                         $(use_with python python3-command $(type -P $(eselect python show --python3)))
207                         $(use_enable racket mzschemeinterp)
208                         $(use_enable ruby rubyinterp)
209                         $(use_enable selinux)
210                         $(use_enable tcl tclinterp)
211                         $(use_enable terminal)
212                 )
213
214                 # --with-features=huge forces on cscope even if we --disable it. We need
215                 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
216                 if ! use cscope; then
217                         sed -i -e \
218                                 '/# define FEAT_CSCOPE/d' src/feature.h || die "sed failed"
219                 fi
220
221                 # don't test USE=X here ... see bug #19115
222                 # but need to provide a way to link against X ... see bug #20093
223                 myconf+=(
224                         --enable-gui=no
225                         --disable-darwin
226                         $(use_with X x)
227                 )
228         fi
229
230         # let package manager strip binaries
231         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
232
233         # keep prefix env contained within the EPREFIX
234         use prefix && myconf+=( --without-local-dir )
235
236         econf \
237                 --with-modified-by=Gentoo-${PVR} \
238                 "${myconf[@]}"
239 }
240
241 src_compile() {
242         # The following allows emake to be used
243         emake -j1 -C src auto/osdef.h objects
244
245         emake
246 }
247
248 src_test() {
249         einfo
250         einfo "Starting vim tests. Several error messages will be shown"
251         einfo "while the tests run. This is normal behaviour and does not"
252         einfo "indicate a fault."
253         einfo
254         ewarn "If the tests fail, your terminal may be left in a strange"
255         ewarn "state. Usually, running 'reset' will fix this."
256         einfo
257
258         # Don't let vim talk to X
259         unset DISPLAY
260
261         emake -j1 -C src/testdir nongui
262 }
263
264 # Call eselect vi update with --if-unset
265 # to respect user's choice (bug 187449)
266 eselect_vi_update() {
267         einfo "Calling eselect vi update..."
268         eselect vi update --if-unset
269         eend $?
270 }
271
272 src_install() {
273         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
274
275         # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
276         #       managed by eselect-vi
277         dobin src/vim
278         dosym vim /usr/bin/vimdiff
279         dosym vim /usr/bin/rvim
280         dosym vim /usr/bin/rview
281         if use vim-pager ; then
282                 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
283                 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
284                 insinto ${vimfiles}/macros
285                 doins runtime/macros/manpager.sh
286                 fperms a+x ${vimfiles}/macros/manpager.sh
287         fi
288
289         domenu runtime/vim.desktop
290
291         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
292
293         # keep in sync with 'complete ... -F' list
294         bashcomp_alias vim ex vi view rvim rview vimdiff
295 }
296
297 pkg_postinst() {
298         # Update documentation tags (from vim-doc.eclass)
299         update_vim_helptags
300
301         # Call eselect vi update
302         eselect_vi_update
303
304         # update desktop file mime cache
305         xdg_desktop_database_update
306 }
307
308 pkg_postrm() {
309         # Update documentation tags (from vim-doc.eclass)
310         update_vim_helptags
311
312         # Call eselect vi update
313         eselect_vi_update
314
315         # update desktop file mime cache
316         xdg_desktop_database_update
317 }