1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit autotools elisp-common eutils flag-o-matic multilib readme.gentoo
9 if [[ ${PV##*.} = 9999 ]]; then
11 EGIT_REPO_URI="git://git.sv.gnu.org/emacs.git"
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}"
27 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
28 HOMEPAGE="http://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 gnutls gpm gsettings gtk +gtk3 gzip-el hesiod imagemagick +inotify jpeg kerberos libxml2 livecd m17n-lib motif pax_kernel png selinux sound source svg tiff toolkit-scroll-bars wide-int X Xaw3d xft +xpm zlib"
33 REQUIRED_USE="?? ( aqua X )"
35 RDEPEND="sys-libs/ncurses
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 )
42 gfile? ( >=dev-libs/glib-2.28.6 )
43 gnutls? ( net-libs/gnutls )
45 hesiod? ( net-dns/hesiod )
46 kerberos? ( virtual/krb5 )
47 libxml2? ( >=dev-libs/libxml2-2.2.0 )
48 selinux? ( sys-libs/libselinux )
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 )
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
74 gtk3? ( x11-libs/gtk+:3 )
75 !gtk3? ( x11-libs/gtk+:2 )
78 motif? ( >=x11-libs/motif-2.3:0 )
80 Xaw3d? ( x11-libs/libXaw3d )
81 !Xaw3d? ( athena? ( x11-libs/libXaw ) )
88 gzip-el? ( app-arch/gzip )
94 if [[ ${PV##*.} = 9999 ]]; then
99 EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}"
100 SITEFILE="20${PN}-${SLOT}-gentoo.el"
103 if [[ ${PV##*.} = 9999 ]]; then
104 FULL_VERSION=$(sed -n 's/^AC_INIT([^,]*,[ \t]*\([^ \t,)]*\).*/\1/p' \
106 [[ ${FULL_VERSION} ]] || die "Cannot determine current Emacs version"
107 einfo "Emacs branch: ${EGIT_BRANCH}"
108 einfo "Commit: ${EGIT_VERSION}"
109 einfo "Emacs version number: ${FULL_VERSION}"
110 [[ ${FULL_VERSION} =~ ^${PV%.*}(\..*)?$ ]] \
111 || die "Upstream version number changed to ${FULL_VERSION}"
116 # Fix filename reference in redirected man page
117 sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \
118 || die "unable to sed ctags.1"
120 AT_M4DIR=m4 eautoreconf
125 filter-flags -pie #526948
128 replace-flags "-O[1-9]" -O0 #262359
130 replace-flags "-O[2-9]" -O1 #325373
132 replace-flags "-O[3-9]" -O2
139 "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
140 myconf+=" --with-sound=alsa"
142 myconf+=" --with-sound=$(usex sound oss)"
146 myconf+=" --with-x --without-ns"
147 myconf+=" $(use_with gconf)"
148 myconf+=" $(use_with gsettings)"
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)"
156 myconf+=" $(use_with imagemagick)"
159 myconf+=" --with-xft"
160 myconf+=" $(use_with cairo)"
161 myconf+=" $(use_with m17n-lib libotf)"
162 myconf+=" $(use_with m17n-lib m17n-flt)"
164 myconf+=" --without-xft"
165 myconf+=" --without-cairo"
166 myconf+=" --without-libotf --without-m17n-flt"
168 "USE flag \"cairo\" has no effect if \"xft\" is not set."
169 use m17n-lib && ewarn \
170 "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
175 einfo "Configuring to build with GIMP Toolkit (GTK+)"
176 while read line; do ewarn "${line}"; done <<-EOF
177 Your version of GTK+ will have problems with closing open
178 displays. This is no problem if you just use one display, but
179 if you use more than one and close one of them Emacs may crash.
180 See <http://bugzilla.gnome.org/show_bug.cgi?id=85715>.
181 If you intend to use more than one display, then it is strongly
182 recommended that you compile Emacs with the Athena/Lucid or the
183 Motif toolkit instead.
185 myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)"
186 for f in motif Xaw3d athena; do
188 "USE flag \"${f}\" has no effect if \"gtk\" is set."
191 einfo "Configuring to build with Motif toolkit"
192 myconf+=" --with-x-toolkit=motif"
193 for f in Xaw3d athena; do
195 "USE flag \"${f}\" has no effect if \"motif\" is set."
197 elif use athena || use Xaw3d; then
198 einfo "Configuring to build with Athena/Lucid toolkit"
199 myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
201 einfo "Configuring to build with no toolkit"
202 myconf+=" --with-x-toolkit=no"
205 einfo "Configuring to build with Nextstep (Cocoa) support"
206 myconf+=" --with-ns --disable-ns-self-contained"
207 myconf+=" --without-x"
209 myconf+=" --without-x --without-ns"
212 # Save version information in the Emacs binary. It will be available
213 # in variable "system-configuration-options".
214 myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
215 if [[ ${PV##*.} = 9999 ]]; then
216 myconf+=" EGIT_BRANCH=${EGIT_BRANCH} EGIT_VERSION=${EGIT_VERSION}"
220 --program-suffix="-${EMACS_SUFFIX}" \
221 --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
222 --localstatedir="${EPREFIX}"/var \
223 --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
224 --with-gameuser=":gamestat" \
225 --without-compress-install \
226 --with-file-notification=$(usev gfile || usev inotify || echo no) \
232 $(use_with kerberos) $(use_with kerberos kerberos5) \
233 $(use_with libxml2 xml2) \
234 $(use_with selinux) \
235 $(use_with wide-int) \
241 export SANDBOX_ON=0 # for the unbelievers, see Bug #131505
246 emake DESTDIR="${D}" NO_BIN_LINK=t install
248 mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} \
249 || die "moving emacs executable failed"
250 mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 \
251 || die "moving emacs man page failed"
253 # move info dir to avoid collisions with the dir file generated by portage
254 mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
255 || die "moving info dir failed"
256 touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
257 docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
259 # avoid collision between slots, see bug #169033 e.g.
260 rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
261 rm -rf "${ED}"/usr/share/{appdata,applications,icons}
264 # remove unused <version>/site-lisp dir
265 rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
267 # remove COPYING file (except for etc/COPYING used by describe-copying)
268 rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
271 # compress .el files when a corresponding .elc exists
272 find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \
273 -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n
274 assert "gzip .el failed"
279 cdir="/usr/share/emacs/${FULL_VERSION}/src"
281 # This is not meant to install all the source -- just the
282 # C source you might find via find-function
284 elif has installsources ${FEATURES}; then
285 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
288 sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
290 ;;; ${PN}-${SLOT} site-lisp configuration
292 (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
293 Y (setq find-function-C-source-directory
294 Y "${EPREFIX}${cdir}")
295 X (let ((path (getenv "INFOPATH"))
296 X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
297 X (re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
299 X ;; move Emacs Info dir before anything else in /usr/share/info
300 X (let* ((p (cons nil (split-string path ":" t))) (q p))
301 X (while (and (cdr q) (not (string-match re (cadr q))))
303 X (setcdr q (cons dir (delete dir (cdr q))))
304 X (setq Info-directory-list (prune-directory-list (cdr p)))))))
306 elisp-site-file-install "${T}/${SITEFILE}" || die
308 dodoc README BUGS CONTRIBUTE
311 dodir /Applications/Gentoo
312 rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
313 mv nextstep/Emacs.app \
314 "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
317 DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
318 through the Emacs eselect module, which also redirects man and info
319 pages. Therefore, several Emacs versions can be installed at the
320 same time. \"man emacs.eselect\" for details.
321 \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is
322 strongly recommended that you use app-admin/emacs-updater to rebuild
323 all byte-compiled elisp files of the installed Emacs packages."
324 use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
325 Installing media-fonts/font-adobe-{75,100}dpi on the X server's
326 machine would satisfy basic Emacs requirements under X11.
327 See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
328 for how to enable anti-aliased fonts."
329 use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
330 \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
331 it into /Applications by yourself."
332 readme.gentoo_create_doc
336 # move Info dir file to correct name
337 local infodir=/usr/share/info/${EMACS_SUFFIX} f
338 if [[ -f ${ED}${infodir}/dir.orig ]]; then
339 mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
340 elif [[ -d "${ED}"${infodir} ]]; then
341 # this should not happen in EAPI 4
342 ewarn "Regenerating Info directory index in ${infodir} ..."
343 rm -f "${ED}"${infodir}/dir{,.*}
344 for f in "${ED}"${infodir}/*; do
345 if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
346 install-info --info-dir="${ED}"${infodir} "${f}" \
347 || die "install-info failed"
357 for pvr in ${REPLACING_VERSIONS}; do
358 [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1
360 readme.gentoo_print_elog
363 # force an update of the emacs symlink for the livecd/dvd,
364 # because some microemacs packages set it with USE=livecd
366 elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
367 # refresh symlinks in case any installed files have changed
368 eselect emacs set ${EMACS_SUFFIX}
370 eselect emacs update ifunset
376 eselect emacs update ifunset