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