Use https by default
[gentoo.git] / app-editors / vim / vim-9999.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 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 -> ${P}.tar.gz
19                 https://dev.gentoo.org/~radhermit/vim/vim-${PV}-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-${MY_PV}
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 [[ -d "${WORKDIR}"/patches/ ]]; then
81                         # Gentoo patches to fix runtime issues, cross-compile errors, etc
82                         EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" \
83                                 epatch "${WORKDIR}"/patches/
84                 fi
85         fi
86
87         # Fixup a script to use awk instead of nawk
88         sed -i '1s|.*|#!'"${EPREFIX}"'/usr/bin/awk -f|' "${S}"/runtime/tools/mve.awk \
89                 || die "mve.awk sed failed"
90
91         # Read vimrc and gvimrc from /etc/vim
92         echo '#define SYS_VIMRC_FILE "'${EPREFIX}'/etc/vim/vimrc"' >> "${S}"/src/feature.h
93         echo '#define SYS_GVIMRC_FILE "'${EPREFIX}'/etc/vim/gvimrc"' >> "${S}"/src/feature.h
94
95         # Use exuberant ctags which installs as /usr/bin/exuberant-ctags.
96         # Hopefully this pattern won't break for a while at least.
97         # This fixes bug 29398 (27 Sep 2003 agriffis)
98         sed -i 's/\<ctags\("\| [-*.]\)/exuberant-&/g' \
99                 "${S}"/runtime/doc/syntax.txt \
100                 "${S}"/runtime/doc/tagsrch.txt \
101                 "${S}"/runtime/doc/usr_29.txt \
102                 "${S}"/runtime/menu.vim \
103                 "${S}"/src/configure.in || die 'sed failed'
104
105         # Don't be fooled by /usr/include/libc.h.  When found, vim thinks
106         # this is NeXT, but it's actually just a file in dev-libs/9libs
107         # This fixes bug 43885 (20 Mar 2004 agriffis)
108         sed -i 's/ libc\.h / /' "${S}"/src/configure.in || die 'sed failed'
109
110         # gcc on sparc32 has this, uhm, interesting problem with detecting EOF
111         # correctly. To avoid some really entertaining error messages about stuff
112         # which isn't even in the source file being invalid, we'll do some trickery
113         # to make the error never occur. bug 66162 (02 October 2004 ciaranm)
114         find "${S}" -name '*.c' | while read c ; do echo >> "$c" ; done
115
116         # conditionally make the manpager.sh script
117         if use vim-pager ; then
118                 cat <<-END > "${S}"/runtime/macros/manpager.sh
119                         #!/bin/sh
120                         sed -e 's/\x1B\[[[:digit:]]\+m//g' | col -b | \\
121                                         vim \\
122                                                 -c 'let no_plugin_maps = 1' \\
123                                                 -c 'set nolist nomod ft=man ts=8' \\
124                                                 -c 'let g:showmarks_enable=0' \\
125                                                 -c 'runtime! macros/less.vim' -
126                         END
127         fi
128
129         # Try to avoid sandbox problems. Bug #114475.
130         if [[ -d "${S}"/src/po ]] ; then
131                 sed -i '/-S check.vim/s,..VIM.,ln -s $(VIM) testvim \; ./testvim -X,' \
132                         "${S}"/src/po/Makefile
133         fi
134
135         if version_is_at_least 7.3.122 ; then
136                 cp "${S}"/src/config.mk.dist "${S}"/src/auto/config.mk
137         fi
138
139         # Bug #378107 - Build properly with >=perl-core/ExtUtils-ParseXS-3.20.0
140         if version_is_at_least 7.3 ; then
141                 sed -i "s:\\\$(PERLLIB)/ExtUtils/xsubpp:${EPREFIX}/usr/bin/xsubpp:"     \
142                         "${S}"/src/Makefile || die 'sed for ExtUtils-ParseXS failed'
143         fi
144
145         epatch_user
146 }
147
148 src_configure() {
149         local myconf=()
150
151         # Fix bug 37354: Disallow -funroll-all-loops on amd64
152         # Bug 57859 suggests that we want to do this for all archs
153         filter-flags -funroll-all-loops
154
155         # Fix bug 76331: -O3 causes problems, use -O2 instead. We'll do this for
156         # everyone since previous flag filtering bugs have turned out to affect
157         # multiple archs...
158         replace-flags -O3 -O2
159
160         # Fix bug 18245: Prevent "make" from the following chain:
161         # (1) Notice configure.in is newer than auto/configure
162         # (2) Rebuild auto/configure
163         # (3) Notice auto/configure is newer than auto/config.mk
164         # (4) Run ./configure (with wrong args) to remake auto/config.mk
165         sed -i 's# auto/config\.mk:#:#' src/Makefile || die "Makefile sed failed"
166         rm -f src/auto/configure
167         emake -j1 -C src autoconf
168
169         # This should fix a sandbox violation (see bug 24447). The hvc
170         # things are for ppc64, see bug 86433.
171         for file in /dev/pty/s* /dev/console /dev/hvc/* /dev/hvc* ; do
172                 [[ -e ${file} ]] && addwrite $file
173         done
174
175         if use minimal ; then
176                 myconf=(
177                         --with-features=tiny
178                         --disable-nls
179                         --disable-multibyte
180                         --disable-acl
181                         --enable-gui=no
182                         --without-x
183                         --disable-darwin
184                         --disable-luainterp
185                         --disable-perlinterp
186                         --disable-pythoninterp
187                         --disable-mzschemeinterp
188                         --disable-rubyinterp
189                         --disable-selinux
190                         --disable-tclinterp
191                         --disable-gpm
192                 )
193         else
194                 use debug && append-flags "-DDEBUG"
195
196                 myconf=(
197                         --with-features=huge
198                         --enable-multibyte
199                         $(use_enable acl)
200                         $(use_enable cscope)
201                         $(use_enable gpm)
202                         $(use_enable lua luainterp)
203                         $(usex lua "--with-lua-prefix=${EPREFIX}/usr" "")
204                         $(use_with luajit)
205                         $(use_enable nls)
206                         $(use_enable perl perlinterp)
207                         $(use_enable racket mzschemeinterp)
208                         $(use_enable ruby rubyinterp)
209                         $(use_enable selinux)
210                         $(use_enable tcl tclinterp)
211                 )
212
213                 if use python ; then
214                         py_add_interp() {
215                                 local v
216
217                                 [[ ${EPYTHON} == python3* ]] && v=3
218                                 myconf+=(
219                                         --enable-python${v}interp
220                                         vi_cv_path_python${v}="${PYTHON}"
221                                 )
222                         }
223
224                         python_foreach_impl py_add_interp
225                 else
226                         myconf+=(
227                                 --disable-pythoninterp
228                                 --disable-python3interp
229                         )
230                 fi
231
232                 # --with-features=huge forces on cscope even if we --disable it. We need
233                 # to sed this out to avoid screwiness. (1 Sep 2004 ciaranm)
234                 if ! use cscope ; then
235                         sed -i '/# define FEAT_CSCOPE/d' src/feature.h || \
236                                 die "couldn't disable cscope"
237                 fi
238
239                 # don't test USE=X here ... see bug #19115
240                 # but need to provide a way to link against X ... see bug #20093
241                 myconf+=(
242                         --enable-gui=no
243                         --disable-darwin
244                         $(use_with X x)
245                 )
246         fi
247
248         # Let Portage do the stripping. Some people like that.
249         export ac_cv_prog_STRIP="$(type -P true ) faking strip"
250
251         # Keep Gentoo Prefix env contained within the EPREFIX
252         use prefix && myconf+=( --without-local-dir )
253
254         econf \
255                 --with-modified-by=Gentoo-${PVR} \
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         # Don't try to do the additional GUI test
291         emake -j1 VIMPROG=../vim nongui
292 }
293
294 # Make convenience symlinks, hopefully without stepping on toes.  Some
295 # of these links are "owned" by the vim ebuild when it is installed,
296 # but they might be good for gvim as well (see bug 45828)
297 update_vim_symlinks() {
298         local f syms
299         syms="vimdiff rvim rview"
300         einfo "Calling eselect vi update..."
301         # Call this with --if-unset to respect user's choice (bug 187449)
302         eselect vi update --if-unset
303
304         # Make or remove convenience symlink, vim -> gvim
305         if [[ -f "${EROOT}"/usr/bin/gvim ]]; then
306                 ln -s gvim "${EROOT}"/usr/bin/vim 2>/dev/null
307         elif [[ -L "${EROOT}"/usr/bin/vim && ! -f "${EROOT}"/usr/bin/vim ]]; then
308                 rm "${EROOT}"/usr/bin/vim
309         fi
310
311         # Make or remove convenience symlinks to vim
312         if [[ -f "${EROOT}"/usr/bin/vim ]]; then
313                 for f in ${syms}; do
314                         ln -s vim "${EROOT}"/usr/bin/${f} 2>/dev/null
315                 done
316         else
317                 for f in ${syms}; do
318                         if [[ -L "${EROOT}"/usr/bin/${f} && ! -f "${EROOT}"/usr/bin/${f} ]]; then
319                                 rm -f "${EROOT}"/usr/bin/${f}
320                         fi
321                 done
322         fi
323
324         # This will still break if you merge then remove the vi package,
325         # but there's only so much you can do, eh?  Unfortunately we don't
326         # have triggers like are done in rpm-land.
327 }
328
329 src_install() {
330         local vimfiles=/usr/share/vim/vim${VIM_VERSION/.}
331
332         # Note: Do not install symlinks for 'vi', 'ex', or 'view', as these are
333         #       managed by eselect-vi
334         dobin src/vim
335         dosym vim /usr/bin/vimdiff
336         dosym vim /usr/bin/rvim
337         dosym vim /usr/bin/rview
338         if use vim-pager ; then
339                 dosym ${vimfiles}/macros/less.sh /usr/bin/vimpager
340                 dosym ${vimfiles}/macros/manpager.sh /usr/bin/vimmanpager
341                 insinto ${vimfiles}/macros
342                 doins runtime/macros/manpager.sh
343                 fperms a+x ${vimfiles}/macros/manpager.sh
344         fi
345
346         newbashcomp "${FILESDIR}"/${PN}-completion ${PN}
347         # keep in sync with 'complete ... -F' list
348         bashcomp_alias vim ex vi view rvim rview vimdiff
349
350         # We shouldn't be installing the ex or view man page symlinks, as they
351         # are managed by eselect-vi
352         rm -f "${ED}"/usr/share/man/man1/{ex,view}.1
353 }
354
355 pkg_postinst() {
356         # Update documentation tags (from vim-doc.eclass)
357         update_vim_helptags
358
359         if [[ -z ${REPLACING_VERSIONS} ]] ; then
360                 if use X ; then
361                         echo
362                         elog "The 'X' USE flag enables vim <-> X communication, like"
363                         elog "updating the xterm titlebar. It does not install a GUI."
364                 fi
365                 echo
366                 elog "To install a GUI version of vim, use the app-editors/gvim"
367                 elog "package."
368                 echo
369                 elog "Vim 7 includes an integrated spell checker. You need to install"
370                 elog "word list files before you can use it. There are ebuilds for"
371                 elog "some of these named app-vim/vim-spell-*. If your language of"
372                 elog "choice is not included, please consult vim-spell.eclass for"
373                 elog "instructions on how to make a package."
374                 echo
375                 ewarn "Note that the English word lists are no longer installed by"
376                 ewarn "default."
377         fi
378
379         # Make convenience symlinks
380         update_vim_symlinks
381 }
382
383 pkg_postrm() {
384         # Update documentation tags (from vim-doc.eclass)
385         update_vim_helptags
386
387         # Make convenience symlinks
388         update_vim_symlinks
389 }