app-editors/emacs-vcs: Remove old.
[gentoo.git] / app-editors / emacs-vcs / emacs-vcs-25.0.9999-r2.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6
7 inherit autotools elisp-common flag-o-matic multilib readme.gentoo-r1
8
9 if [[ ${PV##*.} = 9999 ]]; then
10         inherit git-r3
11         EGIT_REPO_URI="git://git.sv.gnu.org/emacs.git"
12         EGIT_BRANCH="emacs-25"
13         EGIT_CHECKOUT_DIR="${WORKDIR}/emacs"
14         S="${EGIT_CHECKOUT_DIR}"
15 else
16         SRC_URI="https://dev.gentoo.org/~ulm/distfiles/emacs-${PV}.tar.xz
17                 mirror://gnu-alpha/emacs/pretest/emacs-${PV}.tar.xz"
18         KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
19         # FULL_VERSION keeps the full version number, which is needed in
20         # order to determine some path information correctly for copy/move
21         # operations later on
22         FULL_VERSION="${PV%%_*}"
23         S="${WORKDIR}/emacs-${FULL_VERSION}"
24         [[ ${FULL_VERSION} != ${PV} ]] && S="${WORKDIR}/emacs"
25 fi
26
27 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
28 HOMEPAGE="https://www.gnu.org/software/emacs/"
29
30 LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
31 SLOT="25"
32 IUSE="acl alsa aqua athena cairo dbus games gconf gfile gif gpm gsettings gtk +gtk3 gzip-el hesiod imagemagick +inotify jpeg kerberos libxml2 livecd m17n-lib motif pax_kernel png selinux sound source ssl svg tiff toolkit-scroll-bars wide-int X Xaw3d xft +xpm xwidgets zlib"
33 REQUIRED_USE="?? ( aqua X )"
34
35 RDEPEND="sys-libs/ncurses:0
36         >=app-eselect/eselect-emacs-1.16
37         >=app-emacs/emacs-common-gentoo-1.5[games?,X?]
38         net-libs/liblockfile
39         acl? ( virtual/acl )
40         alsa? ( media-libs/alsa-lib )
41         dbus? ( sys-apps/dbus )
42         gpm? ( sys-libs/gpm )
43         hesiod? ( net-dns/hesiod )
44         !inotify? ( gfile? ( >=dev-libs/glib-2.28.6 ) )
45         kerberos? ( virtual/krb5 )
46         libxml2? ( >=dev-libs/libxml2-2.2.0 )
47         selinux? ( sys-libs/libselinux )
48         ssl? ( net-libs/gnutls )
49         zlib? ( sys-libs/zlib )
50         X? (
51                 x11-libs/libXmu
52                 x11-libs/libXt
53                 x11-misc/xbitmaps
54                 gconf? ( >=gnome-base/gconf-2.26.2 )
55                 gsettings? ( >=dev-libs/glib-2.28.6 )
56                 gif? ( media-libs/giflib:0= )
57                 jpeg? ( virtual/jpeg:0= )
58                 png? ( >=media-libs/libpng-1.4:0= )
59                 svg? ( >=gnome-base/librsvg-2.0 )
60                 tiff? ( media-libs/tiff:0 )
61                 xpm? ( x11-libs/libXpm )
62                 imagemagick? ( >=media-gfx/imagemagick-6.6.2 )
63                 xft? (
64                         media-libs/fontconfig
65                         media-libs/freetype
66                         x11-libs/libXft
67                         cairo? ( >=x11-libs/cairo-1.12.18 )
68                         m17n-lib? (
69                                 >=dev-libs/libotf-0.9.4
70                                 >=dev-libs/m17n-lib-1.5.1
71                         )
72                 )
73                 gtk? (
74                         xwidgets? (
75                                 x11-libs/gtk+:3
76                                 net-libs/webkit-gtk:3=
77                         )
78                         !xwidgets? (
79                                 gtk3? ( x11-libs/gtk+:3 )
80                                 !gtk3? ( x11-libs/gtk+:2 )
81                         )
82                 )
83                 !gtk? (
84                         motif? ( >=x11-libs/motif-2.3:0 )
85                         !motif? (
86                                 Xaw3d? ( x11-libs/libXaw3d )
87                                 !Xaw3d? ( athena? ( x11-libs/libXaw ) )
88                         )
89                 )
90         )"
91
92 DEPEND="${RDEPEND}
93         virtual/pkgconfig
94         gzip-el? ( app-arch/gzip )
95         pax_kernel? (
96                 sys-apps/attr
97                 sys-apps/paxctl
98         )"
99
100 if [[ ${PV##*.} = 9999 ]]; then
101         DEPEND="${DEPEND}
102         sys-apps/texinfo"
103 fi
104
105 EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}"
106 SITEFILE="20${PN}-${SLOT}-gentoo.el"
107
108 src_prepare() {
109         if [[ ${PV##*.} = 9999 ]]; then
110                 FULL_VERSION=$(sed -n 's/^AC_INIT([^,]*,[ \t]*\([^ \t,)]*\).*/\1/p' \
111                         configure.ac)
112                 [[ ${FULL_VERSION} ]] || die "Cannot determine current Emacs version"
113                 einfo "Emacs branch: ${EGIT_BRANCH}"
114                 einfo "Commit: ${EGIT_VERSION}"
115                 einfo "Emacs version number: ${FULL_VERSION}"
116                 [[ ${FULL_VERSION} =~ ^${PV%.*}(\..*)?$ ]] \
117                         || die "Upstream version number changed to ${FULL_VERSION}"
118         fi
119
120         eapply_user
121
122         # Fix filename reference in redirected man page
123         sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \
124                 || die "unable to sed ctags.1"
125
126         AT_M4DIR=m4 eautoreconf
127 }
128
129 src_configure() {
130         strip-flags
131         filter-flags -pie                                       #526948
132
133         if use sh; then
134                 replace-flags "-O[1-9]" -O0             #262359
135         elif use ia64; then
136                 replace-flags "-O[2-9]" -O1             #325373
137         else
138                 replace-flags "-O[3-9]" -O2
139         fi
140
141         local myconf
142
143         if use alsa; then
144                 use sound || ewarn \
145                         "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
146                 myconf+=" --with-sound=alsa"
147         else
148                 myconf+=" --with-sound=$(usex sound oss)"
149         fi
150
151         if use X; then
152                 myconf+=" --with-x --without-ns"
153                 myconf+=" $(use_with gconf)"
154                 myconf+=" $(use_with gsettings)"
155                 myconf+=" $(use_with toolkit-scroll-bars)"
156                 myconf+=" $(use_with gif)"
157                 myconf+=" $(use_with jpeg)"
158                 myconf+=" $(use_with png)"
159                 myconf+=" $(use_with svg rsvg)"
160                 myconf+=" $(use_with tiff)"
161                 myconf+=" $(use_with xpm)"
162                 myconf+=" $(use_with imagemagick)"
163
164                 if use xft; then
165                         myconf+=" --with-xft"
166                         myconf+=" $(use_with cairo)"
167                         myconf+=" $(use_with m17n-lib libotf)"
168                         myconf+=" $(use_with m17n-lib m17n-flt)"
169                 else
170                         myconf+=" --without-xft"
171                         myconf+=" --without-cairo"
172                         myconf+=" --without-libotf --without-m17n-flt"
173                         use cairo && ewarn \
174                                 "USE flag \"cairo\" has no effect if \"xft\" is not set."
175                         use m17n-lib && ewarn \
176                                 "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
177                 fi
178
179                 local f
180                 if use gtk; then
181                         einfo "Configuring to build with GIMP Toolkit (GTK+)"
182                         while read line; do ewarn "${line}"; done <<-EOF
183                                 Your version of GTK+ will have problems with closing open
184                                 displays. This is no problem if you just use one display, but
185                                 if you use more than one and close one of them Emacs may crash.
186                                 See <https://bugzilla.gnome.org/show_bug.cgi?id=85715>.
187                                 If you intend to use more than one display, then it is strongly
188                                 recommended that you compile Emacs with the Athena/Lucid or the
189                                 Motif toolkit instead.
190                         EOF
191                         if use xwidgets; then
192                                 myconf+=" --with-x-toolkit=gtk3 --with-xwidgets"
193                         else
194                                 myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)"
195                                 myconf+=" --without-xwidgets"
196                         fi
197                         for f in motif Xaw3d athena; do
198                                 use ${f} && ewarn \
199                                         "USE flag \"${f}\" has no effect if \"gtk\" is set."
200                         done
201                 elif use motif; then
202                         einfo "Configuring to build with Motif toolkit"
203                         myconf+=" --with-x-toolkit=motif"
204                         for f in Xaw3d athena; do
205                                 use ${f} && ewarn \
206                                         "USE flag \"${f}\" has no effect if \"motif\" is set."
207                         done
208                 elif use athena || use Xaw3d; then
209                         einfo "Configuring to build with Athena/Lucid toolkit"
210                         myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
211                 else
212                         einfo "Configuring to build with no toolkit"
213                         myconf+=" --with-x-toolkit=no"
214                 fi
215                 ! use gtk && use xwidgets && ewarn \
216                         "USE flag \"xwidgets\" has no effect if \"gtk\" is not set."
217         elif use aqua; then
218                 einfo "Configuring to build with Nextstep (Cocoa) support"
219                 myconf+=" --with-ns --disable-ns-self-contained"
220                 myconf+=" --without-x"
221         else
222                 myconf+=" --without-x --without-ns"
223         fi
224
225         # Save version information in the Emacs binary. It will be available
226         # in variable "system-configuration-options".
227         myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
228
229         econf \
230                 --program-suffix="-${EMACS_SUFFIX}" \
231                 --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
232                 --localstatedir="${EPREFIX}"/var \
233                 --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
234                 --with-gameuser=":gamestat" \
235                 --without-compress-install \
236                 --with-file-notification=$(usev inotify || usev gfile || echo no) \
237                 $(use_enable acl) \
238                 $(use_with dbus) \
239                 $(use_with gpm) \
240                 $(use_with hesiod) \
241                 $(use_with kerberos) $(use_with kerberos kerberos5) \
242                 $(use_with libxml2 xml2) \
243                 $(use_with selinux) \
244                 $(use_with ssl gnutls) \
245                 $(use_with wide-int) \
246                 $(use_with zlib) \
247                 ${myconf}
248 }
249
250 src_compile() {
251         export SANDBOX_ON=0                     # for the unbelievers, see Bug #131505
252         emake
253 }
254
255 src_install () {
256         emake DESTDIR="${D}" NO_BIN_LINK=t install
257
258         mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} \
259                 || die "moving emacs executable failed"
260         mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 \
261                 || die "moving emacs man page failed"
262
263         # move info dir to avoid collisions with the dir file generated by portage
264         mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
265                 || die "moving info dir failed"
266         touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
267         docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
268
269         # avoid collision between slots, see bug #169033 e.g.
270         rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
271         rm -rf "${ED}"/usr/share/{appdata,applications,icons}
272         rm -rf "${ED}"/var
273
274         # remove unused <version>/site-lisp dir
275         rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
276
277         # remove COPYING file (except for etc/COPYING used by describe-copying)
278         rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
279
280         if use gzip-el; then
281                 # compress .el files when a corresponding .elc exists
282                 find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \
283                         -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n
284                 assert "gzip .el failed"
285         fi
286
287         local cdir
288         if use source; then
289                 cdir="/usr/share/emacs/${FULL_VERSION}/src"
290                 insinto "${cdir}"
291                 # This is not meant to install all the source -- just the
292                 # C source you might find via find-function
293                 doins src/*.{c,h,m}
294         elif has installsources ${FEATURES}; then
295                 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
296         fi
297
298         sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
299         X
300         ;;; ${PN}-${SLOT} site-lisp configuration
301         X
302         (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
303         Y  (setq find-function-C-source-directory
304         Y       "${EPREFIX}${cdir}")
305         X  (let ((path (getenv "INFOPATH"))
306         X       (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
307         X       (re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
308         X    (and path
309         X        ;; move Emacs Info dir before anything else in /usr/share/info
310         X        (let* ((p (cons nil (split-string path ":" t))) (q p))
311         X          (while (and (cdr q) (not (string-match re (cadr q))))
312         X            (setq q (cdr q)))
313         X          (setcdr q (cons dir (delete dir (cdr q))))
314         X          (setq Info-directory-list (prune-directory-list (cdr p)))))))
315         EOF
316         elisp-site-file-install "${T}/${SITEFILE}" || die
317
318         dodoc README BUGS CONTRIBUTE
319
320         if use aqua; then
321                 dodir /Applications/Gentoo
322                 rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
323                 mv nextstep/Emacs.app \
324                         "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
325         fi
326
327         DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
328                 through the Emacs eselect module, which also redirects man and info
329                 pages. Therefore, several Emacs versions can be installed at the
330                 same time. \"man emacs.eselect\" for details.
331                 \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is
332                 strongly recommended that you use app-admin/emacs-updater to rebuild
333                 all byte-compiled elisp files of the installed Emacs packages."
334         use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
335                 Installing media-fonts/font-adobe-{75,100}dpi on the X server's
336                 machine would satisfy basic Emacs requirements under X11.
337                 See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
338                 for how to enable anti-aliased fonts."
339         use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
340                 \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
341                 it into /Applications by yourself."
342         readme.gentoo_create_doc
343 }
344
345 pkg_preinst() {
346         # move Info dir file to correct name
347         local infodir=/usr/share/info/${EMACS_SUFFIX} f
348         if [[ -f ${ED}${infodir}/dir.orig ]]; then
349                 mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
350         elif [[ -d "${ED}"${infodir} ]]; then
351                 # this should not happen in EAPI 4
352                 ewarn "Regenerating Info directory index in ${infodir} ..."
353                 rm -f "${ED}"${infodir}/dir{,.*}
354                 for f in "${ED}"${infodir}/*; do
355                         if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
356                                 install-info --info-dir="${ED}"${infodir} "${f}" \
357                                         || die "install-info failed"
358                         fi
359                 done
360         fi
361 }
362
363 pkg_postinst() {
364         elisp-site-regen
365
366         local pvr
367         for pvr in ${REPLACING_VERSIONS}; do
368                 [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1
369         done
370         readme.gentoo_print_elog
371
372         if use livecd; then
373                 # force an update of the emacs symlink for the livecd/dvd,
374                 # because some microemacs packages set it with USE=livecd
375                 eselect emacs update
376         elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
377                 # refresh symlinks in case any installed files have changed
378                 eselect emacs set ${EMACS_SUFFIX}
379         else
380                 eselect emacs update ifunset
381         fi
382 }
383
384 pkg_postrm() {
385         elisp-site-regen
386         eselect emacs update ifunset
387 }