app-editors: Remove *-fbsd KEYWORDS
[gentoo.git] / app-editors / gvim / gvim-8.1.1486.ebuild
1 # Copyright 1999-2019 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_5,3_6,3_7} )
7 PYTHON_REQ_USE="threads(+)"
8 USE_RUBY="ruby24 ruby25 ruby26"
9
10 inherit vim-doc flag-o-matic xdg-utils gnome2-utils bash-completion-r1 prefix python-single-r1 ruby-single
11
12 if [[ ${PV} == 9999* ]]; then
13         inherit git-r3
14         EGIT_REPO_URI="https://github.com/vim/vim.git"
15         EGIT_CHECKOUT_DIR=${WORKDIR}/vim-${PV}
16 else
17         SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> vim-${PV}.tar.gz
18                 https://dev.gentoo.org/~radhermit/vim/vim-8.0.0938-gentoo-patches.tar.bz2"
19         KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ppc ppc64 s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~x86-solaris"
20 fi
21
22 DESCRIPTION="GUI version of the Vim text editor"
23 HOMEPAGE="https://vim.sourceforge.io/ https://github.com/vim/vim"
24
25 SLOT="0"
26 LICENSE="vim"
27 IUSE="acl aqua cscope debug gtk gtk2 lua luajit motif neXt netbeans nls perl python racket ruby selinux session tcl"
28 REQUIRED_USE="
29         python? ( ${PYTHON_REQUIRED_USE} )
30 "
31
32 RDEPEND="
33         >=app-eselect/eselect-vi-1.1
34         >=sys-libs/ncurses-5.2-r2:0=
35         x11-libs/libICE
36         x11-libs/libSM
37         x11-libs/libXext
38         x11-libs/libXt
39         acl? ( kernel_linux? ( sys-apps/acl ) )
40         !aqua? (
41                 gtk? (
42                         x11-libs/gtk+:3
43                         x11-libs/libXft
44                 )
45                 !gtk? (
46                         gtk2? (
47                                 >=x11-libs/gtk+-2.6:2
48                                 x11-libs/libXft
49                         )
50                         !gtk2? (
51                                 motif? ( >=x11-libs/motif-2.3:0 )
52                                 !motif? (
53                                         neXt? ( x11-libs/neXtaw )
54                                         !neXt? ( x11-libs/libXaw )
55                                 )
56                         )
57                 )
58         )
59         cscope? ( dev-util/cscope )
60         lua? (
61                 luajit? ( dev-lang/luajit:2= )
62                 !luajit? ( dev-lang/lua:0[deprecated] )
63         )
64         nls? ( virtual/libintl )
65         perl? ( dev-lang/perl:= )
66         python? ( ${PYTHON_DEPS} )
67         racket? ( dev-scheme/racket )
68         ruby? ( ${RUBY_DEPS} )
69         selinux? ( sys-libs/libselinux )
70         session? ( x11-libs/libSM )
71         tcl? ( dev-lang/tcl:0= )
72 "
73 DEPEND="${RDEPEND}
74         sys-devel/autoconf
75         virtual/pkgconfig
76         nls? ( sys-devel/gettext )
77 "
78 # temporarily use PDEPEND to allow upgrades past icon file collision, bug #673880
79 PDEPEND="~app-editors/vim-core-${PV}"
80
81 # various failures (bugs #630042 and #682320)
82 RESTRICT="test"
83
84 S=${WORKDIR}/vim-${PV}
85
86 pkg_setup() {
87         # people with broken alphabets run into trouble. bug 82186.
88         unset LANG LC_ALL
89         export LC_COLLATE="C"
90
91         # Gnome sandbox silliness. bug #114475.
92         mkdir -p "${T}"/home || die
93         export HOME="${T}"/home
94
95         use python && python-single-r1_pkg_setup
96 }
97
98 src_prepare() {
99         if [[ ${PV} != 9999* ]]; then
100                 # Gentoo patches to fix runtime issues, cross-compile errors, etc
101                 eapply "${WORKDIR}"/patches/
102         fi
103
104         # Fixup a script to use awk instead of nawk
105         sed -i -e \
106                 '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' \
107                 "${S}"/runtime/tools/mve.awk || die "mve.awk sed failed"
108
109         # Read vimrc and gvimrc from /etc/vim
110         echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' \
111             >> "${S}"/src/feature.h || die "echo failed"
112         echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' \
113             >> "${S}"/src/feature.h || die "echo failed"
114
115         # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
116         # Hopefully this pattern won't break for a while at least.
117         # This fixes bug 29398 (27 Sep 2003 agriffis)
118         sed -i -e \
119                 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
120                 "${S}"/runtime/doc/syntax.txt \
121                 "${S}"/runtime/doc/tagsrch.txt \
122                 "${S}"/runtime/doc/usr_29.txt \
123                 "${S}"/runtime/menu.vim \
124                 "${S}"/src/configure.ac || die 'sed failed'
125
126         # Don't be fooled by /usr/include/libc.h.  When found, vim thinks
127         # this is NeXT, but it's actually just a file in dev-libs/9libs
128         # This fixes bug 43885 (20 Mar 2004 agriffis)
129         sed -i -e \
130                 's/ libc\.h / /' "${S}"/src/configure.ac || die 'sed failed'
131
132         # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
133         # correctly. To avoid some really entertaining error messages about stuff
134         # which isn't even in the source file being invalid, we'll do some trickery
135         # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
136         find "${S}" -name '*.c' | while read c; do
137             echo >> "$c" || die "echo failed"
138         done
139
140         # Try to avoid sandbox problems. Bug #114475.
141         if [[ -d "${S}"/src/po ]]; then
142                 sed -i -e \
143                         '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
144                         "${S}"/src/po/Makefile || die
145         fi
146
147         cp -v "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk || die "cp failed"
148
149         # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
150         sed -i -e \
151                 "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
152                 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
153
154         eapply_user
155 }
156
157 src_configure() {
158         local myconf=()
159
160         # Fix bug 37354: Disallow -funroll-all-loops on amd64
161         # Bug 57859 suggests that we want to do this for all archs
162         filter-flags -funroll-all-loops
163
164         # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
165         # everyone since previous flag filtering bugs have turned out to affect
166         # multiple archs...
167         replace-flags -O3 -O2
168
169         # Fix bug 18245: Prevent "make" from the following chain:
170         # (1) Notice configure.ac is newer than auto/configure
171         # (2) Rebuild auto/configure
172         # (3) Notice auto/configure is newer than auto/config.mk
173         # (4) Run ./configure (with wrong args) to remake auto/config.mk
174         sed -i -e \
175                 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
176         rm -v src/auto/configure || die "rm failed"
177         emake -j1 -C src autoconf
178
179         # This should fix a sandbox violation (see bug 24447). The hvc
180         # things are for ppc64, see bug 86433.
181         local file
182         for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc*; do
183                 if [[ -e ${file} ]]; then
184                         addwrite $file
185                 fi
186         done
187
188         use debug && append-flags "-DDEBUG"
189
190         myconf=(
191                 --with-features=huge
192                 --disable-gpm
193                 --with-gnome=no
194                 $(use_enable acl)
195                 $(use_enable cscope)
196                 $(use_enable lua luainterp)
197                 $(use_with luajit)
198                 $(use_enable netbeans)
199                 $(use_enable nls)
200                 $(use_enable perl perlinterp)
201                 $(use_enable python pythoninterp)
202                 $(use_enable python python3interp)
203                 $(use_with python python-command $(type -P $(eselect python show --python2)))
204                 $(use_with python python3-command $(type -P $(eselect python show --python3)))
205                 $(use_enable racket mzschemeinterp)
206                 $(use_enable ruby rubyinterp)
207                 $(use_enable selinux)
208                 $(use_enable session xsmp)
209                 $(use_enable tcl tclinterp)
210         )
211
212         # --with-features=huge forces on cscope even if we --disable it. We need
213         # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
214         if ! use cscope; then
215                 sed -i -e \
216                         '/# define FEAT_CSCOPE/d' src/feature.h || die "couldn't disable cscope"
217         fi
218
219         # gvim's GUI preference order is as follows:
220         # aqua                         CARBON (not tested)
221         # -aqua gtk                    GTK3
222         # -aqua -gtk gtk2              GTK2
223         # -aqua -gtk -gtk motif        MOTIF
224         # -aqua -gtk -gtk -motif neXt  NEXTAW
225         # -aqua -gtk -gtk -motif -neXt ATHENA
226         echo ; echo
227         if use aqua; then
228                 einfo "Building gvim with the Carbon GUI"
229                 myconf+=(
230                         --enable-darwin
231                         --enable-gui=carbon
232                 )
233         elif use gtk; then
234                 myconf+=( --enable-gtk3-check )
235                 einfo "Building gvim with the gtk+-3 GUI"
236                 myconf+=( --enable-gui=gtk3 )
237         elif use gtk2; then
238                 myconf+=( --enable-gtk2-check )
239                 einfo "Building gvim with the gtk+-2 GUI"
240                 myconf+=( --enable-gui=gtk2 )
241         elif use motif; then
242                 einfo "Building gvim with the MOTIF GUI"
243                 myconf+=( --enable-gui=motif )
244         elif use neXt; then
245                 einfo "Building gvim with the neXtaw GUI"
246                 myconf+=( --enable-gui=nextaw )
247         else
248                 einfo "Building gvim with the Athena GUI"
249                 myconf+=( --enable-gui=athena )
250         fi
251         echo ; echo
252
253         # let package manager strip binaries
254         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
255
256         # keep prefix env contained within the EPREFIX
257         use prefix && myconf+=( --without-local-dir )
258
259         if [[ ${CHOST} == *-interix* ]]; then
260                 # avoid finding of this function, to avoid having to patch either
261                 # configure or the source, which would be much more hackish.
262                 # after all vim does it right, only interix is badly broken (again)
263                 export ac_cv_func_sigaction=no
264         fi
265
266         econf \
267                 --with-modified-by=Gentoo-${PVR} \
268                 --with-vim-name=gvim \
269                 --with-x \
270                 "${myconf[@]}"
271 }
272
273 src_compile() {
274         # The following allows emake to be used
275         emake -j1 -C src auto/osdef.h objects
276
277         emake
278 }
279
280 src_test() {
281         einfo
282         einfo "Starting vim tests. Several error messages will be shown"
283         einfo "while the tests run. This is normal behaviour and does not"
284         einfo "indicate a fault."
285         einfo
286         ewarn "If the tests fail, your terminal may be left in a strange"
287         ewarn "state. Usually, running 'reset' will fix this."
288         einfo
289
290         # Don't let vim talk to X
291         unset DISPLAY
292
293         # Make gvim not try to connect to X. See :help gui-x11-start in vim for how
294         # this evil trickery works.
295         ln -s "${S}"/src/gvim "${S}"/src/testvim || die
296
297         # Make sure our VIMPROG is used.
298         sed -i -e 's:\.\./vim:../testvim:' src/testdir/test49.vim || die
299
300         # Don't do additional GUI tests.
301         emake -j1 VIMPROG=../testvim -C src/testdir nongui
302 }
303
304 # Call eselect vi update with --if-unset
305 # to respect user's choice (bug 187449)
306 eselect_vi_update() {
307         einfo "Calling eselect vi update..."
308         eselect vi update --if-unset
309         eend $?
310 }
311
312 src_install() {
313         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
314
315         dobin src/gvim
316         dosym gvim /usr/bin/gvimdiff
317         dosym gvim /usr/bin/evim
318         dosym gvim /usr/bin/eview
319         dosym gvim /usr/bin/gview
320         dosym gvim /usr/bin/rgvim
321         dosym gvim /usr/bin/rgview
322
323         emake -C src DESTDIR="${D}" DATADIR="${EPREFIX}"/usr/share install-icons
324
325         dodir /usr/share/man/man1
326         echo ".so vim.1" > "${ED}"/usr/share/man/man1/gvim.1 || die "echo failed"
327         echo ".so vim.1" > "${ED}"/usr/share/man/man1/gview.1 || die "echo failed"
328         echo ".so vimdiff.1" > "${ED}"/usr/share/man/man1/gvimdiff.1 || \
329                 die "echo failed"
330
331         insinto /etc/vim
332         newins "${FILESDIR}"/gvimrc-r1 gvimrc
333         eprefixify "${ED}"/etc/vim/gvimrc
334
335         # bash completion script, bug #79018.
336         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
337
338         # don't install vim desktop file
339         rm -v "${ED}"/usr/share/applications/vim.desktop || die "failed to remove vim.desktop"
340 }
341
342 pkg_postinst() {
343         # Update documentation tags (from vim-doc.eclass)
344         update_vim_helptags
345
346         # Update fdo mime stuff, bug #78394
347         xdg_desktop_database_update
348
349         # Update icon cache
350         gnome2_icon_cache_update
351
352         # Call eselect vi update
353         eselect_vi_update
354 }
355
356 pkg_postrm() {
357         # Update documentation tags (from vim-doc.eclass)
358         update_vim_helptags
359
360         # Update fdo mime stuff, bug #78394
361         xdg_desktop_database_update
362
363         # Update icon cache
364         gnome2_icon_cache_update
365
366         # Call eselect vi update
367         eselect_vi_update
368 }