From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-852567-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 18ACC1388C1
	for <garchives@archives.gentoo.org>; Sun, 20 Dec 2015 20:29:57 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 4AFD721C027;
	Sun, 20 Dec 2015 20:29:53 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id BAF4521C027
	for <gentoo-commits@lists.gentoo.org>; Sun, 20 Dec 2015 20:29:52 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 36ACF340504
	for <gentoo-commits@lists.gentoo.org>; Sun, 20 Dec 2015 20:29:50 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id E1BD0B41
	for <gentoo-commits@lists.gentoo.org>; Sun, 20 Dec 2015 20:29:47 +0000 (UTC)
From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" <ulm@gentoo.org>
Message-ID: <1450643379.665048d7715aa97f1a3e64ed5a351e6cc0310985.ulm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: app-editors/emacs/
X-VCS-Repository: repo/gentoo
X-VCS-Files: app-editors/emacs/Manifest app-editors/emacs/emacs-18.59-r11.ebuild app-editors/emacs/emacs-23.4-r14.ebuild
X-VCS-Directories: app-editors/emacs/
X-VCS-Committer: ulm
X-VCS-Committer-Name: Ulrich Müller
X-VCS-Revision: 665048d7715aa97f1a3e64ed5a351e6cc0310985
X-VCS-Branch: master
Date: Sun, 20 Dec 2015 20:29:47 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 4c2141ea-7f14-4d6f-b8ec-68aec2074930
X-Archives-Hash: 3da4a6f6bd5508055bee6d814883cf95

commit:     665048d7715aa97f1a3e64ed5a351e6cc0310985
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 20 20:28:58 2015 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Dec 20 20:29:39 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=665048d7

app-editors/emacs: Fixes for GCC 5.

Emacs 18.59: Use system malloc. This fixes hanging at runtime when
compiled with GCC 5.3. Fix a couple of compiler warnings.

Emacs 23.4: Fix jpeg version check to work with gcc >= 5.

Package-Manager: portage-2.2.26

 app-editors/emacs/Manifest               |   2 +
 app-editors/emacs/emacs-18.59-r11.ebuild | 149 +++++++++++++
 app-editors/emacs/emacs-23.4-r14.ebuild  | 349 +++++++++++++++++++++++++++++++
 3 files changed, 500 insertions(+)

diff --git a/app-editors/emacs/Manifest b/app-editors/emacs/Manifest
index fecd59c..3f611c4 100644
--- a/app-editors/emacs/Manifest
+++ b/app-editors/emacs/Manifest
@@ -1,7 +1,9 @@
 DIST emacs-18.59-linux22x-elf-glibc21.diff.gz 15671 SHA256 fb810d893938883d50a3a8d7c43fbeb1604d5454f760b8f1f700326c8ee659dd SHA512 c6c6ea33850dadf08d68fff56fc6aacc80ad1aa36661260715d50b95438942d56e6244094427d50356cfe716f26559feb885254c436399bff7be639637d605b6 WHIRLPOOL cafaa0fb0d06058cac8e445a7a1b5cba145d23186477a9c681efdab8ca0f18a9675dec3a93851fd7138890701f83fab83300c28a548c8fc22478a0cfff95d5da
 DIST emacs-18.59-patches-8.tar.bz2 19667 SHA256 637542bf5ee07d4abac11b76e742598a60787f3869dbf377eed99ae005fbc59d SHA512 a6564bc16724bfdb22f77b0e21b6064ca5e0e1bc91f3223c1037c26f8a048f28ac7a5da6817dc940a5f00f1f39bbfcda2277645409cd7e143a55fabdc3d3fe5d WHIRLPOOL 6b81f978aef2b429262e79ab1d995cca9237dc9c9d98144d2dc3de07bc2cdcec8547adbaf5ad41d9cce3239554918c04c7b9ff783b7931582a3a7398eb2b66f1
+DIST emacs-18.59-patches-9.tar.xz 21380 SHA256 69411c57b20850e8aab1e20614437f9a836c2ddf47c46a833d0262c138fa3270 SHA512 595a4a7a4052c3b3325e4d4952eed24c98d3dd62b7ce89bd149f046552e2dd67ec3e720b7559fbc086b06a667c992bccc60201ef53b263dbd0fc96cbcdceee38 WHIRLPOOL 23f803d940c35fe9519fe7169e6bca7012c2d2db2246dec121fba37e8dbf39f411a9e579a9cbd4193562da72b9ac226286ad687877ccadd7cb78ea7eb615ab3f
 DIST emacs-18.59.tar.gz 2962652 SHA256 1e27e33f91984a91e9b4c1f21433f931aba03670960ecc147bb6d7b0de0f051e SHA512 03ce565e346e89b7aacb1852f4783e8907f394de7da0c543b475cb038eb89b87f980d0f7ca1841b1d2108b20f211e95113c7214e4a33e5767a1827ff43173f33 WHIRLPOOL 5e98e71518f665e2a8278afe54e0ace6d7fdd9df23ff0a3354ffc1d5cc25cd21b0dd4d82766fcb436d4f24e9291c933295e956e1ffea43cfeedf915175763be6
 DIST emacs-23.4-patches-17.tar.xz 16164 SHA256 bc9d4a36239f2749e218d903b67102e211a3a62ef162f5ab2801865dab77b752 SHA512 ceccd559b4f53328d75016b64d246ecf6fca7edebd080ce3bbba5f4d000bec38be5da91f3195c972ede0710da14b3be0545891321259b0a0b2963981c8fd62de WHIRLPOOL 4b70ce4d876e92a006e3dc0a31301f604aa8fa53a198515d1cbb3517a94933b1d7a11636494c1bd28ad1049a5a233d4ec13213e74e1eaff1cf96bb1fd095c345
+DIST emacs-23.4-patches-18.tar.xz 16512 SHA256 8c783691d61b888ca79d5d7a8319806a3125b656b3406a8834166cd53ba94813 SHA512 ec1092ca9a767035517fdb280fa31684466cf03ce19b3bcaf80ea816ad417fe8bf918787c49f2719bbf535a59594132ef2044c38a810717e8b5119a76d3dc0d2 WHIRLPOOL aac96413b3a76acbf3e9a771d909be42f913a72688e5c11c31534439a242e364d220ef66d23b73cf8ed4693f4a9ed2f5642c155e66b4b49e6ea1c2a16944aaa4
 DIST emacs-23.4.tar.bz2 38646508 SHA256 26576f9e664397c729f78f5ffcd092969251988461896fe8793062346ee988b9 SHA512 def7a95ecaefae24d8102b96b1d575a23def1b11a8f0bb17b68f7913bd118e2ea4449a8feee76c1bd649f099b70419f0d494ddd9bb32b26f92720cda842b0296 WHIRLPOOL 2384c3f63ff153c3975e373334d6021d46b23ad3cab448ed2e1180501236453a61d13bf1dfbb2e6075bb141dd8511d85f77e37c763b39769f98de48eacc56f3b
 DIST emacs-24.4-patches-5.tar.xz 6000 SHA256 967dac364282a51933f90c56f368bc3f2741efe0b7ff42d3151bb4824b70fa04 SHA512 0a337ad5b7601f5e453645d1fba99717328c6bc7a5505bcb4bd8e853179cf61be43eb6f3b9370edf0f44aa6485d4847c14554c1592ccc7da87b10dabaaa9d421 WHIRLPOOL 149f3a431d055963c544d9fa6c6447a16aa093840f6bf4086f50506979356a12407af16291c46ee62a92b3ee41767452046f45a7163214be33ab7bdbcd6059dc
 DIST emacs-24.4.tar.xz 39733124 SHA256 47e391170db4ca0a3c724530c7050655f6d573a711956b4cd84693c194a9d4fd SHA512 f51f88a4736a3f153ef01f3ad710571e967cd3d0c0112b066169a4040725d370ec29b14a4ca8fa3e3f4c657c726ba8e64c3ac4e390b8e911ea47a3afb5ac755c WHIRLPOOL eae38c2382731fecf0ccf8f717f8c96cc130d01a893ff560caecde903294eb843660492761ea8cce9920b79bfc55e821921924e27c040f25355110f56cd2255b

diff --git a/app-editors/emacs/emacs-18.59-r11.ebuild b/app-editors/emacs/emacs-18.59-r11.ebuild
new file mode 100644
index 0000000..e78983d
--- /dev/null
+++ b/app-editors/emacs/emacs-18.59-r11.ebuild
@@ -0,0 +1,149 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+inherit toolchain-funcs flag-o-matic multilib
+
+DESCRIPTION="The extensible self-documenting text editor"
+HOMEPAGE="https://www.gnu.org/software/emacs/"
+SRC_URI="ftp://ftp.gnu.org/old-gnu/emacs/${P}.tar.gz
+	ftp://ftp.splode.com/pub/users/friedman/emacs/${P}-linux22x-elf-glibc21.diff.gz
+	https://dev.gentoo.org/~ulm/emacs/${P}-patches-9.tar.xz"
+
+LICENSE="GPL-1+ GPL-2+ BSD" #HPND
+SLOT="18"
+KEYWORDS="~amd64 ~x86"
+IUSE="abi_x86_x32"
+
+RDEPEND=">=app-eselect/eselect-emacs-1.16
+	sys-libs/ncurses:0
+	amd64? (
+		abi_x86_x32? ( >=sys-libs/ncurses-5.9-r3:0[abi_x86_x32(-)?] )
+		!abi_x86_x32? ( >=sys-libs/ncurses-5.9-r3:0[abi_x86_32(-)] )
+	)"
+#	X? ( x11-libs/libX11[-xcb] )
+DEPEND="${RDEPEND}
+	virtual/pkgconfig"
+
+PATCHES="../${P}-linux22x-elf-glibc21.diff ../patch"
+
+src_configure() {
+	# autoconf? What's autoconf? We are living in 1992. ;-)
+	local arch
+	case ${ARCH} in
+		amd64)
+			if use abi_x86_x32; then
+				arch=x86-x32
+				multilib_toolchain_setup x32
+			else
+				arch=intel386
+				multilib_toolchain_setup x86
+			fi
+			;;
+		x86) arch=intel386 ;;
+		*) die "Architecture ${ARCH} not yet supported" ;;
+	esac
+	local cmd="s/\"s-.*\.h\"/\"s-linux.h\"/;s/\"m-.*\.h\"/\"m-${arch}.h\"/"
+	#use X && cmd="${cmd};s/.*\(#define HAVE_X_WINDOWS\).*/\1/"
+	sed -e "${cmd}" src/config.h-dist >src/config.h || die
+
+	cat <<-END >src/paths.h
+		#define PATH_LOADSEARCH "/usr/share/emacs/${PV}/lisp"
+		#define PATH_EXEC "/usr/share/emacs/${PV}/etc"
+		#define PATH_LOCK "/var/lib/emacs/lock/"
+		#define PATH_SUPERLOCK "/var/lib/emacs/lock/!!!SuperLock!!!"
+	END
+
+	sed -i -e "s:/usr/lib/\([^ ]*\).o:/usr/$(get_libdir)/\1.o:g" \
+		-e "s:-lncurses:$("$(tc-getPKG_CONFIG)" --libs ncurses):" \
+		src/s-linux.h || die
+
+	# -O3 and -finline-functions cause segmentation faults at run time.
+	filter-flags -finline-functions
+	replace-flags -O[3-9] -O2
+	strip-flags
+	# Quieten GCC 5. Feel free to submit a patch adding all those prototypes.
+	append-flags -Wno-implicit
+}
+
+src_compile() {
+	# Do not use the sandbox, or the dumped Emacs will be twice as large
+	export SANDBOX_ON=0
+	emake --jobs=1 \
+		CC="$(tc-getCC)" CFLAGS="${CFLAGS} -Demacs" \
+		LD="$(tc-getCC) -nostdlib" LDFLAGS="${LDFLAGS}"
+}
+
+src_install() {
+	local basedir="/usr/share/emacs/${PV}" i
+
+	dodir ${basedir}
+	dodir /usr/share/man/man1
+	emake --jobs=1 \
+		LIBDIR="${D}"${basedir} \
+		BINDIR="${D}"/usr/bin \
+		MANDIR="${D}"/usr/share/man/man1 \
+		install
+
+	rmdir "${D}"${basedir}/lock || die
+	find "${D}"${basedir} -type f \( -name "*.c" -o -name ChangeLog \
+		-o -name COPYING ! -path "*/etc/COPYING" \) -exec rm "{}" + || die
+	fperms -R go-w ${basedir}
+
+	# remove duplicate DOC file
+	rm "${D}"${basedir}/etc/DOC || die
+
+	# move executables to the correct place
+	mv "${D}"/usr/bin/emacs{,-${SLOT}} || die
+	for i in etags ctags emacsclient; do
+		mv "${D}"/usr/bin/${i}{,-emacs-${SLOT}} || die
+		rm "${D}"${basedir}/etc/${i} || die
+	done
+
+	dodir /usr/libexec/emacs/${PV}
+	for i in wakeup digest-doc sorted-doc movemail cvtmail fakemail \
+		yow env server
+	do
+		mv "${D}"${basedir}/etc/${i} "${D}"/usr/libexec/emacs/${PV}/${i} || die
+		dosym ../../../../libexec/emacs/${PV}/${i} ${basedir}/etc/${i}
+	done
+	for i in test-distrib make-docfile; do
+		rm "${D}"${basedir}/etc/${i} || die
+	done
+
+	# move man page
+	mv "${D}"/usr/share/man/man1/emacs{,-${SLOT}}.1 || die
+
+	# move Info files
+	dodir /usr/share/info
+	mv "${D}"${basedir}/info "${D}"/usr/share/info/emacs-${SLOT} || die
+	dosym ../../info/emacs-${SLOT} "${basedir}"/info
+	docompress -x /usr/share/info
+
+	# move Info dir to avoid collisions with the dir file generated by portage
+	mv "${D}"/usr/share/info/emacs-${SLOT}/dir{,.orig} || die
+	touch "${D}"/usr/share/info/emacs-${SLOT}/.keepinfodir
+
+	dodir /var/lib/emacs
+	diropts -m0777
+	keepdir /var/lib/emacs/lock
+
+	dodoc README PROBLEMS
+}
+
+pkg_preinst() {
+	# move Info dir file to correct name
+	if [[ -d "${D}"/usr/share/info ]]; then
+		mv "${D}"/usr/share/info/emacs-${SLOT}/dir{.orig,} || die
+	fi
+}
+
+pkg_postinst() {
+	eselect emacs update ifunset
+}
+
+pkg_postrm() {
+	eselect emacs update ifunset
+}

diff --git a/app-editors/emacs/emacs-23.4-r14.ebuild b/app-editors/emacs/emacs-23.4-r14.ebuild
new file mode 100644
index 0000000..edb1f0d
--- /dev/null
+++ b/app-editors/emacs/emacs-23.4-r14.ebuild
@@ -0,0 +1,349 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+WANT_AUTOMAKE="none"
+
+inherit autotools elisp-common flag-o-matic multilib readme.gentoo-r1
+
+DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
+HOMEPAGE="https://www.gnu.org/software/emacs/"
+SRC_URI="mirror://gnu/emacs/${P}.tar.bz2
+	https://dev.gentoo.org/~ulm/emacs/${P}-patches-18.tar.xz"
+
+LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
+SLOT="23"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
+IUSE="alsa aqua athena dbus games gconf gif gpm gtk gzip-el hesiod jpeg kerberos livecd m17n-lib motif pax_kernel png sound source svg tiff toolkit-scroll-bars X Xaw3d xft +xpm"
+REQUIRED_USE="?? ( aqua X )"
+
+RDEPEND="sys-libs/ncurses:0
+	>=app-eselect/eselect-emacs-1.16
+	>=app-emacs/emacs-common-gentoo-1.5[games?,X?]
+	net-libs/liblockfile
+	hesiod? ( net-dns/hesiod )
+	kerberos? ( virtual/krb5 )
+	alsa? ( media-libs/alsa-lib )
+	gpm? ( sys-libs/gpm )
+	dbus? ( sys-apps/dbus )
+	X? (
+		x11-libs/libXmu
+		x11-libs/libXt
+		x11-misc/xbitmaps
+		gconf? ( >=gnome-base/gconf-2.26.2 )
+		gif? ( media-libs/giflib )
+		jpeg? ( virtual/jpeg:0= )
+		png? ( >=media-libs/libpng-1.4:0= )
+		svg? ( >=gnome-base/librsvg-2.0 )
+		tiff? ( media-libs/tiff:0 )
+		xpm? ( x11-libs/libXpm )
+		xft? (
+			media-libs/fontconfig
+			media-libs/freetype
+			x11-libs/libXft
+			m17n-lib? (
+				>=dev-libs/libotf-0.9.4
+				>=dev-libs/m17n-lib-1.5.1
+			)
+		)
+		gtk? ( x11-libs/gtk+:2 )
+		!gtk? (
+			motif? ( >=x11-libs/motif-2.3:0 )
+			!motif? (
+				Xaw3d? ( x11-libs/libXaw3d )
+				!Xaw3d? ( athena? ( x11-libs/libXaw ) )
+			)
+		)
+	)"
+
+DEPEND="${RDEPEND}
+	alsa? ( virtual/pkgconfig )
+	dbus? ( virtual/pkgconfig )
+	X? ( virtual/pkgconfig )
+	gzip-el? ( app-arch/gzip )
+	pax_kernel? (
+		sys-apps/attr
+		sys-apps/paxctl
+	)"
+
+RDEPEND="${RDEPEND}
+	!<app-editors/emacs-vcs-${PV}"
+
+EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}"
+SITEFILE="20${PN}-${SLOT}-gentoo.el"
+# FULL_VERSION keeps the full version number, which is needed in
+# order to determine some path information correctly for copy/move
+# operations later on
+FULL_VERSION="${PV%%_*}"
+S="${WORKDIR}/emacs-${FULL_VERSION}"
+
+src_prepare() {
+	eapply ../patch
+	eapply_user
+
+	sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \
+		|| die "unable to sed ctags.1"
+
+	if ! use alsa; then
+		# ALSA is detected even if not requested by its USE flag.
+		# Suppress it by supplying pkg-config with a wrong library name.
+		sed -i -e "/ALSA_MODULES=/s/alsa/DiSaBlEaLsA/" configure.in \
+			|| die "unable to sed configure.in"
+	fi
+	if ! use gzip-el; then
+		# Emacs' build system automatically detects the gzip binary and
+		# compresses el files. We don't want that so confuse it with a
+		# wrong binary name
+		sed -i -e "s/ gzip/ PrEvEnTcOmPrEsSiOn/" configure.in \
+			|| die "unable to sed configure.in"
+	fi
+
+	mv configure.in configure.ac || die
+	eautoreconf
+}
+
+src_configure() {
+	strip-flags
+	filter-flags -fstrict-aliasing -pie
+	append-flags $(test-flags -fno-strict-aliasing)
+
+	if use sh; then
+		replace-flags "-O[1-9]" -O0		#262359
+	elif use ia64; then
+		replace-flags "-O[2-9]" -O1		#325373
+	else
+		replace-flags "-O[3-9]" -O2
+	fi
+
+	local myconf
+
+	if use alsa && ! use sound; then
+		einfo "Although sound USE flag is disabled you chose to have alsa,"
+		einfo "so sound is switched on anyway."
+		myconf+=" --with-sound"
+	else
+		myconf+=" $(use_with sound)"
+	fi
+
+	if use X; then
+		myconf+=" --with-x --without-ns"
+		myconf+=" $(use_with gconf)"
+		myconf+=" $(use_with toolkit-scroll-bars)"
+		myconf+=" $(use_with gif)"
+		myconf+=" $(use_with jpeg)"
+		myconf+=" $(use_with png)"
+		myconf+=" $(use_with svg rsvg)"
+		myconf+=" $(use_with tiff)"
+		myconf+=" $(use_with xpm)"
+
+		if use xft; then
+			myconf+=" --with-xft"
+			myconf+=" $(use_with m17n-lib libotf)"
+			myconf+=" $(use_with m17n-lib m17n-flt)"
+		else
+			myconf+=" --without-xft"
+			myconf+=" --without-libotf --without-m17n-flt"
+			use m17n-lib && ewarn \
+				"USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
+		fi
+
+		# GTK+ is the default toolkit if USE=gtk is chosen with other
+		# possibilities. Emacs upstream thinks this should be standard
+		# policy on all distributions
+		local f
+		if use gtk; then
+			einfo "Configuring to build with GIMP Toolkit (GTK+)"
+			myconf+=" --with-x-toolkit=gtk"
+			for f in motif Xaw3d athena; do
+				use ${f} && ewarn \
+					"USE flag \"${f}\" has no effect if \"gtk\" is set."
+			done
+		elif use motif; then
+			einfo "Configuring to build with Motif toolkit"
+			myconf+=" --with-x-toolkit=motif"
+			for f in Xaw3d athena; do
+				use ${f} && ewarn \
+					"USE flag \"${f}\" has no effect if \"motif\" is set."
+			done
+		elif use athena || use Xaw3d; then
+			einfo "Configuring to build with Athena/Lucid toolkit"
+			myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
+		else
+			einfo "Configuring to build with no toolkit"
+			myconf+=" --with-x-toolkit=no"
+		fi
+	elif use aqua; then
+		einfo "Configuring to build with Nextstep (Cocoa) support"
+		myconf+=" --with-ns --disable-ns-self-contained"
+		myconf+=" --without-x"
+	else
+		myconf+=" --without-x --without-ns"
+	fi
+
+	# Save version information in the Emacs binary. It will be available
+	# in variable "system-configuration-options".
+	myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
+
+	# According to configure, this option is only used for GNU/Linux
+	# (x86_64 and s390). For Gentoo Prefix we have to explicitly spell
+	# out the location because $(get_libdir) does not necessarily return
+	# something that matches the host OS's libdir naming (e.g. RHEL).
+	local crtdir=$($(tc-getCC) -print-file-name=crt1.o)
+	crtdir=${crtdir%/*}
+
+	econf \
+		--program-suffix="-${EMACS_SUFFIX}" \
+		--infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
+		--localstatedir="${EPREFIX}"/var \
+		--enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
+		--with-crt-dir="${crtdir}" \
+		--with-gameuser=":gamestat" \
+		$(use_with hesiod) \
+		$(use_with kerberos) $(use_with kerberos kerberos5) \
+		$(use_with gpm) \
+		$(use_with dbus) \
+		${myconf}
+}
+
+src_compile() {
+	export SANDBOX_ON=0			# for the unbelievers, see Bug #131505
+	emake CC="$(tc-getCC)" \
+		AR="$(tc-getAR) cq" \
+		RANLIB="$(tc-getRANLIB)"
+}
+
+src_install () {
+	emake DESTDIR="${D}" install
+
+	rm "${ED}"/usr/bin/emacs-${FULL_VERSION}-${EMACS_SUFFIX} \
+		|| die "removing duplicate emacs executable failed"
+	mv "${ED}"/usr/bin/emacs-${EMACS_SUFFIX} "${ED}"/usr/bin/${EMACS_SUFFIX} \
+		|| die "moving emacs executable failed"
+
+	# move man pages to the correct place
+	local m
+	mv "${ED}"/usr/share/man/man1/{emacs,${EMACS_SUFFIX}}.1 \
+		|| die "moving emacs man page failed"
+	for m in b2m ctags ebrowse emacsclient etags grep-changelog rcs-checkin; do
+		mv "${ED}"/usr/share/man/man1/${m}{,-${EMACS_SUFFIX}}.1 \
+			|| die "moving ${m} man page failed"
+	done
+
+	# move info dir to avoid collisions with the dir file generated by portage
+	mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
+		|| die "moving info dir failed"
+	touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
+	docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
+
+	# avoid collision between slots, see bug #169033 e.g.
+	rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
+	rm -rf "${ED}"/usr/share/{applications,icons}
+	rm -rf "${ED}"/var
+
+	# remove unused <version>/site-lisp dir
+	rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
+
+	# remove COPYING file (except for etc/COPYING used by describe-copying)
+	rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
+
+	local cdir
+	if use source; then
+		cdir="/usr/share/emacs/${FULL_VERSION}/src"
+		insinto "${cdir}"
+		# This is not meant to install all the source -- just the
+		# C source you might find via find-function
+		doins src/*.{c,h,m}
+		doins -r src/{m,s}
+		rm "${ED}"/usr/share/emacs/${FULL_VERSION}/src/Makefile.c
+		rm "${ED}"/usr/share/emacs/${FULL_VERSION}/src/{m,s}/README
+	elif has installsources ${FEATURES}; then
+		cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
+	fi
+
+	sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
+	X
+	;;; ${PN}-${SLOT} site-lisp configuration
+	X
+	(when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
+	Y  (setq find-function-C-source-directory
+	Y	"${EPREFIX}${cdir}")
+	X  (let ((path (getenv "INFOPATH"))
+	X	(dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
+	X	(re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
+	X    (and path
+	X	 ;; move Emacs Info dir before anything else in /usr/share/info
+	X	 (let* ((p (cons nil (split-string path ":" t))) (q p))
+	X	   (while (and (cdr q) (not (string-match re (cadr q))))
+	X	     (setq q (cdr q)))
+	X	   (setcdr q (cons dir (delete dir (cdr q))))
+	X	   (setq Info-directory-list (prune-directory-list (cdr p)))))))
+	EOF
+	elisp-site-file-install "${T}/${SITEFILE}" || die
+
+	dodoc README BUGS
+
+	if use aqua; then
+		dodir /Applications/Gentoo
+		rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
+		mv nextstep/Emacs.app \
+			"${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
+	fi
+
+	DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
+		through the Emacs eselect module, which also redirects man and info
+		pages. Therefore, several Emacs versions can be installed at the
+		same time. \"man emacs.eselect\" for details.
+		\\n\\nIf you upgrade from a previous major version of Emacs, then
+		it is strongly recommended that you use app-admin/emacs-updater
+		to rebuild all byte-compiled elisp files of the installed Emacs
+		packages."
+	use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
+		Installing media-fonts/font-adobe-{75,100}dpi on the X server's
+		machine would satisfy basic Emacs requirements under X11.
+		See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
+		for how to enable anti-aliased fonts."
+	use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
+		\"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
+		it into /Applications by yourself."
+	readme.gentoo_create_doc
+}
+
+pkg_preinst() {
+	# move Info dir file to correct name
+	local infodir=/usr/share/info/${EMACS_SUFFIX} f
+	if [[ -f ${ED}${infodir}/dir.orig ]]; then
+		mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
+	elif [[ -d "${ED}"${infodir} ]]; then
+		# this should not happen in EAPI 4
+		ewarn "Regenerating Info directory index in ${infodir} ..."
+		rm -f "${ED}"${infodir}/dir{,.*}
+		for f in "${ED}"${infodir}/*; do
+			if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
+				install-info --info-dir="${ED}"${infodir} "${f}" \
+					|| die "install-info failed"
+			fi
+		done
+	fi
+}
+
+pkg_postinst() {
+	elisp-site-regen
+	readme.gentoo_print_elog
+
+	if use livecd; then
+		# force an update of the emacs symlink for the livecd/dvd,
+		# because some microemacs packages set it with USE=livecd
+		eselect emacs update
+	elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
+		# refresh symlinks in case any installed files have changed
+		eselect emacs set ${EMACS_SUFFIX}
+	else
+		eselect emacs update ifunset
+	fi
+}
+
+pkg_postrm() {
+	elisp-site-regen
+	eselect emacs update ifunset
+}