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