1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools elisp-common eutils flag-o-matic multilib readme.gentoo-r1
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"
13 LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
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 )"
19 RDEPEND="sys-libs/ncurses:0=
20 >=app-eselect/eselect-emacs-1.16
21 >=app-emacs/emacs-common-gentoo-1.5[games?,X?]
24 alsa? ( media-libs/alsa-lib )
25 dbus? ( sys-apps/dbus )
26 games? ( acct-group/gamestat )
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 )
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= )
57 >=dev-libs/libotf-0.9.4
58 >=dev-libs/m17n-lib-1.5.1
62 gtk2? ( x11-libs/gtk+:2 )
63 !gtk2? ( x11-libs/gtk+:3 )
67 >=x11-libs/motif-2.3:0
88 X? ( x11-base/xorg-proto )"
90 BDEPEND="virtual/pkgconfig
91 gzip-el? ( app-arch/gzip )"
94 !<app-editors/emacs-vcs-${PV}"
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}"
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"
112 AT_M4DIR=m4 eautoreconf
113 touch src/stamp-h.in || die
118 filter-flags -pie #526948
119 append-ldflags $(test-flags -no-pie) #639570
122 replace-flags "-O[1-9]" -O0 #262359
124 replace-flags "-O[2-9]" -O1 #325373
126 replace-flags "-O[3-9]" -O2
129 # Don't trigger a floating point exception for NaNs on alpha
130 use alpha && append-flags -mieee
136 "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
137 myconf+=" --with-sound=alsa"
139 myconf+=" --with-sound=$(usex sound oss)"
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)"
156 myconf+=" --with-xft"
157 myconf+=" $(use_with m17n-lib libotf)"
158 myconf+=" $(use_with m17n-lib m17n-flt)"
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."
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.
178 myconf+=" --with-x-toolkit=$(usex gtk2 gtk2 gtk3)"
179 for f in motif Xaw3d athena; do
181 "USE flag \"${f}\" has no effect if \"gtk\" is set."
184 einfo "Configuring to build with Motif toolkit"
185 myconf+=" --with-x-toolkit=motif"
186 for f in Xaw3d athena; do
188 "USE flag \"${f}\" has no effect if \"motif\" is set."
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)"
194 einfo "Configuring to build with no toolkit"
195 myconf+=" --with-x-toolkit=no"
197 ! use gtk && use gtk2 && ewarn \
198 "USE flag \"gtk2\" has no effect if \"gtk\" is not set."
200 einfo "Configuring to build with Nextstep (Cocoa) support"
201 myconf+=" --with-ns --disable-ns-self-contained"
202 myconf+=" --without-x"
204 myconf+=" --without-x --without-ns"
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 \
215 --with-file-notification=$(usev inotify || usev gfile || echo no) \
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) \
229 # Disable sandbox when dumping. For the unbelievers, see bug #131505
230 emake RUN_TEMACS="SANDBOX_ON=0 LD_PRELOAD= env ./temacs"
234 emake DESTDIR="${D}" NO_BIN_LINK=t install
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"
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
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}
252 # remove unused <version>/site-lisp dir
253 rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
255 # remove COPYING file (except for etc/COPYING used by describe-copying)
256 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
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"
267 cdir="/usr/share/emacs/${FULL_VERSION}/src"
269 # This is not meant to install all the source -- just the
270 # C source you might find via find-function
272 elif has installsources ${FEATURES}; then
273 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
276 sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF || die
278 ;;; ${PN}-${SLOT} site-lisp configuration
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\\\\>"))
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))))
291 X (setcdr q (cons dir (delete dir (cdr q))))
292 X (setq Info-directory-list (prune-directory-list (cdr p)))))))
294 elisp-site-file-install "${T}/${SITEFILE}" || die
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
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
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"
343 readme.gentoo_print_elog
346 # force an update of the emacs symlink for the livecd/dvd,
347 # because some microemacs packages set it with USE=livecd
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}
353 eselect emacs update ifunset
359 eselect emacs update ifunset