1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 inherit autotools elisp-common flag-o-matic readme.gentoo-r1 toolchain-funcs
9 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
10 HOMEPAGE="https://www.gnu.org/software/emacs/"
11 SRC_URI="mirror://gnu/emacs/${P}.tar.bz2
12 https://dev.gentoo.org/~ulm/emacs/${P}-patches-23.tar.xz"
14 LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
16 KEYWORDS="~alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~sh ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
17 IUSE="alsa aqua athena dbus games gconf gif gpm gtk gzip-el jpeg kerberos livecd m17n-lib motif png sound source svg tiff toolkit-scroll-bars X Xaw3d xft +xpm"
18 REQUIRED_USE="?? ( aqua X )"
20 RDEPEND="sys-libs/ncurses:0=
21 >=app-eselect/eselect-emacs-1.16
22 >=app-emacs/emacs-common-gentoo-1.5[games?,X?]
24 kerberos? ( virtual/krb5 )
25 alsa? ( media-libs/alsa-lib )
26 games? ( acct-group/gamestat )
28 dbus? ( sys-apps/dbus )
34 gconf? ( >=gnome-base/gconf-2.26.2 )
35 gif? ( media-libs/giflib:0= )
36 jpeg? ( virtual/jpeg:0= )
37 png? ( >=media-libs/libpng-1.4:0= )
38 svg? ( >=gnome-base/librsvg-2.0 )
39 tiff? ( media-libs/tiff:0 )
40 xpm? ( x11-libs/libXpm )
47 >=dev-libs/libotf-0.9.4
48 >=dev-libs/m17n-lib-1.5.1
51 gtk? ( x11-libs/gtk+:2 )
54 >=x11-libs/motif-2.3:0
78 X? ( x11-base/xorg-proto )"
80 BDEPEND="alsa? ( virtual/pkgconfig )
81 dbus? ( virtual/pkgconfig )
82 X? ( virtual/pkgconfig )
83 gzip-el? ( app-arch/gzip )"
85 EMACS_SUFFIX="emacs-${SLOT}"
86 SITEFILE="20${EMACS_SUFFIX}-gentoo.el"
87 # FULL_VERSION keeps the full version number, which is needed in
88 # order to determine some path information correctly for copy/move
90 FULL_VERSION="${PV%%_*}"
91 S="${WORKDIR}/emacs-${FULL_VERSION}"
97 sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \
98 || die "unable to sed ctags.1"
101 # ALSA is detected even if not requested by its USE flag.
102 # Suppress it by supplying pkg-config with a wrong library name.
103 sed -i -e "/ALSA_MODULES=/s/alsa/DiSaBlEaLsA/" configure.in \
104 || die "unable to sed configure.in"
106 if ! use gzip-el; then
107 # Emacs' build system automatically detects the gzip binary and
108 # compresses el files. We don't want that so confuse it with a
110 sed -i -e "s/ gzip/ PrEvEnTcOmPrEsSiOn/" configure.in \
111 || die "unable to sed configure.in"
114 mv configure.in configure.ac || die
116 touch src/stamp-h.in || die
121 filter-flags -fstrict-aliasing -pie
122 append-flags $(test-flags -fno-strict-aliasing)
123 append-ldflags $(test-flags -no-pie) #639568
126 replace-flags "-O[1-9]" -O0 #262359
128 replace-flags "-O[2-9]" -O1 #325373
130 replace-flags "-O[3-9]" -O2
133 # Don't trigger a floating point exception for NaNs on alpha
134 use alpha && append-flags -mieee
138 if use alsa && ! use sound; then
139 einfo "Although sound USE flag is disabled you chose to have alsa,"
140 einfo "so sound is switched on anyway."
141 myconf+=" --with-sound"
143 myconf+=" $(use_with sound)"
147 myconf+=" --with-x --without-ns"
148 myconf+=" $(use_with gconf)"
149 myconf+=" $(use_with toolkit-scroll-bars)"
150 myconf+=" $(use_with gif)"
151 myconf+=" $(use_with jpeg)"
152 myconf+=" $(use_with png)"
153 myconf+=" $(use_with svg rsvg)"
154 myconf+=" $(use_with tiff)"
155 myconf+=" $(use_with xpm)"
158 myconf+=" --with-xft"
159 myconf+=" $(use_with m17n-lib libotf)"
160 myconf+=" $(use_with m17n-lib m17n-flt)"
162 myconf+=" --without-xft"
163 myconf+=" --without-libotf --without-m17n-flt"
164 use m17n-lib && ewarn \
165 "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
168 # GTK+ is the default toolkit if USE=gtk is chosen with other
169 # possibilities. Emacs upstream thinks this should be standard
170 # policy on all distributions
173 einfo "Configuring to build with GIMP Toolkit (GTK+)"
174 myconf+=" --with-x-toolkit=gtk"
175 for f in motif Xaw3d athena; do
177 "USE flag \"${f}\" has no effect if \"gtk\" is set."
180 einfo "Configuring to build with Motif toolkit"
181 myconf+=" --with-x-toolkit=motif"
182 for f in Xaw3d athena; do
184 "USE flag \"${f}\" has no effect if \"motif\" is set."
186 elif use athena || use Xaw3d; then
187 einfo "Configuring to build with Athena/Lucid toolkit"
188 myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
190 einfo "Configuring to build with no toolkit"
191 myconf+=" --with-x-toolkit=no"
194 einfo "Configuring to build with Nextstep (Cocoa) support"
195 myconf+=" --with-ns --disable-ns-self-contained"
196 myconf+=" --without-x"
198 myconf+=" --without-x --without-ns"
201 # According to configure, this option is only used for GNU/Linux
202 # (x86_64 and s390). For Gentoo Prefix we have to explicitly spell
203 # out the location because $(get_libdir) does not necessarily return
204 # something that matches the host OS's libdir naming (e.g. RHEL).
205 local crtdir=$($(tc-getCC) -print-file-name=crt1.o)
209 --program-suffix="-${EMACS_SUFFIX}" \
210 --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
211 --localstatedir="${EPREFIX}"/var \
212 --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
213 --with-crt-dir="${crtdir}" \
214 --with-gameuser=":gamestat" \
216 $(use_with kerberos) $(use_with kerberos kerberos5) \
223 # Disable sandbox when dumping. For the unbelievers, see bug #131505
224 emake CC="$(tc-getCC)" \
225 AR="$(tc-getAR) cq" \
226 RANLIB="$(tc-getRANLIB)" \
227 RUN_TEMACS="SANDBOX_ON=0 LD_PRELOAD= env ./temacs"
231 emake DESTDIR="${D}" install
233 rm "${ED}"/usr/bin/emacs-${FULL_VERSION}-${EMACS_SUFFIX} \
234 || die "removing duplicate emacs executable failed"
235 mv "${ED}"/usr/bin/emacs-${EMACS_SUFFIX} "${ED}"/usr/bin/${EMACS_SUFFIX} \
236 || die "moving emacs executable failed"
238 # move man pages to the correct place
240 mv "${ED}"/usr/share/man/man1/{emacs,${EMACS_SUFFIX}}.1 \
241 || die "moving emacs man page failed"
242 for m in b2m ctags ebrowse emacsclient etags grep-changelog rcs-checkin; do
243 mv "${ED}"/usr/share/man/man1/${m}{,-${EMACS_SUFFIX}}.1 \
244 || die "moving ${m} man page failed"
247 # move info dir to avoid collisions with the dir file generated by portage
248 mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
249 || die "moving info dir failed"
250 touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
251 docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
253 # avoid collision between slots, see bug #169033 e.g.
254 rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
255 rm -rf "${ED}"/usr/share/{applications,icons}
258 # remove unused <version>/site-lisp dir
259 rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
261 # remove COPYING file (except for etc/COPYING used by describe-copying)
262 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
266 cdir="/usr/share/emacs/${FULL_VERSION}/src"
268 # This is not meant to install all the source -- just the
269 # C source you might find via find-function
272 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/src/Makefile.c
273 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/src/{m,s}/README
274 elif has installsources ${FEATURES}; then
275 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
278 sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF || die
280 ;;; ${EMACS_SUFFIX} site-lisp configuration
282 (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
283 Y (setq find-function-C-source-directory
284 Y "${EPREFIX}${cdir}")
285 X (let ((path (getenv "INFOPATH"))
286 X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
287 X (re "\\\\\`${EPREFIX}/usr/share\\\\>"))
289 X ;; move Emacs Info dir before anything else in /usr/share
290 X (let* ((p (cons nil (split-string path ":" t))) (q p))
291 X (while (and (cdr q) (not (string-match re (cadr q))))
293 X (setcdr q (cons dir (delete dir (cdr q))))
294 X (setq Info-directory-list (prune-directory-list (cdr p)))))))
296 elisp-site-file-install "${T}/${SITEFILE}" || die
301 dodir /Applications/Gentoo
302 rm -rf "${ED}"/Applications/Gentoo/${EMACS_SUFFIX^}.app
303 mv nextstep/Emacs.app \
304 "${ED}"/Applications/Gentoo/${EMACS_SUFFIX^}.app || die
307 local DOC_CONTENTS="You can set the version to be started by
308 /usr/bin/emacs through the Emacs eselect module, which also
309 redirects man and info pages. Therefore, several Emacs versions can
310 be installed at the same time. \"man emacs.eselect\" for details.
311 \\n\\nIf you upgrade from a previous major version of Emacs, then
312 it is strongly recommended that you use app-admin/emacs-updater
313 to rebuild all byte-compiled elisp files of the installed Emacs
315 use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
316 Installing media-fonts/font-adobe-{75,100}dpi on the X server's
317 machine would satisfy basic Emacs requirements under X11.
318 See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
319 for how to enable anti-aliased fonts."
320 use aqua && DOC_CONTENTS+="\\n\\n${EMACS_SUFFIX^}.app is in
321 \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
322 it into /Applications by yourself."
323 readme.gentoo_create_doc
327 # move Info dir file to correct name
328 if [[ -d ${ED}/usr/share/info ]]; then
329 mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
335 readme.gentoo_print_elog
338 # force an update of the emacs symlink for the livecd/dvd,
339 # because some microemacs packages set it with USE=livecd
341 elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
342 # refresh symlinks in case any installed files have changed
343 eselect emacs set ${EMACS_SUFFIX}
345 eselect emacs update ifunset
351 eselect emacs update ifunset