1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python{2_7,3_3,3_4,3_5} )
9 inherit eutils vim-doc flag-o-matic fdo-mime versionator bash-completion-r1 python-r1
11 if [[ ${PV} == 9999* ]] ; then
13 EGIT_REPO_URI="https://github.com/vim/vim.git"
15 SRC_URI="https://github.com/vim/vim/archive/v${PV}.tar.gz -> ${P}.tar.gz
16 https://dev.gentoo.org/~radhermit/vim/vim-7.4.827-gentoo-patches.tar.bz2"
17 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"
20 DESCRIPTION="Vim, an improved vi-style text editor"
21 HOMEPAGE="http://www.vim.org/"
25 IUSE="X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux tcl vim-pager"
29 || ( $(python_gen_useflags '*') )
30 ?? ( $(python_gen_useflags 'python2*') )
31 ?? ( $(python_gen_useflags 'python3*') )
36 >=app-eselect/eselect-vi-1.1
37 >=sys-libs/ncurses-5.2-r2:0
38 nls? ( virtual/libintl )
39 acl? ( kernel_linux? ( sys-apps/acl ) )
40 cscope? ( dev-util/cscope )
41 gpm? ( >=sys-libs/gpm-1.19.3 )
43 luajit? ( dev-lang/luajit:2= )
44 !luajit? ( dev-lang/lua:0[deprecated] )
47 ~app-editors/vim-core-${PV}
50 perl? ( dev-lang/perl:= )
51 python? ( ${PYTHON_DEPS} )
52 racket? ( dev-scheme/racket )
53 ruby? ( || ( dev-lang/ruby:2.3 dev-lang/ruby:2.2 dev-lang/ruby:2.1 dev-lang/ruby:2.0 ) )
54 selinux? ( sys-libs/libselinux )
55 tcl? ( dev-lang/tcl:0= )
60 nls? ( sys-devel/gettext )
64 # people with broken alphabets run into trouble. bug 82186.
68 # Gnome sandbox silliness. bug #114475.
70 export HOME="${T}"/home
74 if [[ ${PV} != 9999* ]] ; then
75 if [[ -d "${WORKDIR}"/patches/ ]]; then
76 # Gentoo patches to fix runtime issues, cross-compile errors, etc
77 EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" \
78 epatch "${WORKDIR}"/patches/
82 # Fixup a script to use awk instead of nawk
83 sed -i '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' "${S}"/runtime/tools/mve.awk \
84 || die "mve.awk sed failed"
86 # Read vimrc and gvimrc from /etc/vim
87 echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h
88 echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h
90 # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
91 # Hopefully this pattern won't break for a while at least.
92 # This fixes bug 29398 (27 Sep 2003 agriffis)
93 sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
94 "${S}"/runtime/doc/syntax.txt \
95 "${S}"/runtime/doc/tagsrch.txt \
96 "${S}"/runtime/doc/usr_29.txt \
97 "${S}"/runtime/menu.vim \
98 "${S}"/src/configure.in || die 'sed failed'
100 # Don't be fooled by /usr/include/libc.h. When found, vim thinks
101 # this is NeXT, but it's actually just a file in dev-libs/9libs
102 # This fixes bug 43885 (20 Mar 2004 agriffis)
103 sed -i 's/ libc\.h / /' "${S}"/src/configure.in || die 'sed failed'
105 # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
106 # correctly. To avoid some really entertaining error messages about stuff
107 # which isn't even in the source file being invalid, we'll do some trickery
108 # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
109 find "${S}" -name '*.c' | while read c ; do echo >> "$c" ; done
111 # conditionally make the manpager.sh script
112 if use vim-pager ; then
113 cat <<-END > "${S}"/runtime/macros/manpager.sh
115 sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
117 -c 'let no_plugin_maps = 1' \\
118 -c 'set nolist nomod ft=man ts=8' \\
119 -c 'let g:showmarks_enable=0' \\
120 -c 'runtime! macros/less.vim' -
124 # Try to avoid sandbox problems. Bug #114475.
125 if [[ -d "${S}"/src/po ]] ; then
126 sed -i '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
127 "${S}"/src/po/Makefile
130 if version_is_at_least 7.3.122 ; then
131 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
134 # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
135 if version_is_at_least 7.3 ; then
136 sed -i "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
137 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
146 # Fix bug 37354: Disallow -funroll-all-loops on amd64
147 # Bug 57859 suggests that we want to do this for all archs
148 filter-flags -funroll-all-loops
150 # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
151 # everyone since previous flag filtering bugs have turned out to affect
153 replace-flags -O3 -O2
155 # Fix bug 18245: Prevent "make" from the following chain:
156 # (1) Notice configure.in is newer than auto/configure
157 # (2) Rebuild auto/configure
158 # (3) Notice auto/configure is newer than auto/config.mk
159 # (4) Run ./configure (with wrong args) to remake auto/config.mk
160 sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
161 rm -f src/auto/configure
162 emake -j1 -C src autoconf
164 # This should fix a sandbox violation (see bug 24447). The hvc
165 # things are for ppc64, see bug 86433.
166 for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc* ; do
167 [[ -e ${file} ]] && addwrite $file
170 if use minimal ; then
181 --disable-pythoninterp
182 --disable-mzschemeinterp
189 use debug && append-flags "-DDEBUG"
197 $(use_enable lua luainterp)
198 $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
201 $(use_enable perl perlinterp)
202 $(use_enable racket mzschemeinterp)
203 $(use_enable ruby rubyinterp)
204 $(use_enable selinux)
205 $(use_enable tcl tclinterp)
212 [[ ${EPYTHON} == python3* ]] && v=3
214 --enable-python${v}interp
215 vi_cv_path_python${v}="${PYTHON}"
219 python_foreach_impl py_add_interp
222 --disable-pythoninterp
223 --disable-python3interp
227 # --with-features=huge forces on cscope even if we --disable it. We need
228 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
229 if ! use cscope ; then
230 sed -i '/# define FEAT_CSCOPE/d' src/feature.h || \
231 die "couldn't disable cscope"
234 # don't test USE=X here ... see bug #19115
235 # but need to provide a way to link against X ... see bug #20093
243 # Let Portage do the stripping. Some people like that.
244 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
246 # Keep Gentoo Prefix env contained within the EPREFIX
247 use prefix && myconf+=( --without-local-dir )
250 --with-modified-by=Gentoo-${PVR} \
255 # The following allows emake to be used
256 emake -j1 -C src auto/osdef.h objects
263 einfo "Starting vim tests. Several error messages will be shown"
264 einfo "while the tests run. This is normal behaviour and does not"
265 einfo "indicate a fault."
267 ewarn "If the tests fail, your terminal may be left in a strange"
268 ewarn "state. Usually, running 'reset' will fix this."
271 # Don't let vim talk to X
274 # We've got to call make test from within testdir, since the Makefiles
275 # don't pass through our VIMPROG argument
276 cd "${S}"/src/testdir
278 # Test 49 won't work inside a portage environment
279 einfo "Test 49 isn't sandbox-friendly, so it will be skipped."
280 sed -i 's~test49.out~~g' Makefile
282 # We don't want to rebuild vim before running the tests
283 sed -i 's,: \$(VIMPROG),: ,' Makefile
285 # Don't try to do the additional GUI test
286 emake -j1 VIMPROG=../vim nongui
289 # Make convenience symlinks, hopefully without stepping on toes. Some
290 # of these links are "owned" by the vim ebuild when it is installed,
291 # but they might be good for gvim as well (see bug 45828)
292 update_vim_symlinks() {
294 syms="vimdiff rvim rview"
295 einfo "Calling eselect vi update..."
296 # Call this with --if-unset to respect user's choice (bug 187449)
297 eselect vi update --if-unset
299 # Make or remove convenience symlink, vim -> gvim
300 if [[ -f "${EROOT}"/usr/bin/gvim ]]; then
301 ln -s gvim "${EROOT}"/usr/bin/vim 2>/dev/null
302 elif [[ -L "${EROOT}"/usr/bin/vim && ! -f "${EROOT}"/usr/bin/vim ]]; then
303 rm "${EROOT}"/usr/bin/vim
306 # Make or remove convenience symlinks to vim
307 if [[ -f "${EROOT}"/usr/bin/vim ]]; then
309 ln -s vim "${EROOT}"/usr/bin/${f} 2>/dev/null
313 if [[ -L "${EROOT}"/usr/bin/${f} && ! -f "${EROOT}"/usr/bin/${f} ]]; then
314 rm -f "${EROOT}"/usr/bin/${f}
319 # This will still break if you merge then remove the vi package,
320 # but there's only so much you can do, eh? Unfortunately we don't
321 # have triggers like are done in rpm-land.
325 local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
327 # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
328 # managed by eselect-vi
330 dosym vim /usr/bin/vimdiff
331 dosym vim /usr/bin/rvim
332 dosym vim /usr/bin/rview
333 if use vim-pager ; then
334 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
335 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
336 insinto ${vimfiles}/macros
337 doins runtime/macros/manpager.sh
338 fperms a+x ${vimfiles}/macros/manpager.sh
341 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
342 # keep in sync with 'complete ... -F' list
343 bashcomp_alias vim ex vi view rvim rview vimdiff
345 # We shouldn't be installing the ex or view man page symlinks, as they
346 # are managed by eselect-vi
347 rm -f "${ED}"/usr/share/man/man1/{ex,view}.1
351 # Update documentation tags (from vim-doc.eclass)
354 # Make convenience symlinks
359 # Update documentation tags (from vim-doc.eclass)
362 # Make convenience symlinks