1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{6,7,8} )
7 PYTHON_REQ_USE="threads(+)"
8 USE_RUBY="ruby24 ruby25 ruby26 ruby27"
10 inherit vim-doc flag-o-matic xdg-utils bash-completion-r1 prefix python-single-r1 ruby-single
12 if [[ ${PV} == 9999* ]]; then
14 EGIT_REPO_URI="https://github.com/vim/vim.git"
15 EGIT_CHECKOUT_DIR=${WORKDIR}/vim-${PV}
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"
22 DESCRIPTION="GUI version of the Vim text editor"
23 HOMEPAGE="https://vim.sourceforge.io/ https://github.com/vim/vim"
27 IUSE="acl aqua cscope debug gtk gtk2 lua luajit motif neXt netbeans nls perl python racket ruby selinux session sound tcl"
29 python? ( ${PYTHON_REQUIRED_USE} )
33 ~app-editors/vim-core-${PV}
34 >=app-eselect/eselect-vi-1.1
35 >=sys-libs/ncurses-5.2-r2:0=
40 acl? ( kernel_linux? ( sys-apps/acl ) )
52 motif? ( >=x11-libs/motif-2.3:0 )
54 neXt? ( x11-libs/neXtaw )
55 !neXt? ( x11-libs/libXaw )
60 cscope? ( dev-util/cscope )
62 luajit? ( dev-lang/luajit:2= )
63 !luajit? ( dev-lang/lua:0[deprecated] )
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= )
78 nls? ( sys-devel/gettext )
81 # various failures (bugs #630042 and #682320)
84 S=${WORKDIR}/vim-${PV}
87 # people with broken alphabets run into trouble. bug 82186.
91 # Gnome sandbox silliness. bug #114475.
92 mkdir -p "${T}"/home || die
93 export HOME="${T}"/home
95 use python && python-single-r1_pkg_setup
99 if [[ ${PV} != 9999* ]]; then
100 # Gentoo patches to fix runtime issues, cross-compile errors, etc
101 eapply "${WORKDIR}"/patches/
104 # Fixup a script to use awk instead of nawk
106 '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' \
107 "${S}"/runtime/tools/mve.awk || die "mve.awk sed failed"
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"
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)
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'
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)
130 's/ libc\.h / /' "${S}"/src/configure.ac || die 'sed failed'
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"
140 # Try to avoid sandbox problems. Bug #114475.
141 if [[ -d "${S}"/src/po ]]; then
143 '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
144 "${S}"/src/po/Makefile || die
147 cp -v "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk || die "cp failed"
149 # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
151 "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
152 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
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
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
167 replace-flags -O3 -O2
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
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
179 # This should fix a sandbox violation (see bug 24447). The hvc
180 # things are for ppc64, see bug 86433.
182 for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc*; do
183 if [[ -e ${file} ]]; then
188 use debug && append-flags "-DDEBUG"
194 $(use_enable sound canberra)
197 $(use_enable lua luainterp)
199 $(use_enable netbeans)
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)
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
215 '/# define FEAT_CSCOPE/d' src/feature.h || die "couldn't disable cscope"
218 # gvim's GUI preference order is as follows:
219 # aqua CARBON (not tested)
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
227 einfo "Building gvim with the Carbon GUI"
233 myconf+=( --enable-gtk3-check )
234 einfo "Building gvim with the gtk+-3 GUI"
235 myconf+=( --enable-gui=gtk3 )
237 myconf+=( --enable-gtk2-check )
238 einfo "Building gvim with the gtk+-2 GUI"
239 myconf+=( --enable-gui=gtk2 )
241 einfo "Building gvim with the MOTIF GUI"
242 myconf+=( --enable-gui=motif )
244 einfo "Building gvim with the neXtaw GUI"
245 myconf+=( --enable-gui=nextaw )
247 einfo "Building gvim with the Athena GUI"
248 myconf+=( --enable-gui=athena )
252 # let package manager strip binaries
253 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
255 # keep prefix env contained within the EPREFIX
256 use prefix && myconf+=( --without-local-dir )
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
266 --with-modified-by=Gentoo-${PVR} \
267 --with-vim-name=gvim \
273 # The following allows emake to be used
274 emake -j1 -C src auto/osdef.h objects
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."
285 ewarn "If the tests fail, your terminal may be left in a strange"
286 ewarn "state. Usually, running 'reset' will fix this."
289 # Don't let vim talk to X
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
296 # Make sure our VIMPROG is used.
297 sed -i -e 's:\.\./vim:../testvim:' src/testdir/test49.vim || die
299 # Don't do additional GUI tests.
300 emake -j1 VIMPROG=../testvim -C src/testdir nongui
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
312 local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
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
322 emake -C src DESTDIR="${D}" DATADIR="${EPREFIX}"/usr/share install-icons
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 || \
331 newins "${FILESDIR}"/gvimrc-r1 gvimrc
332 eprefixify "${ED}"/etc/vim/gvimrc
334 # bash completion script, bug #79018.
335 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
337 # don't install vim desktop file
338 rm -v "${ED}"/usr/share/applications/vim.desktop || die "failed to remove vim.desktop"
342 # update documentation tags (from vim-doc.eclass)
345 # update fdo mime stuff, bug #78394
346 xdg_desktop_database_update
349 xdg_icon_cache_update
351 # call eselect vi update
356 # update documentation tags (from vim-doc.eclass)
359 # update fdo mime stuff, bug #78394
360 xdg_desktop_database_update
363 xdg_icon_cache_update
365 # call eselect vi update