1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools elisp-common flag-o-matic readme.gentoo-r1
8 if [[ ${PV##*.} = 9999 ]]; then
10 EGIT_REPO_URI="https://git.savannah.gnu.org/git/emacs.git"
11 EGIT_BRANCH="emacs-27"
12 EGIT_CHECKOUT_DIR="${WORKDIR}/emacs"
13 S="${EGIT_CHECKOUT_DIR}"
15 SRC_URI="https://dev.gentoo.org/~ulm/distfiles/${P}.tar.xz
16 mirror://gnu-alpha/emacs/pretest/${P}.tar.xz"
17 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
18 # FULL_VERSION keeps the full version number, which is needed in
19 # order to determine some path information correctly for copy/move
21 FULL_VERSION="${PV%%_*}"
22 S="${WORKDIR}/emacs-${FULL_VERSION}"
23 [[ ${FULL_VERSION} != ${PV} ]] && S="${WORKDIR}/emacs"
26 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
27 HOMEPAGE="https://www.gnu.org/software/emacs/"
29 LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
31 IUSE="acl alsa aqua athena cairo dbus dynamic-loading games gconf gfile gif +gmp gpm gsettings gtk gtk2 gzip-el harfbuzz imagemagick +inotify jpeg json kerberos lcms libxml2 livecd m17n-lib mailutils motif png selinux sound source ssl svg systemd +threads tiff toolkit-scroll-bars wide-int X Xaw3d xft +xpm xwidgets zlib"
32 REQUIRED_USE="?? ( aqua X )"
35 RDEPEND="sys-libs/ncurses:0=
36 >=app-eselect/eselect-emacs-1.16
37 >=app-emacs/emacs-common-gentoo-1.5[games?,X?]
39 alsa? ( media-libs/alsa-lib )
40 dbus? ( sys-apps/dbus )
41 games? ( acct-group/gamestat )
42 gmp? ( dev-libs/gmp:0= )
44 !inotify? ( gfile? ( >=dev-libs/glib-2.28.6 ) )
45 json? ( dev-libs/jansson )
46 kerberos? ( virtual/krb5 )
47 lcms? ( media-libs/lcms:2 )
48 libxml2? ( >=dev-libs/libxml2-2.2.0 )
49 mailutils? ( net-mail/mailutils[clients] )
50 !mailutils? ( net-libs/liblockfile )
51 selinux? ( sys-libs/libselinux )
52 ssl? ( net-libs/gnutls:0= )
53 systemd? ( sys-apps/systemd )
54 zlib? ( sys-libs/zlib )
65 gconf? ( >=gnome-base/gconf-2.26.2 )
66 gsettings? ( >=dev-libs/glib-2.28.6 )
67 gif? ( media-libs/giflib:0= )
68 jpeg? ( virtual/jpeg:0= )
69 png? ( >=media-libs/libpng-1.4:0= )
70 svg? ( >=gnome-base/librsvg-2.0 )
71 tiff? ( media-libs/tiff:0 )
72 xpm? ( x11-libs/libXpm )
73 imagemagick? ( >=media-gfx/imagemagick-6.6.2:0= )
79 cairo? ( >=x11-libs/cairo-1.12.18 )
80 harfbuzz? ( media-libs/harfbuzz:0= )
82 >=dev-libs/libotf-0.9.4
83 >=dev-libs/m17n-lib-1.5.1
87 gtk2? ( x11-libs/gtk+:2 )
91 net-libs/webkit-gtk:4=
92 x11-libs/libXcomposite
98 >=x11-libs/motif-2.3:0
119 X? ( x11-base/xorg-proto )"
121 BDEPEND="sys-apps/texinfo
123 gzip-el? ( app-arch/gzip )"
126 !app-editors/emacs-vcs:27"
128 EMACS_SUFFIX="emacs-${SLOT}"
129 SITEFILE="20${EMACS_SUFFIX}-gentoo.el"
132 if [[ ${PV##*.} = 9999 ]]; then
133 FULL_VERSION=$(sed -n 's/^AC_INIT([^,]*,[ \t]*\([^ \t,)]*\).*/\1/p' \
135 [[ ${FULL_VERSION} ]] || die "Cannot determine current Emacs version"
136 einfo "Emacs branch: ${EGIT_BRANCH}"
137 einfo "Commit: ${EGIT_VERSION}"
138 einfo "Emacs version number: ${FULL_VERSION}"
139 [[ ${FULL_VERSION} =~ ^${PV%.*}(\..*)?$ ]] \
140 || die "Upstream version number changed to ${FULL_VERSION}"
145 # Fix filename reference in redirected man page
146 sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 || die
148 AT_M4DIR=m4 eautoreconf
153 filter-flags -pie #526948
156 replace-flags "-O[1-9]" -O0 #262359
158 replace-flags "-O[2-9]" -O1 #325373
160 replace-flags "-O[3-9]" -O2
167 "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
168 myconf+=" --with-sound=alsa"
170 myconf+=" --with-sound=$(usex sound oss)"
174 myconf+=" --with-x --without-ns"
175 myconf+=" $(use_with gconf)"
176 myconf+=" $(use_with gsettings)"
177 myconf+=" $(use_with toolkit-scroll-bars)"
178 myconf+=" $(use_with gif)"
179 myconf+=" $(use_with jpeg)"
180 myconf+=" $(use_with png)"
181 myconf+=" $(use_with svg rsvg)"
182 myconf+=" $(use_with tiff)"
183 myconf+=" $(use_with xpm)"
184 myconf+=" $(use_with imagemagick)"
187 myconf+=" --with-xft"
188 myconf+=" $(use_with cairo)"
189 myconf+=" $(use_with harfbuzz)"
190 myconf+=" $(use_with m17n-lib libotf)"
191 myconf+=" $(use_with m17n-lib m17n-flt)"
193 myconf+=" --without-xft"
194 myconf+=" --without-cairo"
195 myconf+=" --without-libotf --without-m17n-flt"
197 "USE flag \"cairo\" has no effect if \"xft\" is not set."
198 use m17n-lib && ewarn \
199 "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
204 einfo "Configuring to build with GIMP Toolkit (GTK+)"
205 while read line; do ewarn "${line}"; done <<-EOF
206 Your version of GTK+ will have problems with closing open
207 displays. This is no problem if you just use one display, but
208 if you use more than one and close one of them Emacs may crash.
209 See <https://bugzilla.gnome.org/show_bug.cgi?id=85715>.
210 If you intend to use more than one display, then it is strongly
211 recommended that you compile Emacs with the Athena/Lucid or the
212 Motif toolkit instead.
215 myconf+=" --with-x-toolkit=gtk2 --without-xwidgets"
216 use xwidgets && ewarn \
217 "USE flag \"xwidgets\" has no effect if \"gtk2\" is set."
219 myconf+=" --with-x-toolkit=gtk3 $(use_with xwidgets)"
221 for f in motif Xaw3d athena; do
223 "USE flag \"${f}\" has no effect if \"gtk\" is set."
226 einfo "Configuring to build with Motif toolkit"
227 myconf+=" --with-x-toolkit=motif"
228 for f in Xaw3d athena; do
230 "USE flag \"${f}\" has no effect if \"motif\" is set."
232 elif use athena || use Xaw3d; then
233 einfo "Configuring to build with Athena/Lucid toolkit"
234 myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
236 einfo "Configuring to build with no toolkit"
237 myconf+=" --with-x-toolkit=no"
241 "USE flag \"gtk2\" has no effect if \"gtk\" is not set."
242 use xwidgets && ewarn \
243 "USE flag \"xwidgets\" has no effect if \"gtk\" is not set."
246 einfo "Configuring to build with Nextstep (Cocoa) support"
247 myconf+=" --with-ns --disable-ns-self-contained"
248 myconf+=" --without-x"
250 myconf+=" --without-x --without-ns"
254 --program-suffix="-${EMACS_SUFFIX}" \
255 --includedir="${EPREFIX}"/usr/include/${EMACS_SUFFIX} \
256 --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
257 --localstatedir="${EPREFIX}"/var \
258 --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
259 --without-compress-install \
262 --with-dumping=pdumper \
263 --with-file-notification=$(usev inotify || usev gfile || echo no) \
266 $(use_with dynamic-loading modules) \
267 $(use_with games gameuser ":gamestat") \
268 $(use_with gmp libgmp) \
271 $(use_with kerberos) $(use_with kerberos kerberos5) \
272 $(use_with lcms lcms2) \
273 $(use_with libxml2 xml2) \
274 $(use_with mailutils) \
275 $(use_with selinux) \
276 $(use_with ssl gnutls) \
277 $(use_with systemd libsystemd) \
278 $(use_with threads) \
279 $(use_with wide-int) \
285 # # Disable sandbox when dumping. For the unbelievers, see bug #131505
286 # emake RUN_TEMACS="SANDBOX_ON=0 LD_PRELOAD= env ./temacs"
290 emake DESTDIR="${D}" NO_BIN_LINK=t install
292 mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} || die
293 mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 || die
294 mv "${ED}"/usr/share/metainfo/{emacs-,}${EMACS_SUFFIX}.appdata.xml || die
296 # move info dir to avoid collisions with the dir file generated by portage
297 mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} || die
298 touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
299 docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
301 # avoid collision between slots, see bug #169033 e.g.
302 rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
303 rm -rf "${ED}"/usr/share/{appdata,applications,icons}
304 rm -rf "${ED}/usr/$(get_libdir)"
307 # remove unused <version>/site-lisp dir
308 rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
310 # remove COPYING file (except for etc/COPYING used by describe-copying)
311 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
314 insinto /usr/lib/systemd/user
316 -e "/^ExecStart/s,emacs,${EPREFIX}/usr/bin/${EMACS_SUFFIX}," \
317 -e "/^ExecStop/s,emacsclient,${EPREFIX}/usr/bin/&-${EMACS_SUFFIX}," \
318 etc/emacs.service | newins - ${EMACS_SUFFIX}.service
323 # compress .el files when a corresponding .elc exists
324 find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \
325 -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n
326 assert "gzip .el failed"
331 cdir="/usr/share/emacs/${FULL_VERSION}/src"
333 # This is not meant to install all the source -- just the
334 # C source you might find via find-function
336 elif has installsources ${FEATURES}; then
337 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
340 sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF || die
342 ;;; ${EMACS_SUFFIX} site-lisp configuration
344 (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
345 Y (setq find-function-C-source-directory
346 Y "${EPREFIX}${cdir}")
347 X (let ((path (getenv "INFOPATH"))
348 X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
349 X (re "\\\\\`${EPREFIX}/usr/share\\\\>"))
351 X ;; move Emacs Info dir before anything else in /usr/share
352 X (let* ((p (cons nil (split-string path ":" t))) (q p))
353 X (while (and (cdr q) (not (string-match re (cadr q))))
355 X (setcdr q (cons dir (delete dir (cdr q))))
356 X (setq Info-directory-list (prune-directory-list (cdr p)))))))
358 elisp-site-file-install "${T}/${SITEFILE}" || die
360 dodoc README BUGS CONTRIBUTE
363 dodir /Applications/Gentoo
364 rm -rf "${ED}"/Applications/Gentoo/${EMACS_SUFFIX^}.app
365 mv nextstep/Emacs.app \
366 "${ED}"/Applications/Gentoo/${EMACS_SUFFIX^}.app || die
369 local DOC_CONTENTS="You can set the version to be started by
370 /usr/bin/emacs through the Emacs eselect module, which also
371 redirects man and info pages. Therefore, several Emacs versions can
372 be installed at the same time. \"man emacs.eselect\" for details.
373 \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is
374 strongly recommended that you use app-admin/emacs-updater to rebuild
375 all byte-compiled elisp files of the installed Emacs packages."
376 use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
377 Installing media-fonts/font-adobe-{75,100}dpi on the X server's
378 machine would satisfy basic Emacs requirements under X11.
379 See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
380 for how to enable anti-aliased fonts."
381 use aqua && DOC_CONTENTS+="\\n\\n${EMACS_SUFFIX^}.app is in
382 \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
383 it into /Applications by yourself."
384 readme.gentoo_create_doc
388 # move Info dir file to correct name
389 if [[ -d ${ED}/usr/share/info ]]; then
390 mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die
396 readme.gentoo_print_elog
399 # force an update of the emacs symlink for the livecd/dvd,
400 # because some microemacs packages set it with USE=livecd
402 elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
403 # refresh symlinks in case any installed files have changed
404 eselect emacs set ${EMACS_SUFFIX}
406 eselect emacs update ifunset
412 eselect emacs update ifunset