dev-cpp/pangomm: stable 2.42.1 for hppa, bug #717144
[gentoo.git] / app-editors / gvim / gvim-8.2.0508.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 xdg-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/~zlogene/distfiles/app-editors/vim/vim-8.2.0360-gentoo-patches.tar.xz"
19         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~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 sound tcl"
28 REQUIRED_USE="
29         python? ( ${PYTHON_REQUIRED_USE} )
30 "
31
32 RDEPEND="
33         ~app-editors/vim-core-${PV}
34         >=app-eselect/eselect-vi-1.1
35         >=sys-libs/ncurses-5.2-r2:0=
36         x11-libs/libICE
37         x11-libs/libSM
38         x11-libs/libXext
39         x11-libs/libXt
40         acl? ( kernel_linux? ( sys-apps/acl ) )
41         !aqua? (
42                 gtk? (
43                         x11-libs/gtk+:3
44                         x11-libs/libXft
45                 )
46                 !gtk? (
47                         gtk2? (
48                                 >=x11-libs/gtk+-2.6:2
49                                 x11-libs/libXft
50                         )
51                         !gtk2? (
52                                 motif? ( >=x11-libs/motif-2.3:0 )
53                                 !motif? (
54                                         neXt? ( x11-libs/neXtaw )
55                                         !neXt? ( x11-libs/libXaw )
56                                 )
57                         )
58                 )
59         )
60         cscope? ( dev-util/cscope )
61         lua? (
62                 luajit? ( dev-lang/luajit:2= )
63                 !luajit? ( dev-lang/lua:0[deprecated] )
64         )
65         nls? ( virtual/libintl )
66         perl? ( dev-lang/perl:= )
67         python? ( ${PYTHON_DEPS} )
68         racket? ( dev-scheme/racket )
69         ruby? ( ${RUBY_DEPS} )
70         selinux? ( sys-libs/libselinux )
71         session? ( x11-libs/libSM )
72         sound? ( media-libs/libcanberra )
73         tcl? ( dev-lang/tcl:0= )
74 "
75 DEPEND="${RDEPEND}
76         sys-devel/autoconf
77         virtual/pkgconfig
78         nls? ( sys-devel/gettext )
79 "
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 sound canberra)
195                 $(use_enable acl)
196                 $(use_enable cscope)
197                 $(use_enable lua luainterp)
198                 $(use_with luajit)
199                 $(use_enable netbeans)
200                 $(use_enable nls)
201                 $(use_enable perl perlinterp)
202                 $(use_enable python python3interp)
203                 $(use_with python python3-command $(type -P $(eselect python show --python3)))
204                 $(use_enable racket mzschemeinterp)
205                 $(use_enable ruby rubyinterp)
206                 $(use_enable selinux)
207                 $(use_enable session xsmp)
208                 $(use_enable tcl tclinterp)
209         )
210
211         # --with-features=huge forces on cscope even if we --disable it. We need
212         # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
213         if ! use cscope; then
214                 sed -i -e \
215                         '/# define FEAT_CSCOPE/d' src/feature.h || die "couldn't disable cscope"
216         fi
217
218         # gvim's GUI preference order is as follows:
219         # aqua                         CARBON (not tested)
220         # -aqua gtk                    GTK3
221         # -aqua -gtk gtk2              GTK2
222         # -aqua -gtk -gtk motif        MOTIF
223         # -aqua -gtk -gtk -motif neXt  NEXTAW
224         # -aqua -gtk -gtk -motif -neXt ATHENA
225         echo ; echo
226         if use aqua; then
227                 einfo "Building gvim with the Carbon GUI"
228                 myconf+=(
229                         --enable-darwin
230                         --enable-gui=carbon
231                 )
232         elif use gtk; then
233                 myconf+=( --enable-gtk3-check )
234                 einfo "Building gvim with the gtk+-3 GUI"
235                 myconf+=( --enable-gui=gtk3 )
236         elif use gtk2; then
237                 myconf+=( --enable-gtk2-check )
238                 einfo "Building gvim with the gtk+-2 GUI"
239                 myconf+=( --enable-gui=gtk2 )
240         elif use motif; then
241                 einfo "Building gvim with the MOTIF GUI"
242                 myconf+=( --enable-gui=motif )
243         elif use neXt; then
244                 einfo "Building gvim with the neXtaw GUI"
245                 myconf+=( --enable-gui=nextaw )
246         else
247                 einfo "Building gvim with the Athena GUI"
248                 myconf+=( --enable-gui=athena )
249         fi
250         echo ; echo
251
252         # let package manager strip binaries
253         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
254
255         # keep prefix env contained within the EPREFIX
256         use prefix && myconf+=( --without-local-dir )
257
258         if [[ ${CHOST} == *-interix* ]]; then
259                 # avoid finding of this function, to avoid having to patch either
260                 # configure or the source, which would be much more hackish.
261                 # after all vim does it right, only interix is badly broken (again)
262                 export ac_cv_func_sigaction=no
263         fi
264
265         econf \
266                 --with-modified-by=Gentoo-${PVR} \
267                 --with-vim-name=gvim \
268                 --with-x \
269                 "${myconf[@]}"
270 }
271
272 src_compile() {
273         # The following allows emake to be used
274         emake -j1 -C src auto/osdef.h objects
275
276         emake
277 }
278
279 src_test() {
280         einfo
281         einfo "Starting vim tests. Several error messages will be shown"
282         einfo "while the tests run. This is normal behaviour and does not"
283         einfo "indicate a fault."
284         einfo
285         ewarn "If the tests fail, your terminal may be left in a strange"
286         ewarn "state. Usually, running 'reset' will fix this."
287         einfo
288
289         # Don't let vim talk to X
290         unset DISPLAY
291
292         # Make gvim not try to connect to X. See :help gui-x11-start in vim for how
293         # this evil trickery works.
294         ln -s "${S}"/src/gvim "${S}"/src/testvim || die
295
296         # Make sure our VIMPROG is used.
297         sed -i -e 's:\.\./vim:../testvim:' src/testdir/test49.vim || die
298
299         # Don't do additional GUI tests.
300         emake -j1 VIMPROG=../testvim -C src/testdir nongui
301 }
302
303 # Call eselect vi update with --if-unset
304 # to respect user's choice (bug 187449)
305 eselect_vi_update() {
306         einfo "Calling eselect vi update..."
307         eselect vi update --if-unset
308         eend $?
309 }
310
311 src_install() {
312         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
313
314         dobin src/gvim
315         dosym gvim /usr/bin/gvimdiff
316         dosym gvim /usr/bin/evim
317         dosym gvim /usr/bin/eview
318         dosym gvim /usr/bin/gview
319         dosym gvim /usr/bin/rgvim
320         dosym gvim /usr/bin/rgview
321
322         emake -C src DESTDIR="${D}" DATADIR="${EPREFIX}"/usr/share install-icons
323
324         dodir /usr/share/man/man1
325         echo ".so vim.1" > "${ED}"/usr/share/man/man1/gvim.1 || die "echo failed"
326         echo ".so vim.1" > "${ED}"/usr/share/man/man1/gview.1 || die "echo failed"
327         echo ".so vimdiff.1" > "${ED}"/usr/share/man/man1/gvimdiff.1 || \
328                 die "echo failed"
329
330         insinto /etc/vim
331         newins "${FILESDIR}"/gvimrc-r1 gvimrc
332         eprefixify "${ED}"/etc/vim/gvimrc
333
334         # bash completion script, bug #79018.
335         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
336
337         # don't install vim desktop file
338         rm -v "${ED}"/usr/share/applications/vim.desktop || die "failed to remove vim.desktop"
339 }
340
341 pkg_postinst() {
342         # update documentation tags (from vim-doc.eclass)
343         update_vim_helptags
344
345         # update fdo mime stuff, bug #78394
346         xdg_desktop_database_update
347
348         # update icon cache
349         xdg_icon_cache_update
350
351         # call eselect vi update
352         eselect_vi_update
353 }
354
355 pkg_postrm() {
356         # update documentation tags (from vim-doc.eclass)
357         update_vim_helptags
358
359         # update fdo mime stuff, bug #78394
360         xdg_desktop_database_update
361
362         # update icon cache
363         xdg_icon_cache_update
364
365         # call eselect vi update
366         eselect_vi_update
367 }