Use https by default
[gentoo.git] / app-editors / gvim / gvim-7.4.769.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 VIM_VERSION="7.4"
7 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
8 PYTHON_REQ_USE=threads
9 inherit eutils vim-doc flag-o-matic fdo-mime versionator bash-completion-r1 prefix python-r1
10
11 MY_PV=${PV//./-}
12
13 if [[ ${PV} == 9999* ]] ; then
14         inherit git-r3
15         EGIT_REPO_URI="https://github.com/vim/vim.git"
16         EGIT_CHECKOUT_DIR=${WORKDIR}/vim-${MY_PV}
17 else
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"
21 fi
22
23 DESCRIPTION="GUI version of the Vim text editor"
24 HOMEPAGE="http://www.vim.org/"
25
26 SLOT="0"
27 LICENSE="vim"
28 IUSE="acl aqua cscope debug gnome gtk lua luajit motif neXt netbeans nls perl python racket ruby selinux session tcl"
29 REQUIRED_USE="
30         luajit? ( lua )
31         python? (
32                 || ( $(python_gen_useflags '*') )
33                 ?? ( $(python_gen_useflags 'python2*') )
34                 ?? ( $(python_gen_useflags 'python3*') )
35         )
36 "
37
38 RDEPEND="
39         ~app-editors/vim-core-${PV}
40         >=app-eselect/eselect-vi-1.1
41         >=sys-libs/ncurses-5.2-r2
42         x11-libs/libXext
43         x11-libs/libXt
44         acl? ( kernel_linux? ( sys-apps/acl ) )
45         !aqua? (
46                 gtk? (
47                         >=x11-libs/gtk+-2.6:2
48                         x11-libs/libXft
49                         gnome? ( >=gnome-base/libgnomeui-2.6 )
50                 )
51                 !gtk? (
52                         motif? ( >=x11-libs/motif-2.3:0 )
53                         !motif? (
54                                 neXt? ( x11-libs/neXtaw )
55                                 !neXt? ( x11-libs/libXaw )
56                         )
57                 )
58         )
59         cscope? ( dev-util/cscope )
60         lua? (
61                 luajit? ( dev-lang/luajit:2= )
62                 !luajit? ( dev-lang/lua:0[deprecated] )
63         )
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= )
72 "
73 DEPEND="${RDEPEND}
74         dev-util/ctags
75         sys-devel/autoconf
76         virtual/pkgconfig
77         nls? ( sys-devel/gettext )
78 "
79
80 S=${WORKDIR}/vim-${MY_PV}
81
82 pkg_setup() {
83         # people with broken alphabets run into trouble. bug 82186.
84         unset LANG LC_ALL
85         export LC_COLLATE="C"
86
87         # Gnome sandbox silliness. bug #114475.
88         mkdir -p "${T}"/home
89         export HOME="${T}"/home
90 }
91
92 src_prepare() {
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/
98                 fi
99         fi
100
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"
104
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
108
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'
118
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'
123
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
129
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
134         fi
135
136         if version_is_at_least 7.3.122 ; then
137                 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
138         fi
139
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'
144         fi
145
146         epatch_user
147 }
148
149 src_configure() {
150         local myconf=()
151
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
155
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
158         # multiple archs...
159         replace-flags -O3 -O2
160
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
169
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
174         done
175
176         use debug && append-flags "-DDEBUG"
177
178         myconf=(
179                 --with-features=huge
180                 --disable-gpm
181                 --enable-multibyte
182                 $(use_enable acl)
183                 $(use_enable cscope)
184                 $(use_enable lua luainterp)
185                 $(use_with luajit)
186                 $(use_enable netbeans)
187                 $(use_enable nls)
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)
194         )
195
196         if use python ; then
197                 py_add_interp() {
198                         local v
199
200                         [[ ${EPYTHON} == python3* ]] && v=3
201                         myconf+=(
202                                 --enable-python${v}interp
203                                 vi_cv_path_python${v}="${PYTHON}"
204                         )
205                 }
206
207                 python_foreach_impl py_add_interp
208         else
209                 myconf+=(
210                         --disable-pythoninterp
211                         --disable-python3interp
212                 )
213         fi
214
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"
220         fi
221
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
229         echo ; echo
230         if use aqua ; then
231                 einfo "Building gvim with the Carbon GUI"
232                 myconf+=(
233                         --enable-darwin
234                         --enable-gui=carbon
235                 )
236         elif use gtk ; then
237                 myconf+=( --enable-gtk2-check )
238                 if use gnome ; then
239                         einfo "Building gvim with the Gnome 2 GUI"
240                         myconf+=( --enable-gui=gnome2 )
241                 else
242                         einfo "Building gvim with the gtk+-2 GUI"
243                         myconf+=( --enable-gui=gtk2 )
244                 fi
245         elif use motif ; then
246                 einfo "Building gvim with the MOTIF GUI"
247                 myconf+=( --enable-gui=motif )
248         elif use neXt ; then
249                 einfo "Building gvim with the neXtaw GUI"
250                 myconf+=( --enable-gui=nextaw )
251         else
252                 einfo "Building gvim with the Athena GUI"
253                 myconf+=( --enable-gui=athena )
254         fi
255         echo ; echo
256
257         # Let Portage do the stripping. Some people like that.
258         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
259
260         # Keep Gentoo Prefix env contained within the EPREFIX
261         use prefix && myconf+=( --without-local-dir )
262
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
268         fi
269
270         econf \
271                 --with-modified-by=Gentoo-${PVR} \
272                 --with-vim-name=gvim \
273                 --with-x \
274                 "${myconf[@]}"
275 }
276
277 src_compile() {
278         # The following allows emake to be used
279         emake -j1 -C src auto/osdef.h objects
280
281         emake
282 }
283
284 src_test() {
285         echo
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."
289         echo
290         ewarn "If the tests fail, your terminal may be left in a strange"
291         ewarn "state. Usually, running 'reset' will fix this."
292         echo
293
294         # Don't let vim talk to X
295         unset DISPLAY
296
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
300
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
304
305         # We don't want to rebuild vim before running the tests
306         sed -i 's,: \$(VIMPROG),: ,' Makefile
307
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
311
312         # Don't try to do the additional GUI test
313         emake -j1 VIMPROG=../testvim nongui
314 }
315
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() {
320         local f syms
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
325
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
331         fi
332
333         # Make or remove convenience symlinks to vim
334         if [[ -f "${EROOT}"/usr/bin/vim ]]; then
335                 for f in ${syms}; do
336                         ln -s vim "${EROOT}"/usr/bin/${f} 2>/dev/null
337                 done
338         else
339                 for f in ${syms}; do
340                         if [[ -L "${EROOT}"/usr/bin/${f} && ! -f "${EROOT}"/usr/bin/${f} ]]; then
341                                 rm -f "${EROOT}"/usr/bin/${f}
342                         fi
343                 done
344         fi
345
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.
349 }
350
351 src_install() {
352         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
353
354         dobin src/gvim
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
361
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
366
367         insinto /etc/vim
368         newins "${FILESDIR}"/gvimrc-r1 gvimrc
369         eprefixify "${ED}"/etc/vim/gvimrc
370
371         newmenu "${FILESDIR}"/gvim.desktop-r2 gvim.desktop
372         doicon "${FILESDIR}"/gvim.xpm
373         doicon -s scalable "${FILESDIR}"/gvim.svg
374
375         # bash completion script, bug #79018.
376         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
377
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
381 }
382
383 pkg_postinst() {
384         # Update documentation tags (from vim-doc.eclass)
385         update_vim_helptags
386
387         # Update fdo mime stuff, bug #78394
388         fdo-mime_mime_database_update
389
390         if [[ -z ${REPLACING_VERSIONS} ]] ; then
391                 echo
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."
397                 echo
398                 ewarn "Note that the English word lists are no longer installed by"
399                 ewarn "default."
400                 echo
401         fi
402
403         # Make convenience symlinks
404         update_vim_symlinks
405 }
406
407 pkg_postrm() {
408         # Update documentation tags (from vim-doc.eclass)
409         update_vim_helptags
410
411         # Update fdo mime stuff, bug #78394
412         fdo-mime_mime_database_update
413
414         # Make convenience symlinks
415         update_vim_symlinks
416 }