1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_5,3_6,3_7} )
7 PYTHON_REQ_USE="threads(+)"
8 USE_RUBY="ruby24 ruby25 ruby26"
10 inherit vim-doc flag-o-matic xdg-utils gnome2-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/~radhermit/vim/vim-8.0.0938-gentoo-patches.tar.bz2"
19 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ppc ppc64 s390 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 tcl"
29 python? ( ${PYTHON_REQUIRED_USE} )
33 >=app-eselect/eselect-vi-1.1
34 >=sys-libs/ncurses-5.2-r2:0=
39 acl? ( kernel_linux? ( sys-apps/acl ) )
51 motif? ( >=x11-libs/motif-2.3:0 )
53 neXt? ( x11-libs/neXtaw )
54 !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? ( ${RUBY_DEPS} )
69 selinux? ( sys-libs/libselinux )
70 session? ( x11-libs/libSM )
71 tcl? ( dev-lang/tcl:0= )
76 nls? ( sys-devel/gettext )
78 # temporarily use PDEPEND to allow upgrades past icon file collision, bug #673880
79 PDEPEND="~app-editors/vim-core-${PV}"
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"
196 $(use_enable lua luainterp)
198 $(use_enable netbeans)
200 $(use_enable perl perlinterp)
201 $(use_enable python pythoninterp)
202 $(use_enable python python3interp)
203 $(use_with python python-command $(type -P $(eselect python show --python2)))
204 $(use_with python python3-command $(type -P $(eselect python show --python3)))
205 $(use_enable racket mzschemeinterp)
206 $(use_enable ruby rubyinterp)
207 $(use_enable selinux)
208 $(use_enable session xsmp)
209 $(use_enable tcl tclinterp)
212 # --with-features=huge forces on cscope even if we --disable it. We need
213 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
214 if ! use cscope; then
216 '/# define FEAT_CSCOPE/d' src/feature.h || die "couldn't disable cscope"
219 # gvim's GUI preference order is as follows:
220 # aqua CARBON (not tested)
222 # -aqua -gtk gtk2 GTK2
223 # -aqua -gtk -gtk motif MOTIF
224 # -aqua -gtk -gtk -motif neXt NEXTAW
225 # -aqua -gtk -gtk -motif -neXt ATHENA
228 einfo "Building gvim with the Carbon GUI"
234 myconf+=( --enable-gtk3-check )
235 einfo "Building gvim with the gtk+-3 GUI"
236 myconf+=( --enable-gui=gtk3 )
238 myconf+=( --enable-gtk2-check )
239 einfo "Building gvim with the gtk+-2 GUI"
240 myconf+=( --enable-gui=gtk2 )
242 einfo "Building gvim with the MOTIF GUI"
243 myconf+=( --enable-gui=motif )
245 einfo "Building gvim with the neXtaw GUI"
246 myconf+=( --enable-gui=nextaw )
248 einfo "Building gvim with the Athena GUI"
249 myconf+=( --enable-gui=athena )
253 # let package manager strip binaries
254 export ac_cv_prog_STRIP="$(type -P true ) faking strip"
256 # keep prefix env contained within the EPREFIX
257 use prefix && myconf+=( --without-local-dir )
259 if [[ ${CHOST} == *-interix* ]]; then
260 # avoid finding of this function, to avoid having to patch either
261 # configure or the source, which would be much more hackish.
262 # after all vim does it right, only interix is badly broken (again)
263 export ac_cv_func_sigaction=no
267 --with-modified-by=Gentoo-${PVR} \
268 --with-vim-name=gvim \
274 # The following allows emake to be used
275 emake -j1 -C src auto/osdef.h objects
282 einfo "Starting vim tests. Several error messages will be shown"
283 einfo "while the tests run. This is normal behaviour and does not"
284 einfo "indicate a fault."
286 ewarn "If the tests fail, your terminal may be left in a strange"
287 ewarn "state. Usually, running 'reset' will fix this."
290 # Don't let vim talk to X
293 # Make gvim not try to connect to X. See :help gui-x11-start in vim for how
294 # this evil trickery works.
295 ln -s "${S}"/src/gvim "${S}"/src/testvim || die
297 # Make sure our VIMPROG is used.
298 sed -i -e 's:\.\./vim:../testvim:' src/testdir/test49.vim || die
300 # Don't do additional GUI tests.
301 emake -j1 VIMPROG=../testvim -C src/testdir nongui
304 # Call eselect vi update with --if-unset
305 # to respect user's choice (bug 187449)
306 eselect_vi_update() {
307 einfo "Calling eselect vi update..."
308 eselect vi update --if-unset
313 local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
316 dosym gvim /usr/bin/gvimdiff
317 dosym gvim /usr/bin/evim
318 dosym gvim /usr/bin/eview
319 dosym gvim /usr/bin/gview
320 dosym gvim /usr/bin/rgvim
321 dosym gvim /usr/bin/rgview
323 emake -C src DESTDIR="${D}" DATADIR="${EPREFIX}"/usr/share install-icons
325 dodir /usr/share/man/man1
326 echo ".so vim.1" > "${ED}"/usr/share/man/man1/gvim.1 || die "echo failed"
327 echo ".so vim.1" > "${ED}"/usr/share/man/man1/gview.1 || die "echo failed"
328 echo ".so vimdiff.1" > "${ED}"/usr/share/man/man1/gvimdiff.1 || \
332 newins "${FILESDIR}"/gvimrc-r1 gvimrc
333 eprefixify "${ED}"/etc/vim/gvimrc
335 # bash completion script, bug #79018.
336 newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
338 # don't install vim desktop file
339 rm -v "${ED}"/usr/share/applications/vim.desktop || die "failed to remove vim.desktop"
343 # Update documentation tags (from vim-doc.eclass)
346 # Update fdo mime stuff, bug #78394
347 xdg_desktop_database_update
350 gnome2_icon_cache_update
352 # Call eselect vi update
357 # Update documentation tags (from vim-doc.eclass)
360 # Update fdo mime stuff, bug #78394
361 xdg_desktop_database_update
364 gnome2_icon_cache_update
366 # Call eselect vi update