Line 0
Link Here
|
|
|
1 |
# Copyright 1999-2021 Gentoo Authors |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
|
4 |
EAPI=8 |
5 |
|
6 |
inherit autotools elisp-common flag-o-matic readme.gentoo-r1 toolchain-funcs |
7 |
|
8 |
if [[ ${PV##*.} = 9999 ]]; then |
9 |
inherit git-r3 |
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}" |
14 |
SLOT="${PV%%.*}-vcs" |
15 |
else |
16 |
# FULL_VERSION keeps the full version number, which is needed in |
17 |
# order to determine some path information correctly for copy/move |
18 |
# operations later on |
19 |
FULL_VERSION="${PV%%_*}" |
20 |
SRC_URI="mirror://gnu/emacs/${P}.tar.xz" |
21 |
S="${WORKDIR}/emacs-${FULL_VERSION}" |
22 |
# PV can be in any of the following formats: |
23 |
# 27.1 released version (slot 27) |
24 |
# 27.1_rc1 upstream release candidate (27) |
25 |
# 27.0.9999 live ebuild (slot 27-vcs) |
26 |
# 27.0.90 upstream prerelease snapshot (27-vcs) |
27 |
# 27.0.50_pre20191223 snapshot by Gentoo developer (27-vcs) |
28 |
if [[ ${PV} == *_pre* ]]; then |
29 |
SRC_URI="https://dev.gentoo.org/~ulm/distfiles/${P}.tar.xz" |
30 |
S="${WORKDIR}/emacs" |
31 |
elif [[ ${PV//[0-9]} != "." ]]; then |
32 |
SRC_URI="https://alpha.gnu.org/gnu/emacs/pretest/${PN}-${PV/_/-}.tar.xz" |
33 |
fi |
34 |
# Patchset from proj/emacs-patches.git |
35 |
SRC_URI+=" https://dev.gentoo.org/~ulm/emacs/${P}-patches-1.tar.xz" |
36 |
PATCHES=("${WORKDIR}/patch") |
37 |
SLOT="${PV%%.*}" |
38 |
[[ ${PV} == *.*.* ]] && SLOT+="-vcs" |
39 |
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" |
40 |
fi |
41 |
|
42 |
DESCRIPTION="The extensible, customizable, self-documenting real-time display editor" |
43 |
HOMEPAGE="https://www.gnu.org/software/emacs/" |
44 |
|
45 |
LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2" |
46 |
IUSE="acl alsa aqua athena cairo dbus dynamic-loading games gconf gfile gif +gmp gpm gsettings gtk gui 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 Xaw3d xft +xpm xwidgets zlib" |
47 |
RESTRICT="test" |
48 |
|
49 |
RDEPEND="app-emacs/emacs-common[games?,gui(-)?] |
50 |
sys-libs/ncurses:0= |
51 |
acl? ( virtual/acl ) |
52 |
alsa? ( media-libs/alsa-lib ) |
53 |
dbus? ( sys-apps/dbus ) |
54 |
games? ( acct-group/gamestat ) |
55 |
gmp? ( dev-libs/gmp:0= ) |
56 |
gpm? ( sys-libs/gpm ) |
57 |
!inotify? ( gfile? ( >=dev-libs/glib-2.28.6 ) ) |
58 |
json? ( dev-libs/jansson ) |
59 |
kerberos? ( virtual/krb5 ) |
60 |
lcms? ( media-libs/lcms:2 ) |
61 |
libxml2? ( >=dev-libs/libxml2-2.2.0 ) |
62 |
mailutils? ( net-mail/mailutils[clients] ) |
63 |
!mailutils? ( acct-group/mail net-libs/liblockfile ) |
64 |
selinux? ( sys-libs/libselinux ) |
65 |
ssl? ( net-libs/gnutls:0= ) |
66 |
systemd? ( sys-apps/systemd ) |
67 |
zlib? ( sys-libs/zlib ) |
68 |
gui? ( !aqua? ( |
69 |
x11-libs/libICE |
70 |
x11-libs/libSM |
71 |
x11-libs/libX11 |
72 |
x11-libs/libXext |
73 |
x11-libs/libXfixes |
74 |
x11-libs/libXinerama |
75 |
x11-libs/libXrandr |
76 |
x11-libs/libxcb |
77 |
x11-misc/xbitmaps |
78 |
gconf? ( >=gnome-base/gconf-2.26.2 ) |
79 |
gsettings? ( >=dev-libs/glib-2.28.6 ) |
80 |
gif? ( media-libs/giflib:0= ) |
81 |
jpeg? ( virtual/jpeg:0= ) |
82 |
png? ( >=media-libs/libpng-1.4:0= ) |
83 |
svg? ( >=gnome-base/librsvg-2.0 ) |
84 |
tiff? ( media-libs/tiff:0 ) |
85 |
xpm? ( x11-libs/libXpm ) |
86 |
imagemagick? ( >=media-gfx/imagemagick-6.6.2:0= ) |
87 |
xft? ( |
88 |
media-libs/fontconfig |
89 |
media-libs/freetype |
90 |
x11-libs/libXft |
91 |
x11-libs/libXrender |
92 |
cairo? ( >=x11-libs/cairo-1.12.18 ) |
93 |
harfbuzz? ( media-libs/harfbuzz:0= ) |
94 |
m17n-lib? ( |
95 |
>=dev-libs/libotf-0.9.4 |
96 |
>=dev-libs/m17n-lib-1.5.1 |
97 |
) |
98 |
) |
99 |
gtk? ( |
100 |
x11-libs/gtk+:3 |
101 |
xwidgets? ( |
102 |
net-libs/webkit-gtk:4= |
103 |
x11-libs/libXcomposite |
104 |
) |
105 |
) |
106 |
!gtk? ( |
107 |
motif? ( |
108 |
>=x11-libs/motif-2.3:0 |
109 |
x11-libs/libXpm |
110 |
x11-libs/libXmu |
111 |
x11-libs/libXt |
112 |
) |
113 |
!motif? ( |
114 |
Xaw3d? ( |
115 |
x11-libs/libXaw3d |
116 |
x11-libs/libXmu |
117 |
x11-libs/libXt |
118 |
) |
119 |
!Xaw3d? ( athena? ( |
120 |
x11-libs/libXaw |
121 |
x11-libs/libXmu |
122 |
x11-libs/libXt |
123 |
) ) |
124 |
) |
125 |
) |
126 |
) )" |
127 |
|
128 |
DEPEND="${RDEPEND} |
129 |
gui? ( !aqua? ( x11-base/xorg-proto ) )" |
130 |
|
131 |
BDEPEND="sys-apps/texinfo |
132 |
virtual/pkgconfig |
133 |
gzip-el? ( app-arch/gzip )" |
134 |
|
135 |
RDEPEND="${RDEPEND} |
136 |
!app-editors/emacs-vcs:27" |
137 |
|
138 |
IDEPEND="app-eselect/eselect-emacs" |
139 |
|
140 |
EMACS_SUFFIX="emacs-${SLOT}" |
141 |
SITEFILE="20${EMACS_SUFFIX}-gentoo.el" |
142 |
|
143 |
src_prepare() { |
144 |
if [[ ${PV##*.} = 9999 ]]; then |
145 |
FULL_VERSION=$(sed -n 's/^AC_INIT([^,]*,[ \t]*\([^ \t,)]*\).*/\1/p' \ |
146 |
configure.ac) |
147 |
[[ ${FULL_VERSION} ]] || die "Cannot determine current Emacs version" |
148 |
einfo "Emacs branch: ${EGIT_BRANCH}" |
149 |
einfo "Commit: ${EGIT_VERSION}" |
150 |
einfo "Emacs version number: ${FULL_VERSION}" |
151 |
[[ ${FULL_VERSION} =~ ^${PV%.*}(\..*)?$ ]] \ |
152 |
|| die "Upstream version number changed to ${FULL_VERSION}" |
153 |
fi |
154 |
|
155 |
default |
156 |
|
157 |
# Fix filename reference in redirected man page |
158 |
sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 || die |
159 |
|
160 |
#AT_M4DIR=m4 eautoreconf |
161 |
} |
162 |
|
163 |
src_configure() { |
164 |
strip-flags |
165 |
filter-flags -pie #526948 |
166 |
|
167 |
if use ia64; then |
168 |
replace-flags "-O[2-9]" -O1 #325373 |
169 |
else |
170 |
replace-flags "-O[3-9]" -O2 |
171 |
fi |
172 |
|
173 |
local myconf |
174 |
|
175 |
if use alsa; then |
176 |
use sound || ewarn \ |
177 |
"USE flag \"alsa\" overrides \"-sound\"; enabling sound support." |
178 |
myconf+=" --with-sound=alsa" |
179 |
else |
180 |
myconf+=" --with-sound=$(usex sound oss)" |
181 |
fi |
182 |
|
183 |
if ! use gui; then |
184 |
einfo "Configuring to build without window system support" |
185 |
myconf+=" --without-x --without-ns" |
186 |
elif use aqua; then |
187 |
einfo "Configuring to build with Nextstep (Macintosh Cocoa) support" |
188 |
myconf+=" --with-ns --disable-ns-self-contained" |
189 |
myconf+=" --without-x" |
190 |
else |
191 |
myconf+=" --with-x --without-ns" |
192 |
myconf+=" $(use_with gconf)" |
193 |
myconf+=" $(use_with gsettings)" |
194 |
myconf+=" $(use_with toolkit-scroll-bars)" |
195 |
myconf+=" $(use_with gif)" |
196 |
myconf+=" $(use_with jpeg)" |
197 |
myconf+=" $(use_with png)" |
198 |
myconf+=" $(use_with svg rsvg)" |
199 |
myconf+=" $(use_with tiff)" |
200 |
myconf+=" $(use_with xpm)" |
201 |
myconf+=" $(use_with imagemagick)" |
202 |
|
203 |
if use xft; then |
204 |
myconf+=" --with-xft" |
205 |
myconf+=" $(use_with cairo)" |
206 |
myconf+=" $(use_with harfbuzz)" |
207 |
myconf+=" $(use_with m17n-lib libotf)" |
208 |
myconf+=" $(use_with m17n-lib m17n-flt)" |
209 |
else |
210 |
myconf+=" --without-xft" |
211 |
myconf+=" --without-cairo" |
212 |
myconf+=" --without-libotf --without-m17n-flt" |
213 |
use cairo && ewarn \ |
214 |
"USE flag \"cairo\" has no effect if \"xft\" is not set." |
215 |
use m17n-lib && ewarn \ |
216 |
"USE flag \"m17n-lib\" has no effect if \"xft\" is not set." |
217 |
fi |
218 |
|
219 |
local f line |
220 |
if use gtk; then |
221 |
einfo "Configuring to build with GIMP Toolkit (GTK+)" |
222 |
while read line; do ewarn "${line}"; done <<-EOF |
223 |
Your version of GTK+ will have problems with closing open |
224 |
displays. This is no problem if you just use one display, but |
225 |
if you use more than one and close one of them Emacs may crash. |
226 |
See <https://gitlab.gnome.org/GNOME/gtk/-/issues/221> and |
227 |
<https://gitlab.gnome.org/GNOME/gtk/-/issues/2315>. |
228 |
If you intend to use more than one display, then it is strongly |
229 |
recommended that you compile Emacs with the Athena/Lucid or the |
230 |
Motif toolkit instead. |
231 |
EOF |
232 |
myconf+=" --with-x-toolkit=gtk3 $(use_with xwidgets)" |
233 |
for f in motif Xaw3d athena; do |
234 |
use ${f} && ewarn \ |
235 |
"USE flag \"${f}\" has no effect if \"gtk\" is set." |
236 |
done |
237 |
elif use motif; then |
238 |
einfo "Configuring to build with Motif toolkit" |
239 |
myconf+=" --with-x-toolkit=motif" |
240 |
for f in Xaw3d athena; do |
241 |
use ${f} && ewarn \ |
242 |
"USE flag \"${f}\" has no effect if \"motif\" is set." |
243 |
done |
244 |
elif use athena || use Xaw3d; then |
245 |
einfo "Configuring to build with Athena/Lucid toolkit" |
246 |
myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)" |
247 |
else |
248 |
einfo "Configuring to build with no toolkit" |
249 |
myconf+=" --with-x-toolkit=no" |
250 |
fi |
251 |
! use gtk && use xwidgets && ewarn \ |
252 |
"USE flag \"xwidgets\" has no effect if \"gtk\" is not set." |
253 |
fi |
254 |
|
255 |
if tc-is-cross-compiler; then |
256 |
# Configure a CBUILD directory when cross-compiling to make tools |
257 |
mkdir "${S}-build" && pushd "${S}-build" >/dev/null || die |
258 |
ECONF_SOURCE="${S}" econf_build --without-all --without-x-toolkit |
259 |
popd >/dev/null || die |
260 |
# Don't try to execute the binary for dumping during the build |
261 |
myconf+=" --with-dumping=none" |
262 |
else |
263 |
myconf+=" --with-dumping=pdumper" |
264 |
fi |
265 |
|
266 |
econf \ |
267 |
--program-suffix="-${EMACS_SUFFIX}" \ |
268 |
--includedir="${EPREFIX}"/usr/include/${EMACS_SUFFIX} \ |
269 |
--infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \ |
270 |
--localstatedir="${EPREFIX}"/var \ |
271 |
--enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \ |
272 |
--without-compress-install \ |
273 |
--without-hesiod \ |
274 |
--without-pop \ |
275 |
--with-file-notification=$(usev inotify || usev gfile || echo no) \ |
276 |
--with-pdumper \ |
277 |
$(use_enable acl) \ |
278 |
$(use_with dbus) \ |
279 |
$(use_with dynamic-loading modules) \ |
280 |
$(use_with games gameuser ":gamestat") \ |
281 |
$(use_with gmp libgmp) \ |
282 |
$(use_with gpm) \ |
283 |
$(use_with json) \ |
284 |
$(use_with kerberos) $(use_with kerberos kerberos5) \ |
285 |
$(use_with lcms lcms2) \ |
286 |
$(use_with libxml2 xml2) \ |
287 |
$(use_with mailutils) \ |
288 |
$(use_with selinux) \ |
289 |
$(use_with ssl gnutls) \ |
290 |
$(use_with systemd libsystemd) \ |
291 |
$(use_with threads) \ |
292 |
$(use_with wide-int) \ |
293 |
$(use_with zlib) \ |
294 |
${myconf} |
295 |
} |
296 |
|
297 |
src_compile() { |
298 |
if tc-is-cross-compiler; then |
299 |
# Build native tools for compiling lisp etc. |
300 |
emake -C "${S}-build" src |
301 |
emake lib # Cross-compile dependencies first for timestamps |
302 |
# Save native build tools in the cross-directory |
303 |
cp "${S}-build"/lib-src/make-{docfile,fingerprint} lib-src || die |
304 |
# Specify the native Emacs to compile lisp |
305 |
emake -C lisp all EMACS="${S}-build/src/emacs" |
306 |
fi |
307 |
|
308 |
emake |
309 |
} |
310 |
|
311 |
src_install() { |
312 |
emake DESTDIR="${D}" NO_BIN_LINK=t BLESSMAIL_TARGET= install |
313 |
|
314 |
mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} || die |
315 |
mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 || die |
316 |
mv "${ED}"/usr/share/metainfo/{emacs-,}${EMACS_SUFFIX}.appdata.xml || die |
317 |
|
318 |
# move info dir to avoid collisions with the dir file generated by portage |
319 |
mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} || die |
320 |
touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir |
321 |
docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig |
322 |
|
323 |
# movemail must be setgid mail |
324 |
if ! use mailutils; then |
325 |
fowners root:mail /usr/libexec/emacs/${FULL_VERSION}/${CHOST}/movemail |
326 |
fperms 2751 /usr/libexec/emacs/${FULL_VERSION}/${CHOST}/movemail |
327 |
fi |
328 |
|
329 |
# avoid collision between slots, see bug #169033 e.g. |
330 |
rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el || die |
331 |
rm -rf "${ED}"/usr/share/{applications,icons} || die |
332 |
rm -rf "${ED}/usr/$(get_libdir)" || die |
333 |
rm -rf "${ED}"/var || die |
334 |
|
335 |
# remove unused <version>/site-lisp dir |
336 |
rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp || die |
337 |
|
338 |
# remove COPYING file (except for etc/COPYING used by describe-copying) |
339 |
rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING || die |
340 |
|
341 |
if use systemd; then |
342 |
insinto /usr/lib/systemd/user |
343 |
sed -e "/^##/d" \ |
344 |
-e "/^ExecStart/s,emacs,${EPREFIX}/usr/bin/${EMACS_SUFFIX}," \ |
345 |
-e "/^ExecStop/s,emacsclient,${EPREFIX}/usr/bin/&-${EMACS_SUFFIX}," \ |
346 |
etc/emacs.service | newins - ${EMACS_SUFFIX}.service |
347 |
assert |
348 |
fi |
349 |
|
350 |
if use gzip-el; then |
351 |
# compress .el files when a corresponding .elc exists |
352 |
find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \ |
353 |
-name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n |
354 |
assert "gzip .el failed" |
355 |
fi |
356 |
|
357 |
local cdir |
358 |
if use source; then |
359 |
cdir="/usr/share/emacs/${FULL_VERSION}/src" |
360 |
insinto "${cdir}" |
361 |
# This is not meant to install all the source -- just the |
362 |
# C source you might find via find-function |
363 |
doins src/*.{c,h,m} |
364 |
elif has installsources ${FEATURES}; then |
365 |
cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src" |
366 |
fi |
367 |
|
368 |
sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF || die |
369 |
X |
370 |
;;; ${EMACS_SUFFIX} site-lisp configuration |
371 |
X |
372 |
(when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version) |
373 |
Y (setq find-function-C-source-directory |
374 |
Y "${EPREFIX}${cdir}") |
375 |
X (let ((path (getenv "INFOPATH")) |
376 |
X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}") |
377 |
X (re "\\\\\`${EPREFIX}/usr/share\\\\>")) |
378 |
X (and path |
379 |
X ;; move Emacs Info dir before anything else in /usr/share |
380 |
X (let* ((p (cons nil (split-string path ":" t))) (q p)) |
381 |
X (while (and (cdr q) (not (string-match re (cadr q)))) |
382 |
X (setq q (cdr q))) |
383 |
X (setcdr q (cons dir (delete dir (cdr q)))) |
384 |
X (setq Info-directory-list (prune-directory-list (cdr p))))))) |
385 |
EOF |
386 |
elisp-site-file-install "${T}/${SITEFILE}" || die |
387 |
|
388 |
dodoc README BUGS CONTRIBUTE |
389 |
|
390 |
if use gui && use aqua; then |
391 |
dodir /Applications/Gentoo |
392 |
rm -rf "${ED}"/Applications/Gentoo/${EMACS_SUFFIX^}.app || die |
393 |
mv nextstep/Emacs.app \ |
394 |
"${ED}"/Applications/Gentoo/${EMACS_SUFFIX^}.app || die |
395 |
fi |
396 |
|
397 |
local DOC_CONTENTS="You can set the version to be started by |
398 |
/usr/bin/emacs through the Emacs eselect module, which also |
399 |
redirects man and info pages. Therefore, several Emacs versions can |
400 |
be installed at the same time. \"man emacs.eselect\" for details. |
401 |
\\n\\nIf you upgrade from a previous major version of Emacs, then |
402 |
it is strongly recommended that you use app-admin/emacs-updater |
403 |
to rebuild all byte-compiled elisp files of the installed Emacs |
404 |
packages." |
405 |
if use gui; then |
406 |
DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs. |
407 |
Installing media-fonts/font-adobe-{75,100}dpi on the X server's |
408 |
machine would satisfy basic Emacs requirements under X11. |
409 |
See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs |
410 |
for how to enable anti-aliased fonts." |
411 |
use aqua && DOC_CONTENTS+="\\n\\n${EMACS_SUFFIX^}.app is in |
412 |
\"${EPREFIX}/Applications/Gentoo\". You may want to copy or |
413 |
symlink it into /Applications by yourself." |
414 |
fi |
415 |
tc-is-cross-compiler && DOC_CONTENTS+="\\n\\nEmacs did not write |
416 |
a portable dump file due to being cross-compiled. |
417 |
To create this file at run time, execute the following command: |
418 |
\\n${EMACS_SUFFIX} --batch -Q --eval='(dump-emacs-portable |
419 |
\"/usr/libexec/emacs/${FULL_VERSION}/${CHOST}/emacs.pdmp\")'" |
420 |
readme.gentoo_create_doc |
421 |
} |
422 |
|
423 |
pkg_preinst() { |
424 |
# move Info dir file to correct name |
425 |
if [[ -d ${ED}/usr/share/info ]]; then |
426 |
mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{.orig,} || die |
427 |
fi |
428 |
} |
429 |
|
430 |
pkg_postinst() { |
431 |
elisp-site-regen |
432 |
readme.gentoo_print_elog |
433 |
|
434 |
if use livecd; then |
435 |
# force an update of the emacs symlink for the livecd/dvd, |
436 |
# because some microemacs packages set it with USE=livecd |
437 |
eselect emacs update |
438 |
else |
439 |
eselect emacs update ifunset |
440 |
fi |
441 |
} |
442 |
|
443 |
pkg_postrm() { |
444 |
elisp-site-regen |
445 |
if has_version -b app-eselect/eselect-emacs; then |
446 |
eselect emacs update ifunset |
447 |
fi |
448 |
} |