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-single-r1
11 if [[ ${PV} == 9999* ]] ; then
13 EHG_REPO_URI="https://vim.googlecode.com/hg/"
16 VIM_ORG_PATCHES="vim-patches-${PV}.patch.bz2"
18 SRC_URI="ftp://ftp.vim.org/pub/vim/unix/vim-${VIM_VERSION}.tar.bz2
19 https://dev.gentoo.org/~radhermit/vim/${VIM_ORG_PATCHES}"
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"
30 python? ( ${PYTHON_REQUIRED_USE} )
35 ~app-editors/vim-core-${PV}
36 >=app-eselect/eselect-vi-1.1
37 >=sys-libs/ncurses-5.2-r2
40 acl? ( kernel_linux? ( sys-apps/acl ) )
45 gnome? ( >=gnome-base/libgnomeui-2.6 )
48 motif? ( >=x11-libs/motif-2.3:0 )
50 neXt? ( x11-libs/neXtaw )
51 !neXt? ( x11-libs/libXaw )
55 cscope? ( dev-util/cscope )
57 luajit? ( dev-lang/luajit:2= )
58 !luajit? ( dev-lang/lua:0[deprecated] )
60 nls? ( virtual/libintl )
61 perl? ( dev-lang/perl:= )
62 python? ( ${PYTHON_DEPS} )
63 racket? ( dev-scheme/racket )
64 ruby? ( || ( dev-lang/ruby:2.1 dev-lang/ruby:2.0 dev-lang/ruby:1.9 dev-lang/ruby:1.8 ) )
65 selinux? ( sys-libs/libselinux )
66 session? ( x11-libs/libSM )
67 tcl? ( dev-lang/tcl:0= )
73 nls? ( sys-devel/gettext )
76 S=${WORKDIR}/vim${VIM_VERSION/.}
79 # people with broken alphabets run into trouble. bug 82186.
83 # Gnome sandbox silliness. bug #114475.
85 export HOME="${T}"/home
87 use python && python-single-r1_pkg_setup
91 if [[ ${PV} != 9999* ]] ; then
92 if [[ -f "${WORKDIR}"/${VIM_ORG_PATCHES%.bz2} ]] ; then
93 # Apply any patches available from vim.org for this version
94 epatch "${WORKDIR}"/${VIM_ORG_PATCHES%.bz2}
98 # Fixup a script to use awk instead of nawk
99 sed -i '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' "${S}"/runtime/tools/mve.awk \
100 || die "mve.awk sed failed"
102 # Read vimrc and gvimrc from /etc/vim
103 echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h
104 echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h
106 # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
107 # Hopefully this pattern won't break for a while at least.
108 # This fixes bug 29398 (27 Sep 2003 agriffis)
109 sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
110 "${S}"/runtime/doc/syntax.txt \
111 "${S}"/runtime/doc/tagsrch.txt \
112 "${S}"/runtime/doc/usr_29.txt \
113 "${S}"/runtime/menu.vim \
114 "${S}"/src/configure.in || die 'sed failed'
116 # Don't be fooled by /usr/include/libc.h. When found, vim thinks
117 # this is NeXT, but it's actually just a file in dev-libs/9libs
118 # This fixes bug 43885 (20 Mar 2004 agriffis)
119 sed -i 's/ libc\.h / /' "${S}"/src/configure.in || die 'sed failed'
121 # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
122 # correctly. To avoid some really entertaining error messages about stuff
123 # which isn't even in the source file being invalid, we'll do some trickery
124 # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
125 find "${S}" -name '*.c' | while read c ; do echo >> "$c" ; done
127 # Try to avoid sandbox problems. Bug #114475.
128 if [[ -d "${S}"/src/po ]] ; then
129 sed -i '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
130 "${S}"/src/po/Makefile
133 if version_is_at_least 7.3.122 ; then
134 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
137 # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
138 if version_is_at_least 7.3 ; then
139 sed -i "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:" \
140 "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
149 # Fix bug 37354: Disallow -funroll-all-loops on amd64
150 # Bug 57859 suggests that we want to do this for all archs
151 filter-flags -funroll-all-loops
153 # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
154 # everyone since previous flag filtering bugs have turned out to affect
156 replace-flags -O3 -O2
158 # Fix bug 18245: Prevent "make" from the following chain:
159 # (1) Notice configure.in is newer than auto/configure
160 # (2) Rebuild auto/configure
161 # (3) Notice auto/configure is newer than auto/config.mk
162 # (4) Run ./configure (with wrong args) to remake auto/config.mk
163 sed -i 's/ auto.config.mk:/:/' src/Makefile || die "Makefile sed failed"
164 rm -f src/auto/configure
165 emake -j1 -C src autoconf
167 # This should fix a sandbox violation (see bug 24447). The hvc
168 # things are for ppc64, see bug 86433.
169 for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc* ; do
170 [[ -e ${file} ]] && addwrite $file
173 use debug && append-flags "-DDEBUG"
175 myconf="--with-features=huge --disable-gpm --enable-multibyte"
176 myconf+=" $(use_enable acl)"
177 myconf+=" $(use_enable cscope)"
178 myconf+=" $(use_enable lua luainterp)"
179 myconf+=" $(use_with luajit)"
180 myconf+=" $(use_enable netbeans)"
181 myconf+=" $(use_enable nls)"
182 myconf+=" $(use_enable perl perlinterp)"
183 myconf+=" $(use_enable racket mzschemeinterp)"
184 myconf+=" $(use_enable ruby rubyinterp)"
185 myconf+=" $(use_enable selinux)"
186 myconf+=" $(use_enable session xsmp)"
187 myconf+=" $(use_enable tcl tclinterp)"
190 if [[ ${EPYTHON} == python3* ]] ; then
191 myconf+=" --enable-python3interp"
192 export vi_cv_path_python3="${PYTHON}"
194 myconf+=" --enable-pythoninterp"
195 export vi_cv_path_python="${PYTHON}"
198 myconf+=" --disable-pythoninterp --disable-python3interp"
201 # --with-features=huge forces on cscope even if we --disable it. We need
202 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
203 if ! use cscope ; then
204 sed -i '/# define FEAT_CSCOPE/d' src/feature.h || \
205 die "couldn't disable cscope"
208 # gvim's GUI preference order is as follows:
209 # aqua CARBON (not tested)
210 # -aqua gtk gnome GNOME2
211 # -aqua gtk -gnome GTK2
212 # -aqua -gtk motif MOTIF
213 # -aqua -gtk -motif neXt NEXTAW
214 # -aqua -gtk -motif -neXt ATHENA
217 einfo "Building gvim with the Carbon GUI"
218 myconf+=" --enable-darwin --enable-gui=carbon"
220 myconf+=" --enable-gtk2-check"
222 einfo "Building gvim with the Gnome 2 GUI"
223 myconf+=" --enable-gui=gnome2"
225 einfo "Building gvim with the gtk+-2 GUI"
226 myconf+=" --enable-gui=gtk2"
228 elif use motif ; then
229 einfo "Building gvim with the MOTIF GUI"
230 myconf+=" --enable-gui=motif"
232 einfo "Building gvim with the neXtaw GUI"
233 myconf+=" --enable-gui=nextaw"
235 einfo "Building gvim with the Athena GUI"
236 myconf+=" --enable-gui=athena"
240 # Let Portage do the stripping. Some people like that.
241 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
243 # Keep Gentoo Prefix env contained within the EPREFIX
244 use prefix && myconf+=" --without-local-dir"
246 if [[ ${CHOST} == *-interix* ]]; then
247 # avoid finding of this function, to avoid having to patch either
248 # configure or the source, which would be much more hackish.
249 # after all vim does it right, only interix is badly broken (again)
250 export ac_cv_func_sigaction=no
254 --with-modified-by=Gentoo-${PVR} \
255 --with-vim-name=gvim --with-x \
260 # The following allows emake to be used
261 emake -j1 -C src auto/osdef.h objects
268 einfo "Starting vim tests. Several error messages will be shown"
269 einfo "while the tests run. This is normal behaviour and does not"
270 einfo "indicate a fault."
272 ewarn "If the tests fail, your terminal may be left in a strange"
273 ewarn "state. Usually, running 'reset' will fix this."
276 # Don't let vim talk to X
279 # We've got to call make test from within testdir, since the Makefiles
280 # don't pass through our VIMPROG argument
281 cd "${S}"/src/testdir
283 # Test 49 won't work inside a portage environment
284 einfo "Test 49 isn't sandbox-friendly, so it will be skipped."
285 sed -i 's~test49.out~~g' Makefile
287 # We don't want to rebuild vim before running the tests
288 sed -i 's,: \$(VIMPROG),: ,' Makefile
290 # Make gvim not try to connect to X. See :help gui-x11-start
291 # in vim for how this evil trickery works.
292 ln -s "${S}"/src/gvim "${S}"/src/testvim
294 # Don't try to do the additional GUI test
295 emake -j1 VIMPROG=../testvim nongui
298 # Make convenience symlinks, hopefully without stepping on toes. Some
299 # of these links are "owned" by the vim ebuild when it is installed,
300 # but they might be good for gvim as well (see bug 45828)
301 update_vim_symlinks() {
302 has "${EAPI:-0}" 0 1 2 && use !prefix && EROOT="${ROOT}"
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/.}
338 dosym gvim /usr/bin/gvimdiff
339 dosym gvim /usr/bin/evim
340 dosym gvim /usr/bin/eview
341 dosym gvim /usr/bin/gview
342 dosym gvim /usr/bin/rgvim
343 dosym gvim /usr/bin/rgview
345 dodir /usr/share/man/man1
346 echo ".so vim.1" > "${ED}"/usr/share/man/man1/gvim.1
347 echo ".so vim.1" > "${ED}"/usr/share/man/man1/gview.1
348 echo ".so vimdiff.1" > "${ED}"/usr/share/man/man1/gvimdiff.1
351 newins "${FILESDIR}"/gvimrc-r1 gvimrc
352 eprefixify "${ED}"/etc/vim/gvimrc
354 newmenu "${FILESDIR}"/gvim.desktop-r2 gvim.desktop
355 doicon "${FILESDIR}"/gvim.xpm
357 # bash completion script, bug #79018.
358 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
360 # We shouldn't be installing the ex or view man page symlinks, as they
361 # are managed by eselect-vi
362 rm -f "${ED}"/usr/share/man/man1/{ex,view}.1
366 # Update documentation tags (from vim-doc.eclass)
369 # Update fdo mime stuff, bug #78394
370 fdo-mime_mime_database_update
372 if [[ -z ${REPLACING_VERSIONS} ]] ; then
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"
385 # Make convenience symlinks
390 # Update documentation tags (from vim-doc.eclass)
393 # Update fdo mime stuff, bug #78394
394 fdo-mime_mime_database_update
396 # Make convenience symlinks