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 python-r1
11 if [[ ${PV} == 9999* ]] ; then
13 EHG_REPO_URI="https://vim.googlecode.com/hg/"
16 VIM_ORG_PATCH="vim-${PV}.patch.xz"
17 SRC_URI="ftp://ftp.vim.org/pub/vim/unix/vim-${VIM_VERSION}.tar.bz2
18 https://dev.gentoo.org/~radhermit/vim/${VIM_ORG_PATCH}
19 https://dev.gentoo.org/~radhermit/vim/vim-7.4.542-gentoo-patches.tar.bz2"
20 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
23 DESCRIPTION="Vim, an improved vi-style text editor"
24 HOMEPAGE="http://www.vim.org/"
28 IUSE="X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux tcl vim-pager"
32 || ( $(python_gen_useflags '*') )
33 ?? ( $(python_gen_useflags 'python2*') )
34 ?? ( $(python_gen_useflags 'python3*') )
39 >=app-eselect/eselect-vi-1.1
40 >=sys-libs/ncurses-5.2-r2
41 nls? ( virtual/libintl )
42 acl? ( kernel_linux? ( sys-apps/acl ) )
43 cscope? ( dev-util/cscope )
44 gpm? ( >=sys-libs/gpm-1.19.3 )
46 luajit? ( dev-lang/luajit:2= )
47 !luajit? ( dev-lang/lua:0[deprecated] )
50 ~app-editors/vim-core-${PV}
53 perl? ( dev-lang/perl:= )
54 python? ( ${PYTHON_DEPS} )
55 racket? ( dev-scheme/racket )
56 ruby? ( || ( dev-lang/ruby:2.2 dev-lang/ruby:2.1 dev-lang/ruby:2.0 ) )
57 selinux? ( sys-libs/libselinux )
58 tcl? ( dev-lang/tcl:0= )
63 nls? ( sys-devel/gettext )
66 S=${WORKDIR}/vim${VIM_VERSION/.}
69 # people with broken alphabets run into trouble. bug 82186.
73 # Gnome sandbox silliness. bug #114475.
75 export HOME="${T}"/home
79 if [[ ${PV} != 9999* ]] ; then
80 if [[ -f "${WORKDIR}"/${VIM_ORG_PATCH%.xz} ]] ; then
81 # Apply any patches available from vim.org for this version
82 epatch "${WORKDIR}"/${VIM_ORG_PATCH%.xz}
85 if [[ -d "${WORKDIR}"/patches/ ]]; then
86 # Gentoo patches to fix runtime issues, cross-compile errors, etc
87 EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" \
88 epatch "${WORKDIR}"/patches/
92 # Fixup a script to use awk instead of nawk
93 sed -i '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' "${S}"/runtime/tools/mve.awk \
94 || die "mve.awk sed failed"
96 # Read vimrc and gvimrc from /etc/vim
97 echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h
98 echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h
100 # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
101 # Hopefully this pattern won't break for a while at least.
102 # This fixes bug 29398 (27 Sep 2003 agriffis)
103 sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
104 "${S}"/runtime/doc/syntax.txt \
105 "${S}"/runtime/doc/tagsrch.txt \
106 "${S}"/runtime/doc/usr_29.txt \
107 "${S}"/runtime/menu.vim \
108 "${S}"/src/configure.in || die 'sed failed'
110 # Don't be fooled by /usr/include/libc.h. When found, vim thinks
111 # this is NeXT, but it's actually just a file in dev-libs/9libs
112 # This fixes bug 43885 (20 Mar 2004 agriffis)
113 sed -i 's/ libc\.h / /' "${S}"/src/configure.in || die 'sed failed'
115 # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
116 # correctly. To avoid some really entertaining error messages about stuff
117 # which isn't even in the source file being invalid, we'll do some trickery
118 # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
119 find "${S}" -name '*.c' | while read c ; do echo >> "$c" ; done
121 # conditionally make the manpager.sh script
122 if use vim-pager ; then
123 cat <<-END > "${S}"/runtime/macros/manpager.sh
125 sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
127 -c 'let no_plugin_maps = 1' \\
128 -c 'set nolist nomod ft=man' \\
129 -c 'let g:showmarks_enable=0' \\
130 -c 'runtime! macros/less.vim' -
134 # Try to avoid sandbox problems. Bug #114475.
135 if [[ -d "${S}"/src/po ]] ; then
136 sed -i '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
137 "${S}"/src/po/Makefile
140 if version_is_at_least 7.3.122 ; then
141 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
144 # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
145 if version_is_at_least 7.3 ; then
146 sed -i "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
147 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
156 # Fix bug 37354: Disallow -funroll-all-loops on amd64
157 # Bug 57859 suggests that we want to do this for all archs
158 filter-flags -funroll-all-loops
160 # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
161 # everyone since previous flag filtering bugs have turned out to affect
163 replace-flags -O3 -O2
165 # Fix bug 18245: Prevent "make" from the following chain:
166 # (1) Notice configure.in is newer than auto/configure
167 # (2) Rebuild auto/configure
168 # (3) Notice auto/configure is newer than auto/config.mk
169 # (4) Run ./configure (with wrong args) to remake auto/config.mk
170 sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
171 rm -f src/auto/configure
172 emake -j1 -C src autoconf
174 # This should fix a sandbox violation (see bug 24447). The hvc
175 # things are for ppc64, see bug 86433.
176 for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc* ; do
177 [[ -e ${file} ]] && addwrite $file
180 if use minimal ; then
191 --disable-pythoninterp
192 --disable-mzschemeinterp
199 use debug && append-flags "-DDEBUG"
207 $(use_enable lua luainterp)
208 $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
211 $(use_enable perl perlinterp)
212 $(use_enable racket mzschemeinterp)
213 $(use_enable ruby rubyinterp)
214 $(use_enable selinux)
215 $(use_enable tcl tclinterp)
222 [[ ${EPYTHON} == python3* ]] && v=3
224 --enable-python${v}interp
225 vi_cv_path_python${v}="${PYTHON}"
229 python_foreach_impl py_add_interp
232 --disable-pythoninterp
233 --disable-python3interp
237 # --with-features=huge forces on cscope even if we --disable it. We need
238 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
239 if ! use cscope ; then
240 sed -i '/# define FEAT_CSCOPE/d' src/feature.h || \
241 die "couldn't disable cscope"
244 # don't test USE=X here ... see bug #19115
245 # but need to provide a way to link against X ... see bug #20093
253 # Let Portage do the stripping. Some people like that.
254 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
256 # Keep Gentoo Prefix env contained within the EPREFIX
257 use prefix && myconf+=( --without-local-dir )
260 --with-modified-by=Gentoo-${PVR} \
265 # The following allows emake to be used
266 emake -j1 -C src auto/osdef.h objects
273 einfo "Starting vim tests. Several error messages will be shown"
274 einfo "while the tests run. This is normal behaviour and does not"
275 einfo "indicate a fault."
277 ewarn "If the tests fail, your terminal may be left in a strange"
278 ewarn "state. Usually, running 'reset' will fix this."
281 # Don't let vim talk to X
284 # We've got to call make test from within testdir, since the Makefiles
285 # don't pass through our VIMPROG argument
286 cd "${S}"/src/testdir
288 # Test 49 won't work inside a portage environment
289 einfo "Test 49 isn't sandbox-friendly, so it will be skipped."
290 sed -i 's~test49.out~~g' Makefile
292 # We don't want to rebuild vim before running the tests
293 sed -i 's,: \$(VIMPROG),: ,' Makefile
295 # Don't try to do the additional GUI test
296 emake -j1 VIMPROG=../vim nongui
299 # Make convenience symlinks, hopefully without stepping on toes. Some
300 # of these links are "owned" by the vim ebuild when it is installed,
301 # but they might be good for gvim as well (see bug 45828)
302 update_vim_symlinks() {
304 syms="vimdiff rvim rview"
305 einfo "Calling eselect vi update..."
306 # Call this with --if-unset to respect user's choice (bug 187449)
307 eselect vi update --if-unset
309 # Make or remove convenience symlink, vim -> gvim
310 if [[ -f "${EROOT}"/usr/bin/gvim ]]; then
311 ln -s gvim "${EROOT}"/usr/bin/vim 2>/dev/null
312 elif [[ -L "${EROOT}"/usr/bin/vim && ! -f "${EROOT}"/usr/bin/vim ]]; then
313 rm "${EROOT}"/usr/bin/vim
316 # Make or remove convenience symlinks to vim
317 if [[ -f "${EROOT}"/usr/bin/vim ]]; then
319 ln -s vim "${EROOT}"/usr/bin/${f} 2>/dev/null
323 if [[ -L "${EROOT}"/usr/bin/${f} && ! -f "${EROOT}"/usr/bin/${f} ]]; then
324 rm -f "${EROOT}"/usr/bin/${f}
329 # This will still break if you merge then remove the vi package,
330 # but there's only so much you can do, eh? Unfortunately we don't
331 # have triggers like are done in rpm-land.
335 local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
337 # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
338 # managed by eselect-vi
340 dosym vim /usr/bin/vimdiff
341 dosym vim /usr/bin/rvim
342 dosym vim /usr/bin/rview
343 if use vim-pager ; then
344 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
345 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
346 insinto ${vimfiles}/macros
347 doins runtime/macros/manpager.sh
348 fperms a+x ${vimfiles}/macros/manpager.sh
351 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
352 # keep in sync with 'complete ... -F' list
353 bashcomp_alias vim ex vi view rvim rview vimdiff
355 # We shouldn't be installing the ex or view man page symlinks, as they
356 # are managed by eselect-vi
357 rm -f "${ED}"/usr/share/man/man1/{ex,view}.1
361 # Update documentation tags (from vim-doc.eclass)
364 if [[ -z ${REPLACING_VERSIONS} ]] ; then
367 elog "The 'X' USE flag enables vim <-> X communication, like"
368 elog "updating the xterm titlebar. It does not install a GUI."
371 elog "To install a GUI version of vim, use the app-editors/gvim"
374 elog "Vim 7 includes an integrated spell checker. You need to install"
375 elog "word list files before you can use it. There are ebuilds for"
376 elog "some of these named app-vim/vim-spell-*. If your language of"
377 elog "choice is not included, please consult vim-spell.eclass for"
378 elog "instructions on how to make a package."
380 ewarn "Note that the English word lists are no longer installed by"
384 # Make convenience symlinks
389 # Update documentation tags (from vim-doc.eclass)
392 # Make convenience symlinks