Use https by default
[gentoo.git] / app-editors / gvim / gvim-7.4.273.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-single-r1
10
11 if [[ ${PV} == 9999* ]] ; then
12         inherit mercurial
13         EHG_REPO_URI="https://vim.googlecode.com/hg/"
14         EHG_PROJECT="vim"
15 else
16         VIM_ORG_PATCHES="vim-patches-${PV}.patch.bz2"
17
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"
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         python? ( ${PYTHON_REQUIRED_USE} )
31         luajit? ( lua )
32 "
33
34 RDEPEND="
35         ~app-editors/vim-core-${PV}
36         >=app-eselect/eselect-vi-1.1
37         >=sys-libs/ncurses-5.2-r2
38         x11-libs/libXext
39         x11-libs/libXt
40         acl? ( kernel_linux? ( sys-apps/acl ) )
41         !aqua? (
42                 gtk? (
43                         >=x11-libs/gtk+-2.6:2
44                         x11-libs/libXft
45                         gnome? ( >=gnome-base/libgnomeui-2.6 )
46                 )
47                 !gtk? (
48                         motif? ( >=x11-libs/motif-2.3:0 )
49                         !motif? (
50                                 neXt? ( x11-libs/neXtaw )
51                                 !neXt? ( x11-libs/libXaw )
52                         )
53                 )
54         )
55         cscope? ( dev-util/cscope )
56         lua? (
57                 luajit? ( dev-lang/luajit:2= )
58                 !luajit? ( dev-lang/lua:0[deprecated] )
59         )
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= )
68 "
69 DEPEND="${RDEPEND}
70         dev-util/ctags
71         sys-devel/autoconf
72         virtual/pkgconfig
73         nls? ( sys-devel/gettext )
74 "
75
76 S=${WORKDIR}/vim${VIM_VERSION/.}
77
78 pkg_setup() {
79         # people with broken alphabets run into trouble. bug 82186.
80         unset LANG LC_ALL
81         export LC_COLLATE="C"
82
83         # Gnome sandbox silliness. bug #114475.
84         mkdir -p "${T}"/home
85         export HOME="${T}"/home
86
87         use python && python-single-r1_pkg_setup
88 }
89
90 src_prepare() {
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}
95                 fi
96         fi
97
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"
101
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
105
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'
115
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'
120
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
126
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
131         fi
132
133         if version_is_at_least 7.3.122 ; then
134                 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
135         fi
136
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'
141         fi
142
143         epatch_user
144 }
145
146 src_configure() {
147         local myconf
148
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
152
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
155         # multiple archs...
156         replace-flags -O3 -O2
157
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
166
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
171         done
172
173         use debug && append-flags "-DDEBUG"
174
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)"
188
189         if use python ; then
190                 if [[ ${EPYTHON} == python3* ]] ; then
191                         myconf+=" --enable-python3interp"
192                         export vi_cv_path_python3="${PYTHON}"
193                 else
194                         myconf+=" --enable-pythoninterp"
195                         export vi_cv_path_python="${PYTHON}"
196                 fi
197         else
198                 myconf+=" --disable-pythoninterp --disable-python3interp"
199         fi
200
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"
206         fi
207
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
215         echo ; echo
216         if use aqua ; then
217                 einfo "Building gvim with the Carbon GUI"
218                 myconf+=" --enable-darwin --enable-gui=carbon"
219         elif use gtk ; then
220                 myconf+=" --enable-gtk2-check"
221                 if use gnome ; then
222                         einfo "Building gvim with the Gnome 2 GUI"
223                         myconf+=" --enable-gui=gnome2"
224                 else
225                         einfo "Building gvim with the gtk+-2 GUI"
226                         myconf+=" --enable-gui=gtk2"
227                 fi
228         elif use motif ; then
229                 einfo "Building gvim with the MOTIF GUI"
230                 myconf+=" --enable-gui=motif"
231         elif use neXt ; then
232                 einfo "Building gvim with the neXtaw GUI"
233                 myconf+=" --enable-gui=nextaw"
234         else
235                 einfo "Building gvim with the Athena GUI"
236                 myconf+=" --enable-gui=athena"
237         fi
238         echo ; echo
239
240         # Let Portage do the stripping. Some people like that.
241         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
242
243         # Keep Gentoo Prefix env contained within the EPREFIX
244         use prefix && myconf+=" --without-local-dir"
245
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
251         fi
252
253         econf \
254                 --with-modified-by=Gentoo-${PVR} \
255                 --with-vim-name=gvim --with-x \
256                 ${myconf}
257 }
258
259 src_compile() {
260         # The following allows emake to be used
261         emake -j1 -C src auto/osdef.h objects
262
263         emake
264 }
265
266 src_test() {
267         echo
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."
271         echo
272         ewarn "If the tests fail, your terminal may be left in a strange"
273         ewarn "state. Usually, running 'reset' will fix this."
274         echo
275
276         # Don't let vim talk to X
277         unset DISPLAY
278
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
282
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
286
287         # We don't want to rebuild vim before running the tests
288         sed -i 's,: \$(VIMPROG),: ,' Makefile
289
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
293
294         # Don't try to do the additional GUI test
295         emake -j1 VIMPROG=../testvim nongui
296 }
297
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}"
303         local f syms
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
308
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
314         fi
315
316         # Make or remove convenience symlinks to vim
317         if [[ -f "${EROOT}"/usr/bin/vim ]]; then
318                 for f in ${syms}; do
319                         ln -s vim "${EROOT}"/usr/bin/${f} 2>/dev/null
320                 done
321         else
322                 for f in ${syms}; do
323                         if [[ -L "${EROOT}"/usr/bin/${f} && ! -f "${EROOT}"/usr/bin/${f} ]]; then
324                                 rm -f "${EROOT}"/usr/bin/${f}
325                         fi
326                 done
327         fi
328
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.
332 }
333
334 src_install() {
335         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
336
337         dobin src/gvim
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
344
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
349
350         insinto /etc/vim
351         newins "${FILESDIR}"/gvimrc-r1 gvimrc
352         eprefixify "${ED}"/etc/vim/gvimrc
353
354         newmenu "${FILESDIR}"/gvim.desktop-r2 gvim.desktop
355         doicon "${FILESDIR}"/gvim.xpm
356
357         # bash completion script, bug #79018.
358         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
359
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
363 }
364
365 pkg_postinst() {
366         # Update documentation tags (from vim-doc.eclass)
367         update_vim_helptags
368
369         # Update fdo mime stuff, bug #78394
370         fdo-mime_mime_database_update
371
372         if [[ -z ${REPLACING_VERSIONS} ]] ; then
373                 echo
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."
379                 echo
380                 ewarn "Note that the English word lists are no longer installed by"
381                 ewarn "default."
382                 echo
383         fi
384
385         # Make convenience symlinks
386         update_vim_symlinks
387 }
388
389 pkg_postrm() {
390         # Update documentation tags (from vim-doc.eclass)
391         update_vim_helptags
392
393         # Update fdo mime stuff, bug #78394
394         fdo-mime_mime_database_update
395
396         # Make convenience symlinks
397         update_vim_symlinks
398 }