Use https by default
[gentoo.git] / app-editors / vim / vim-7.4.670.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 python-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_PATCH="vim-${PV}.patch.xz"
17         SRC_URI="ftp://ftp.vim.org/pub/vim/unix/vim-${VIM_VERSION}.tar.bz2
18                 https://dev.gentoo.org/~radhermit/vim/${VIM_ORG_PATCH}
19                 https://dev.gentoo.org/~radhermit/vim/vim-7.4.542-gentoo-patches.tar.bz2"
20         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"
21 fi
22
23 DESCRIPTION="Vim, an improved vi-style text editor"
24 HOMEPAGE="http://www.vim.org/"
25
26 SLOT="0"
27 LICENSE="vim"
28 IUSE="X acl cscope debug gpm lua luajit minimal nls perl python racket ruby selinux tcl vim-pager"
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-eselect/eselect-vi-1.1
40         >=sys-libs/ncurses-5.2-r2
41         nls? ( virtual/libintl )
42         acl? ( kernel_linux? ( sys-apps/acl ) )
43         cscope? ( dev-util/cscope )
44         gpm? ( >=sys-libs/gpm-1.19.3 )
45         lua? (
46                 luajit? ( dev-lang/luajit:2= )
47                 !luajit? ( dev-lang/lua:0[deprecated] )
48         )
49         !minimal? (
50                 ~app-editors/vim-core-${PV}
51                 dev-util/ctags
52         )
53         perl? ( dev-lang/perl:= )
54         python? ( ${PYTHON_DEPS} )
55         racket? ( dev-scheme/racket )
56         ruby? ( || ( dev-lang/ruby:2.2 dev-lang/ruby:2.1 dev-lang/ruby:2.0 ) )
57         selinux? ( sys-libs/libselinux )
58         tcl? ( dev-lang/tcl:0= )
59         X? ( x11-libs/libXt )
60 "
61 DEPEND="${RDEPEND}
62         sys-devel/autoconf
63         nls? ( sys-devel/gettext )
64 "
65
66 S=${WORKDIR}/vim${VIM_VERSION/.}
67
68 pkg_setup() {
69         # people with broken alphabets run into trouble. bug 82186.
70         unset LANG LC_ALL
71         export LC_COLLATE="C"
72
73         # Gnome sandbox silliness. bug #114475.
74         mkdir -p "${T}"/home
75         export HOME="${T}"/home
76 }
77
78 src_prepare() {
79         if [[ ${PV} != 9999* ]] ; then
80                 if [[ -f "${WORKDIR}"/${VIM_ORG_PATCH%.xz} ]] ; then
81                         # Apply any patches available from vim.org for this version
82                         epatch "${WORKDIR}"/${VIM_ORG_PATCH%.xz}
83                 fi
84
85                 if [[ -d "${WORKDIR}"/patches/ ]]; then
86                         # Gentoo patches to fix runtime issues, cross-compile errors, etc
87                         EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" \
88                                 epatch "${WORKDIR}"/patches/
89                 fi
90         fi
91
92         # Fixup a script to use awk instead of nawk
93         sed -i '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' "${S}"/runtime/tools/mve.awk \
94                 || die "mve.awk sed failed"
95
96         # Read vimrc and gvimrc from /etc/vim
97         echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h
98         echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h
99
100         # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
101         # Hopefully this pattern won't break for a while at least.
102         # This fixes bug 29398 (27 Sep 2003 agriffis)
103         sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
104                 "${S}"/runtime/doc/syntax.txt \
105                 "${S}"/runtime/doc/tagsrch.txt \
106                 "${S}"/runtime/doc/usr_29.txt \
107                 "${S}"/runtime/menu.vim \
108                 "${S}"/src/configure.in || die 'sed failed'
109
110         # Don't be fooled by /usr/include/libc.h.  When found, vim thinks
111         # this is NeXT, but it's actually just a file in dev-libs/9libs
112         # This fixes bug 43885 (20 Mar 2004 agriffis)
113         sed -i 's/ libc\.h / /' "${S}"/src/configure.in || die 'sed failed'
114
115         # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
116         # correctly. To avoid some really entertaining error messages about stuff
117         # which isn't even in the source file being invalid, we'll do some trickery
118         # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
119         find "${S}" -name '*.c' | while read c ; do echo >> "$c" ; done
120
121         # conditionally make the manpager.sh script
122         if use vim-pager ; then
123                 cat <<-END > "${S}"/runtime/macros/manpager.sh
124                         #!/bin/sh
125                         sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
126                                         vim \\
127                                                 -c 'let no_plugin_maps = 1' \\
128                                                 -c 'set nolist nomod ft=man' \\
129                                                 -c 'let g:showmarks_enable=0' \\
130                                                 -c 'runtime! macros/less.vim' -
131                         END
132         fi
133
134         # Try to avoid sandbox problems. Bug #114475.
135         if [[ -d "${S}"/src/po ]] ; then
136                 sed -i '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
137                         "${S}"/src/po/Makefile
138         fi
139
140         if version_is_at_least 7.3.122 ; then
141                 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
142         fi
143
144         # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
145         if version_is_at_least 7.3 ; then
146                 sed -i "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:"     \
147                         "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
148         fi
149
150         epatch_user
151 }
152
153 src_configure() {
154         local myconf=()
155
156         # Fix bug 37354: Disallow -funroll-all-loops on amd64
157         # Bug 57859 suggests that we want to do this for all archs
158         filter-flags -funroll-all-loops
159
160         # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
161         # everyone since previous flag filtering bugs have turned out to affect
162         # multiple archs...
163         replace-flags -O3 -O2
164
165         # Fix bug 18245: Prevent "make" from the following chain:
166         # (1) Notice configure.in is newer than auto/configure
167         # (2) Rebuild auto/configure
168         # (3) Notice auto/configure is newer than auto/config.mk
169         # (4) Run ./configure (with wrong args) to remake auto/config.mk
170         sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
171         rm -f src/auto/configure
172         emake -j1 -C src autoconf
173
174         # This should fix a sandbox violation (see bug 24447). The hvc
175         # things are for ppc64, see bug 86433.
176         for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc* ; do
177                 [[ -e ${file} ]] && addwrite $file
178         done
179
180         if use minimal ; then
181                 myconf=(
182                         --with-features=tiny
183                         --disable-nls
184                         --disable-multibyte
185                         --disable-acl
186                         --enable-gui=no
187                         --without-x
188                         --disable-darwin
189                         --disable-luainterp
190                         --disable-perlinterp
191                         --disable-pythoninterp
192                         --disable-mzschemeinterp
193                         --disable-rubyinterp
194                         --disable-selinux
195                         --disable-tclinterp
196                         --disable-gpm
197                 )
198         else
199                 use debug && append-flags "-DDEBUG"
200
201                 myconf=(
202                         --with-features=huge
203                         --enable-multibyte
204                         $(use_enable acl)
205                         $(use_enable cscope)
206                         $(use_enable gpm)
207                         $(use_enable lua luainterp)
208                         $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
209                         $(use_with luajit)
210                         $(use_enable nls)
211                         $(use_enable perl perlinterp)
212                         $(use_enable racket mzschemeinterp)
213                         $(use_enable ruby rubyinterp)
214                         $(use_enable selinux)
215                         $(use_enable tcl tclinterp)
216                 )
217
218                 if use python ; then
219                         py_add_interp() {
220                                 local v
221
222                                 [[ ${EPYTHON} == python3* ]] && v=3
223                                 myconf+=(
224                                         --enable-python${v}interp
225                                         vi_cv_path_python${v}="${PYTHON}"
226                                 )
227                         }
228
229                         python_foreach_impl py_add_interp
230                 else
231                         myconf+=(
232                                 --disable-pythoninterp
233                                 --disable-python3interp
234                         )
235                 fi
236
237                 # --with-features=huge forces on cscope even if we --disable it. We need
238                 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
239                 if ! use cscope ; then
240                         sed -i '/# define FEAT_CSCOPE/d' src/feature.h || \
241                                 die "couldn't disable cscope"
242                 fi
243
244                 # don't test USE=X here ... see bug #19115
245                 # but need to provide a way to link against X ... see bug #20093
246                 myconf+=(
247                         --enable-gui=no
248                         --disable-darwin
249                         $(use_with X x)
250                 )
251         fi
252
253         # Let Portage do the stripping. Some people like that.
254         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
255
256         # Keep Gentoo Prefix env contained within the EPREFIX
257         use prefix && myconf+=( --without-local-dir )
258
259         econf \
260                 --with-modified-by=Gentoo-${PVR} \
261                 "${myconf[@]}"
262 }
263
264 src_compile() {
265         # The following allows emake to be used
266         emake -j1 -C src auto/osdef.h objects
267
268         emake
269 }
270
271 src_test() {
272         echo
273         einfo "Starting vim tests. Several error messages will be shown"
274         einfo "while the tests run. This is normal behaviour and does not"
275         einfo "indicate a fault."
276         echo
277         ewarn "If the tests fail, your terminal may be left in a strange"
278         ewarn "state. Usually, running 'reset' will fix this."
279         echo
280
281         # Don't let vim talk to X
282         unset DISPLAY
283
284         # We've got to call make test from within testdir, since the Makefiles
285         # don't pass through our VIMPROG argument
286         cd "${S}"/src/testdir
287
288         # Test 49 won't work inside a portage environment
289         einfo "Test 49 isn't sandbox-friendly, so it will be skipped."
290         sed -i 's~test49.out~~g' Makefile
291
292         # We don't want to rebuild vim before running the tests
293         sed -i 's,: \$(VIMPROG),: ,' Makefile
294
295         # Don't try to do the additional GUI test
296         emake -j1 VIMPROG=../vim nongui
297 }
298
299 # Make convenience symlinks, hopefully without stepping on toes.  Some
300 # of these links are "owned" by the vim ebuild when it is installed,
301 # but they might be good for gvim as well (see bug 45828)
302 update_vim_symlinks() {
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         # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
338         #       managed by eselect-vi
339         dobin src/vim
340         dosym vim /usr/bin/vimdiff
341         dosym vim /usr/bin/rvim
342         dosym vim /usr/bin/rview
343         if use vim-pager ; then
344                 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
345                 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
346                 insinto ${vimfiles}/macros
347                 doins runtime/macros/manpager.sh
348                 fperms a+x ${vimfiles}/macros/manpager.sh
349         fi
350
351         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
352         # keep in sync with 'complete ... -F' list
353         bashcomp_alias vim ex vi view rvim rview vimdiff
354
355         # We shouldn't be installing the ex or view man page symlinks, as they
356         # are managed by eselect-vi
357         rm -f "${ED}"/usr/share/man/man1/{ex,view}.1
358 }
359
360 pkg_postinst() {
361         # Update documentation tags (from vim-doc.eclass)
362         update_vim_helptags
363
364         if [[ -z ${REPLACING_VERSIONS} ]] ; then
365                 if use X ; then
366                         echo
367                         elog "The 'X' USE flag enables vim <-> X communication, like"
368                         elog "updating the xterm titlebar. It does not install a GUI."
369                 fi
370                 echo
371                 elog "To install a GUI version of vim, use the app-editors/gvim"
372                 elog "package."
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         fi
383
384         # Make convenience symlinks
385         update_vim_symlinks
386 }
387
388 pkg_postrm() {
389         # Update documentation tags (from vim-doc.eclass)
390         update_vim_helptags
391
392         # Make convenience symlinks
393         update_vim_symlinks
394 }