1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit autotools elisp-common flag-o-matic multilib readme.gentoo-r1
9 if [[ ${PV##*.} = 9999 ]]; then
11 EGIT_REPO_URI="git://git.sv.gnu.org/emacs.git"
12 EGIT_BRANCH="emacs-25"
13 EGIT_CHECKOUT_DIR="${WORKDIR}/emacs"
14 S="${EGIT_CHECKOUT_DIR}"
16 SRC_URI="https://dev.gentoo.org/~ulm/distfiles/emacs-${PV}.tar.xz
17 mirror://gnu-alpha/emacs/pretest/emacs-${PV}.tar.xz"
18 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
19 # FULL_VERSION keeps the full version number, which is needed in
20 # order to determine some path information correctly for copy/move
22 FULL_VERSION="${PV%%_*}"
23 S="${WORKDIR}/emacs-${FULL_VERSION}"
24 [[ ${FULL_VERSION} != ${PV} ]] && S="${WORKDIR}/emacs"
27 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
28 HOMEPAGE="https://www.gnu.org/software/emacs/"
30 LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
32 IUSE="acl alsa aqua athena cairo dbus games gconf gfile gif gpm gsettings gtk +gtk3 gzip-el hesiod imagemagick +inotify jpeg kerberos libxml2 livecd m17n-lib motif pax_kernel png selinux sound source ssl svg tiff toolkit-scroll-bars wide-int X Xaw3d xft +xpm xwidgets zlib"
33 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?]
40 alsa? ( media-libs/alsa-lib )
41 dbus? ( sys-apps/dbus )
43 hesiod? ( net-dns/hesiod )
44 !inotify? ( gfile? ( >=dev-libs/glib-2.28.6 ) )
45 kerberos? ( virtual/krb5 )
46 libxml2? ( >=dev-libs/libxml2-2.2.0 )
47 selinux? ( sys-libs/libselinux )
48 ssl? ( net-libs/gnutls )
49 zlib? ( sys-libs/zlib )
54 gconf? ( >=gnome-base/gconf-2.26.2 )
55 gsettings? ( >=dev-libs/glib-2.28.6 )
56 gif? ( media-libs/giflib:0= )
57 jpeg? ( virtual/jpeg:0= )
58 png? ( >=media-libs/libpng-1.4:0= )
59 svg? ( >=gnome-base/librsvg-2.0 )
60 tiff? ( media-libs/tiff:0 )
61 xpm? ( x11-libs/libXpm )
62 imagemagick? ( >=media-gfx/imagemagick-6.6.2 )
67 cairo? ( >=x11-libs/cairo-1.12.18 )
69 >=dev-libs/libotf-0.9.4
70 >=dev-libs/m17n-lib-1.5.1
76 net-libs/webkit-gtk:3=
79 gtk3? ( x11-libs/gtk+:3 )
80 !gtk3? ( x11-libs/gtk+:2 )
84 motif? ( >=x11-libs/motif-2.3:0 )
86 Xaw3d? ( x11-libs/libXaw3d )
87 !Xaw3d? ( athena? ( x11-libs/libXaw ) )
94 gzip-el? ( app-arch/gzip )
100 if [[ ${PV##*.} = 9999 ]]; then
105 EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}"
106 SITEFILE="20${PN}-${SLOT}-gentoo.el"
109 if [[ ${PV##*.} = 9999 ]]; then
110 FULL_VERSION=$(sed -n 's/^AC_INIT([^,]*,[ \t]*\([^ \t,)]*\).*/\1/p' \
112 [[ ${FULL_VERSION} ]] || die "Cannot determine current Emacs version"
113 einfo "Emacs branch: ${EGIT_BRANCH}"
114 einfo "Commit: ${EGIT_VERSION}"
115 einfo "Emacs version number: ${FULL_VERSION}"
116 [[ ${FULL_VERSION} =~ ^${PV%.*}(\..*)?$ ]] \
117 || die "Upstream version number changed to ${FULL_VERSION}"
122 # Fix filename reference in redirected man page
123 sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \
124 || die "unable to sed ctags.1"
126 AT_M4DIR=m4 eautoreconf
131 filter-flags -pie #526948
134 replace-flags "-O[1-9]" -O0 #262359
136 replace-flags "-O[2-9]" -O1 #325373
138 replace-flags "-O[3-9]" -O2
145 "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
146 myconf+=" --with-sound=alsa"
148 myconf+=" --with-sound=$(usex sound oss)"
152 myconf+=" --with-x --without-ns"
153 myconf+=" $(use_with gconf)"
154 myconf+=" $(use_with gsettings)"
155 myconf+=" $(use_with toolkit-scroll-bars)"
156 myconf+=" $(use_with gif)"
157 myconf+=" $(use_with jpeg)"
158 myconf+=" $(use_with png)"
159 myconf+=" $(use_with svg rsvg)"
160 myconf+=" $(use_with tiff)"
161 myconf+=" $(use_with xpm)"
162 myconf+=" $(use_with imagemagick)"
165 myconf+=" --with-xft"
166 myconf+=" $(use_with cairo)"
167 myconf+=" $(use_with m17n-lib libotf)"
168 myconf+=" $(use_with m17n-lib m17n-flt)"
170 myconf+=" --without-xft"
171 myconf+=" --without-cairo"
172 myconf+=" --without-libotf --without-m17n-flt"
174 "USE flag \"cairo\" has no effect if \"xft\" is not set."
175 use m17n-lib && ewarn \
176 "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
181 einfo "Configuring to build with GIMP Toolkit (GTK+)"
182 while read line; do ewarn "${line}"; done <<-EOF
183 Your version of GTK+ will have problems with closing open
184 displays. This is no problem if you just use one display, but
185 if you use more than one and close one of them Emacs may crash.
186 See <https://bugzilla.gnome.org/show_bug.cgi?id=85715>.
187 If you intend to use more than one display, then it is strongly
188 recommended that you compile Emacs with the Athena/Lucid or the
189 Motif toolkit instead.
191 if use xwidgets; then
192 myconf+=" --with-x-toolkit=gtk3 --with-xwidgets"
194 myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)"
195 myconf+=" --without-xwidgets"
197 for f in motif Xaw3d athena; do
199 "USE flag \"${f}\" has no effect if \"gtk\" is set."
202 einfo "Configuring to build with Motif toolkit"
203 myconf+=" --with-x-toolkit=motif"
204 for f in Xaw3d athena; do
206 "USE flag \"${f}\" has no effect if \"motif\" is set."
208 elif use athena || use Xaw3d; then
209 einfo "Configuring to build with Athena/Lucid toolkit"
210 myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
212 einfo "Configuring to build with no toolkit"
213 myconf+=" --with-x-toolkit=no"
215 ! use gtk && use xwidgets && ewarn \
216 "USE flag \"xwidgets\" has no effect if \"gtk\" is not set."
218 einfo "Configuring to build with Nextstep (Cocoa) support"
219 myconf+=" --with-ns --disable-ns-self-contained"
220 myconf+=" --without-x"
222 myconf+=" --without-x --without-ns"
225 # Save version information in the Emacs binary. It will be available
226 # in variable "system-configuration-options".
227 myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
230 --program-suffix="-${EMACS_SUFFIX}" \
231 --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
232 --localstatedir="${EPREFIX}"/var \
233 --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
234 --with-gameuser=":gamestat" \
235 --without-compress-install \
236 --with-file-notification=$(usev inotify || usev gfile || echo no) \
241 $(use_with kerberos) $(use_with kerberos kerberos5) \
242 $(use_with libxml2 xml2) \
243 $(use_with selinux) \
244 $(use_with ssl gnutls) \
245 $(use_with wide-int) \
251 export SANDBOX_ON=0 # for the unbelievers, see Bug #131505
256 emake DESTDIR="${D}" NO_BIN_LINK=t install
258 mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} \
259 || die "moving emacs executable failed"
260 mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 \
261 || die "moving emacs man page failed"
263 # move info dir to avoid collisions with the dir file generated by portage
264 mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
265 || die "moving info dir failed"
266 touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
267 docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
269 # avoid collision between slots, see bug #169033 e.g.
270 rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
271 rm -rf "${ED}"/usr/share/{appdata,applications,icons}
274 # remove unused <version>/site-lisp dir
275 rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
277 # remove COPYING file (except for etc/COPYING used by describe-copying)
278 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
281 # compress .el files when a corresponding .elc exists
282 find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \
283 -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n
284 assert "gzip .el failed"
289 cdir="/usr/share/emacs/${FULL_VERSION}/src"
291 # This is not meant to install all the source -- just the
292 # C source you might find via find-function
294 elif has installsources ${FEATURES}; then
295 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
298 sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
300 ;;; ${PN}-${SLOT} site-lisp configuration
302 (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
303 Y (setq find-function-C-source-directory
304 Y "${EPREFIX}${cdir}")
305 X (let ((path (getenv "INFOPATH"))
306 X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
307 X (re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
309 X ;; move Emacs Info dir before anything else in /usr/share/info
310 X (let* ((p (cons nil (split-string path ":" t))) (q p))
311 X (while (and (cdr q) (not (string-match re (cadr q))))
313 X (setcdr q (cons dir (delete dir (cdr q))))
314 X (setq Info-directory-list (prune-directory-list (cdr p)))))))
316 elisp-site-file-install "${T}/${SITEFILE}" || die
318 dodoc README BUGS CONTRIBUTE
321 dodir /Applications/Gentoo
322 rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
323 mv nextstep/Emacs.app \
324 "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
327 DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
328 through the Emacs eselect module, which also redirects man and info
329 pages. Therefore, several Emacs versions can be installed at the
330 same time. \"man emacs.eselect\" for details.
331 \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is
332 strongly recommended that you use app-admin/emacs-updater to rebuild
333 all byte-compiled elisp files of the installed Emacs packages."
334 use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
335 Installing media-fonts/font-adobe-{75,100}dpi on the X server's
336 machine would satisfy basic Emacs requirements under X11.
337 See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
338 for how to enable anti-aliased fonts."
339 use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
340 \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
341 it into /Applications by yourself."
342 readme.gentoo_create_doc
346 # move Info dir file to correct name
347 local infodir=/usr/share/info/${EMACS_SUFFIX} f
348 if [[ -f ${ED}${infodir}/dir.orig ]]; then
349 mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
350 elif [[ -d "${ED}"${infodir} ]]; then
351 # this should not happen in EAPI 4
352 ewarn "Regenerating Info directory index in ${infodir} ..."
353 rm -f "${ED}"${infodir}/dir{,.*}
354 for f in "${ED}"${infodir}/*; do
355 if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
356 install-info --info-dir="${ED}"${infodir} "${f}" \
357 || die "install-info failed"
367 for pvr in ${REPLACING_VERSIONS}; do
368 [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1
370 readme.gentoo_print_elog
373 # force an update of the emacs symlink for the livecd/dvd,
374 # because some microemacs packages set it with USE=livecd
376 elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
377 # refresh symlinks in case any installed files have changed
378 eselect emacs set ${EMACS_SUFFIX}
380 eselect emacs update ifunset
386 eselect emacs update ifunset