summaryrefslogtreecommitdiff
blob: b2d253cac3ff06334da4a2793f568331c07c3f6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-editors/emacs/emacs-22.0.50_pre20050225.ebuild,v 1.5 2005/12/12 03:52:00 spyderous Exp $

inherit elisp-common alternatives flag-o-matic eutils

IUSE="X Xaw3d aqua cjk gif gnome gtk jpeg multi-tty nls png spell tiff"

INLINE="inline_patch-20041229"
MULTI_TTY="emacs--multi-tty--0--patch-301.2005-02-25"

DESCRIPTION="Emacs is the extensible, customizable, self-documenting real-time display editor."
HOMEPAGE="http://www.gnu.org/software/emacs/
	http://macemacsjp.sourceforge.jp/
	http://lorentey.hu/project/emacs.html.en"
SRC_URI="mirror://gentoo/${P/_pre/-}.tar.gz
	cjk? ( mirror://sourceforge.jp/macemacsjp/12817/${INLINE}.tar.gz )
	multi-tty? ( http://lorentey.hu/downloads/emacs/multi-tty/${MULTI_TTY}.patch.gz )"

# Never use the sandbox, it causes Emacs to segfault on startup
SANDBOX_DISABLED="1"
RESTRICT="$RESTRICT nostrip"

DEPEND=">=sys-apps/portage-2.0.51
	>=sys-libs/ncurses-5.3
	sys-libs/gdbm
	spell? ( || ( app-text/ispell app-text/aspell ) )
	X? ( || ( ( x11-libs/libXext
				x11-libs/libICE
				x11-libs/libSM
				x11-libs/libXmu
				x11-libs/libXpm
				x11-misc/xbitmaps
				|| ( media-fonts/font-adobe-100dpi
					media-fonts/font-adobe-75dpi )
			)
			virtual/x11
		)
		gif? ( >=media-libs/giflib-4.1.0.1b )
		jpeg? ( >=media-libs/jpeg-6b )
		tiff? ( >=media-libs/tiff-3.5.7 )
		png? ( >=media-libs/libpng-1.2.5 )
		gtk? ( =x11-libs/gtk+-2* )
		!gtk? ( Xaw3d? ( x11-libs/Xaw3d ) )
		gnome? ( gnome-base/gnome-desktop ) )
	nls? ( >=sys-devel/gettext-0.11.5 )
	!=app-editors/emacs-cvs-21.3.50*
	!=app-editors/emacs-cvs-22.0.50*"

PROVIDE="virtual/emacs virtual/editor"

SLOT="22.0.50"
LICENSE="GPL-2"
# should run on other arches, but the ebuild is intended for ppc-macos
KEYWORDS="-* ~ppc-macos"

DFILE=emacs-${SLOT}.desktop

S=${WORKDIR}/${P%_*}

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${FILESDIR}/emacs-subdirs-el-gentoo.diff
	if use ppc-macos ; then
		use cjk && epatch ${WORKDIR}/${INLINE}/emacs-inline.patch
		epatch ${FILESDIR}/emacs-nofink-gentoo.diff
	fi
	if use multi-tty ; then
		if use aqua ; then
			ewarn "Carbon Emacs will not compile with multi-tty patch; disabling multi-tty."
			ewarn "If you want to use multi-tty, please trun off aqua USE flag."
			epause; ebeep; epause
		else
			epatch ../${MULTI_TTY}.patch
		fi
	fi

	# This will need to be updated for X-Compilation
	sed -i -e "s:/usr/lib/\([^ ]*\).o:/usr/$(get_libdir)/\1.o:g" \
	       ${S}/src/s/gnu-linux.h

	sed -i -e "s/-lungif/-lgif/g" configure* src/Makefile.in || die
}

src_compile() {

	strip-flags

	local myconf

	use nls || myconf="${myconf} --disable-nls"

	if use X; then
		myconf="${myconf} --with-x"
		myconf="${myconf} --with-xpm --with-toolkit-scroll-bars"
		myconf="${myconf} $(use_with jpeg) $(use_with tiff)"
		myconf="${myconf} $(use_with gif) $(use_with png)"
		if use gtk; then
			einfo "Configuring to build with GTK support"
			myconf="${myconf} --with-x-toolkit=gtk"
		elif use Xaw3d; then
			einfo "Configuring to build with Xaw3d support"
			myconf="${myconf} --with-x-toolkit=athena"
		else
			einfo "Configuring to build with lucid toolkit support"
			myconf="${myconf} --without-gtk"
			myconf="${myconf} --with-x-toolkit=lucid"
		fi
	fi

	if use aqua ; then
		einfo "Configuring to build with Carbon Emacs"
		econf --enable-debug \
			--enable-carbon-app=/Applications/Gentoo \
			--without-x \
			$(use_with jpeg) $(use_with tiff) \
			$(use_with gif) $(use_with png) \
			|| die "econf carbon emacs failed"
		emake -j1 || die "make carbon emacs bootstrap failed"
	fi

	econf --enable-debug \
		--program-suffix=.emacs-${SLOT} \
		--without-carbon \
		${myconf} || die "econf emacs failed"

	emake -j1 CC="$(tc-getCC)" || die "make emacs bootstrap failed"
}

src_install () {
	einstall || die
	rm ${D}/usr/bin/emacs-${SLOT}.emacs-${SLOT} || die "removing duplicate emacs executable failed"
	dohard /usr/bin/emacs.emacs-${SLOT} /usr/bin/emacs-${SLOT} || die

	if use aqua ; then
		einfo "Installing Carbon Emacs..."
		dodir /Applications/Gentoo/Emacs.app
		pushd mac/Emacs.app
		tar -chf - . | ( cd ${D}/Applications/Gentoo/Emacs.app; tar -xf -)
		popd
	fi

	# fix info documentation
	einfo "Fixing info documentation..."
	dodir /usr/share/info/emacs-${SLOT}
	mv ${D}/usr/share/info/{,emacs-${SLOT}/}dir || die "mv dir failed"
	for i in ${D}/usr/share/info/*
	do
		if [ "${i##*/}" != emacs-${SLOT} ] ; then
			mv ${i} ${i/info/info/emacs-${SLOT}}.info
			gzip -9 ${i/info/info/emacs-${SLOT}}.info
		fi
	done

	if has_version 'app-text/aspell' ; then
		# defaults to aspell if installed
		elisp-site-file-install ${FILESDIR}/40aspell-gentoo.el
	fi
	newenvd ${FILESDIR}/60emacs-${SLOT}.envd 60emacs-${SLOT}

	einfo "Fixing manpages..."
	for m in  ${D}/usr/share/man/man1/* ; do
		mv ${m} ${m/.1/-${SLOT}.1} || die "mv man failed"
	done

	dodoc BUGS ChangeLog README*

	if use gnome; then
		insinto /usr/share/applications
		doins ${FILESDIR}/${DFILE} || die "install desktop file faild"
	fi
}

update-alternatives() {
	for i in emacs emacsclient etags ctags b2m ebrowse \
		rcs-checkin grep-changelog ; do
		alternatives_auto_makesym "/usr/bin/$i" "/usr/bin/$i.emacs-*"
	done
}

pkg_postinst() {
	use ppc-macos || update-alternatives
	if use aqua && use cjk ; then
		einfo
		einfo "If you are going to use Japanese input method on Carbon Emacs,"
		einfo "put the following lines to your ~/.emacs.el"
		einfo "(if (eq window-system 'mac)"
		einfo "	(set-keyboard-coding-system 'sjis)"
		einfo
	fi
}

pkg_postrm() {
	use ppc-macos || update-alternatives
}