1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
9 inherit eutils vim-doc flag-o-matic fdo-mime versionator bash-completion-r1 prefix python-r1
13 if [[ ${PV} == 9999* ]] ; then
15 EGIT_REPO_URI="https://github.com/vim/vim.git"
16 EGIT_CHECKOUT_DIR=${WORKDIR}/vim-${MY_PV}
18 SRC_URI="https://github.com/vim/vim/archive/v${MY_PV}.tar.gz -> vim-${PV}.tar.gz
19 https://dev.gentoo.org/~radhermit/vim/vim-7.4.542-gentoo-patches.tar.bz2"
20 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~x86-solaris"
23 DESCRIPTION="GUI version of the Vim text editor"
24 HOMEPAGE="http://www.vim.org/"
28 IUSE="acl aqua cscope debug gnome gtk lua luajit motif neXt netbeans nls perl python racket ruby selinux session tcl"
32 || ( $(python_gen_useflags '*') )
33 ?? ( $(python_gen_useflags 'python2*') )
34 ?? ( $(python_gen_useflags 'python3*') )
39 ~app-editors/vim-core-${PV}
40 >=app-eselect/eselect-vi-1.1
41 >=sys-libs/ncurses-5.2-r2
44 acl? ( kernel_linux? ( sys-apps/acl ) )
49 gnome? ( >=gnome-base/libgnomeui-2.6 )
52 motif? ( >=x11-libs/motif-2.3:0 )
54 neXt? ( x11-libs/neXtaw )
55 !neXt? ( x11-libs/libXaw )
59 cscope? ( dev-util/cscope )
61 luajit? ( dev-lang/luajit:2= )
62 !luajit? ( dev-lang/lua:0[deprecated] )
64 nls? ( virtual/libintl )
65 perl? ( dev-lang/perl:= )
66 python? ( ${PYTHON_DEPS} )
67 racket? ( dev-scheme/racket )
68 ruby? ( || ( dev-lang/ruby:2.2 dev-lang/ruby:2.1 dev-lang/ruby:2.0 ) )
69 selinux? ( sys-libs/libselinux )
70 session? ( x11-libs/libSM )
71 tcl? ( dev-lang/tcl:0= )
77 nls? ( sys-devel/gettext )
80 S=${WORKDIR}/vim-${MY_PV}
83 # people with broken alphabets run into trouble. bug 82186.
87 # Gnome sandbox silliness. bug #114475.
89 export HOME="${T}"/home
93 if [[ ${PV} != 9999* ]] ; then
94 if [[ -d "${WORKDIR}"/patches/ ]]; then
95 # Gentoo patches to fix runtime issues, cross-compile errors, etc
96 EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" \
97 epatch "${WORKDIR}"/patches/
101 # Fixup a script to use awk instead of nawk
102 sed -i '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' "${S}"/runtime/tools/mve.awk \
103 || die "mve.awk sed failed"
105 # Read vimrc and gvimrc from /etc/vim
106 echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h
107 echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h
109 # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
110 # Hopefully this pattern won't break for a while at least.
111 # This fixes bug 29398 (27 Sep 2003 agriffis)
112 sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
113 "${S}"/runtime/doc/syntax.txt \
114 "${S}"/runtime/doc/tagsrch.txt \
115 "${S}"/runtime/doc/usr_29.txt \
116 "${S}"/runtime/menu.vim \
117 "${S}"/src/configure.in || die 'sed failed'
119 # Don't be fooled by /usr/include/libc.h. When found, vim thinks
120 # this is NeXT, but it's actually just a file in dev-libs/9libs
121 # This fixes bug 43885 (20 Mar 2004 agriffis)
122 sed -i 's/ libc\.h / /' "${S}"/src/configure.in || die 'sed failed'
124 # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
125 # correctly. To avoid some really entertaining error messages about stuff
126 # which isn't even in the source file being invalid, we'll do some trickery
127 # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
128 find "${S}" -name '*.c' | while read c ; do echo >> "$c" ; done
130 # Try to avoid sandbox problems. Bug #114475.
131 if [[ -d "${S}"/src/po ]] ; then
132 sed -i '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
133 "${S}"/src/po/Makefile
136 if version_is_at_least 7.3.122 ; then
137 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
140 # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
141 if version_is_at_least 7.3 ; then
142 sed -i "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
143 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
152 # Fix bug 37354: Disallow -funroll-all-loops on amd64
153 # Bug 57859 suggests that we want to do this for all archs
154 filter-flags -funroll-all-loops
156 # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
157 # everyone since previous flag filtering bugs have turned out to affect
159 replace-flags -O3 -O2
161 # Fix bug 18245: Prevent "make" from the following chain:
162 # (1) Notice configure.in is newer than auto/configure
163 # (2) Rebuild auto/configure
164 # (3) Notice auto/configure is newer than auto/config.mk
165 # (4) Run ./configure (with wrong args) to remake auto/config.mk
166 sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
167 rm -f src/auto/configure
168 emake -j1 -C src autoconf
170 # This should fix a sandbox violation (see bug 24447). The hvc
171 # things are for ppc64, see bug 86433.
172 for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc* ; do
173 [[ -e ${file} ]] && addwrite $file
176 use debug && append-flags "-DDEBUG"
184 $(use_enable lua luainterp)
186 $(use_enable netbeans)
188 $(use_enable perl perlinterp)
189 $(use_enable racket mzschemeinterp)
190 $(use_enable ruby rubyinterp)
191 $(use_enable selinux)
192 $(use_enable session xsmp)
193 $(use_enable tcl tclinterp)
200 [[ ${EPYTHON} == python3* ]] && v=3
202 --enable-python${v}interp
203 vi_cv_path_python${v}="${PYTHON}"
207 python_foreach_impl py_add_interp
210 --disable-pythoninterp
211 --disable-python3interp
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 '/# define FEAT_CSCOPE/d' src/feature.h || \
219 die "couldn't disable cscope"
222 # gvim's GUI preference order is as follows:
223 # aqua CARBON (not tested)
224 # -aqua gtk gnome GNOME2
225 # -aqua gtk -gnome GTK2
226 # -aqua -gtk motif MOTIF
227 # -aqua -gtk -motif neXt NEXTAW
228 # -aqua -gtk -motif -neXt ATHENA
231 einfo "Building gvim with the Carbon GUI"
237 myconf+=( --enable-gtk2-check )
239 einfo "Building gvim with the Gnome 2 GUI"
240 myconf+=( --enable-gui=gnome2 )
242 einfo "Building gvim with the gtk+-2 GUI"
243 myconf+=( --enable-gui=gtk2 )
245 elif use motif ; then
246 einfo "Building gvim with the MOTIF GUI"
247 myconf+=( --enable-gui=motif )
249 einfo "Building gvim with the neXtaw GUI"
250 myconf+=( --enable-gui=nextaw )
252 einfo "Building gvim with the Athena GUI"
253 myconf+=( --enable-gui=athena )
257 # Let Portage do the stripping. Some people like that.
258 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
260 # Keep Gentoo Prefix env contained within the EPREFIX
261 use prefix && myconf+=( --without-local-dir )
263 if [[ ${CHOST} == *-interix* ]]; then
264 # avoid finding of this function, to avoid having to patch either
265 # configure or the source, which would be much more hackish.
266 # after all vim does it right, only interix is badly broken (again)
267 export ac_cv_func_sigaction=no
271 --with-modified-by=Gentoo-${PVR} \
272 --with-vim-name=gvim \
278 # The following allows emake to be used
279 emake -j1 -C src auto/osdef.h objects
286 einfo "Starting vim tests. Several error messages will be shown"
287 einfo "while the tests run. This is normal behaviour and does not"
288 einfo "indicate a fault."
290 ewarn "If the tests fail, your terminal may be left in a strange"
291 ewarn "state. Usually, running 'reset' will fix this."
294 # Don't let vim talk to X
297 # We've got to call make test from within testdir, since the Makefiles
298 # don't pass through our VIMPROG argument
299 cd "${S}"/src/testdir
301 # Test 49 won't work inside a portage environment
302 einfo "Test 49 isn't sandbox-friendly, so it will be skipped."
303 sed -i 's~test49.out~~g' Makefile
305 # We don't want to rebuild vim before running the tests
306 sed -i 's,: \$(VIMPROG),: ,' Makefile
308 # Make gvim not try to connect to X. See :help gui-x11-start
309 # in vim for how this evil trickery works.
310 ln -s "${S}"/src/gvim "${S}"/src/testvim
312 # Don't try to do the additional GUI test
313 emake -j1 VIMPROG=../testvim nongui
316 # Make convenience symlinks, hopefully without stepping on toes. Some
317 # of these links are "owned" by the vim ebuild when it is installed,
318 # but they might be good for gvim as well (see bug 45828)
319 update_vim_symlinks() {
321 syms="vimdiff rvim rview"
322 einfo "Calling eselect vi update..."
323 # Call this with --if-unset to respect user's choice (bug 187449)
324 eselect vi update --if-unset
326 # Make or remove convenience symlink, vim -> gvim
327 if [[ -f "${EROOT}"/usr/bin/gvim ]]; then
328 ln -s gvim "${EROOT}"/usr/bin/vim 2>/dev/null
329 elif [[ -L "${EROOT}"/usr/bin/vim && ! -f "${EROOT}"/usr/bin/vim ]]; then
330 rm "${EROOT}"/usr/bin/vim
333 # Make or remove convenience symlinks to vim
334 if [[ -f "${EROOT}"/usr/bin/vim ]]; then
336 ln -s vim "${EROOT}"/usr/bin/${f} 2>/dev/null
340 if [[ -L "${EROOT}"/usr/bin/${f} && ! -f "${EROOT}"/usr/bin/${f} ]]; then
341 rm -f "${EROOT}"/usr/bin/${f}
346 # This will still break if you merge then remove the vi package,
347 # but there's only so much you can do, eh? Unfortunately we don't
348 # have triggers like are done in rpm-land.
352 local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
355 dosym gvim /usr/bin/gvimdiff
356 dosym gvim /usr/bin/evim
357 dosym gvim /usr/bin/eview
358 dosym gvim /usr/bin/gview
359 dosym gvim /usr/bin/rgvim
360 dosym gvim /usr/bin/rgview
362 dodir /usr/share/man/man1
363 echo ".so vim.1" > "${ED}"/usr/share/man/man1/gvim.1
364 echo ".so vim.1" > "${ED}"/usr/share/man/man1/gview.1
365 echo ".so vimdiff.1" > "${ED}"/usr/share/man/man1/gvimdiff.1
368 newins "${FILESDIR}"/gvimrc-r1 gvimrc
369 eprefixify "${ED}"/etc/vim/gvimrc
371 newmenu "${FILESDIR}"/gvim.desktop-r2 gvim.desktop
372 doicon "${FILESDIR}"/gvim.xpm
373 doicon -s scalable "${FILESDIR}"/gvim.svg
375 # bash completion script, bug #79018.
376 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
378 # We shouldn't be installing the ex or view man page symlinks, as they
379 # are managed by eselect-vi
380 rm -f "${ED}"/usr/share/man/man1/{ex,view}.1
384 # Update documentation tags (from vim-doc.eclass)
387 # Update fdo mime stuff, bug #78394
388 fdo-mime_mime_database_update
390 if [[ -z ${REPLACING_VERSIONS} ]] ; then
392 elog "Vim 7 includes an integrated spell checker. You need to install"
393 elog "word list files before you can use it. There are ebuilds for"
394 elog "some of these named app-vim/vim-spell-*. If your language of"
395 elog "choice is not included, please consult vim-spell.eclass for"
396 elog "instructions on how to make a package."
398 ewarn "Note that the English word lists are no longer installed by"
403 # Make convenience symlinks
408 # Update documentation tags (from vim-doc.eclass)
411 # Update fdo mime stuff, bug #78394
412 fdo-mime_mime_database_update
414 # Make convenience symlinks