0448ac2094c645703130cf27b422848beeeee19f
[gentoo-soor-overlay.git] / app-editors / emacs-git / emacs-git-23.0.9999.ebuild
blob0448ac2094c645703130cf27b422848beeeee19f
1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
5 EAPI="1"
7 EGIT_REPO_URI="git://git.sv.gnu.org/emacs.git"
9 WANT_AUTOCONF="latest"
10 WANT_AUTOMAKE="latest"
12 inherit autotools git elisp-common eutils flag-o-matic
14 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
15 HOMEPAGE="http://www.gnu.org/software/emacs/"
16 SRC_URI=""
18 LICENSE="GPL-3 FDL-1.2 BSD"
19 SLOT="23"
20 KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
22 IUSE="alsa dbus gif gpm gtk gzip-el hesiod jpeg kerberos m17n-lib motif png spell sound source svg tiff toolkit-scroll-bars X Xaw3d xft xpm"
23 RESTRICT="strip"
25 RDEPEND="sys-libs/ncurses
26 >=app-admin/eselect-emacs-1.2
27 net-libs/liblockfile
28 hesiod? ( net-dns/hesiod )
29 kerberos? ( virtual/krb5 )
30 spell? ( || ( app-text/ispell app-text/aspell ) )
31 alsa? ( media-libs/alsa-lib )
32 gpm? ( sys-libs/gpm )
33 dbus? ( sys-apps/dbus )
34 X? (
35 x11-libs/libXmu
36 x11-libs/libXt
37 x11-misc/xbitmaps
38 x11-misc/emacs-desktop
39 gif? ( media-libs/giflib )
40 jpeg? ( media-libs/jpeg )
41 png? ( media-libs/libpng )
42 svg? ( gnome-base/librsvg:2 )
43 tiff? ( media-libs/tiff )
44 xpm? ( x11-libs/libXpm )
45 xft? (
46 media-libs/fontconfig
47 media-libs/freetype
48 virtual/xft
49 m17n-lib? (
50 >=dev-libs/libotf-0.9.4
51 >=dev-libs/m17n-lib-1.5.1
54 gtk? ( x11-libs/gtk+:2 )
55 !gtk? (
56 Xaw3d? ( x11-libs/Xaw3d )
57 !Xaw3d? (
58 motif? ( virtual/motif )
63 DEPEND="${RDEPEND}
64 dev-util/git
65 dev-util/pkgconfig
66 gzip-el? ( app-arch/gzip )"
68 S="${WORKDIR}/${ECVS_LOCALNAME}"
70 EMACS_SUFFIX="emacs-${SLOT}"
72 src_unpack() {
73 git_src_unpack
75 cd "${S}"
76 # FULL_VERSION keeps the full version number, which is needed in
77 # order to determine some path information correctly for copy/move
78 # operations later on
79 FULL_VERSION=$(grep 'defconst[ ]*emacs-version' lisp/version.el \
80 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/')
81 [[ -z "${FULL_VERSION}" ]] && die "Cannot determine current Emacs version"
82 echo
83 einfo "Emacs CVS branch: ${ECVS_BRANCH}"
84 einfo "Emacs version number: ${FULL_VERSION}"
85 [[ "${FULL_VERSION%.*}" == ${PV%.*} ]] \
86 || die "Upstream version number changed to ${FULL_VERSION}"
87 echo
89 epatch "${FILESDIR}/${PN}-freebsd-sparc.patch"
91 sed -i -e "s:/usr/lib/crtbegin.o:$(`tc-getCC` -print-file-name=crtbegin.o):g" \
92 -e "s:/usr/lib/crtend.o:$(`tc-getCC` -print-file-name=crtend.o):g" \
93 "${S}"/src/s/freebsd.h || die "unable to sed freebsd.h settings"
95 if ! use alsa; then
96 # ALSA is detected even if not requested by its USE flag.
97 # Suppress it by supplying pkg-config with a wrong library name.
98 sed -i -e "/ALSA_MODULES=/s/alsa/DiSaBlEaLsA/" configure.in \
99 || die "unable to sed configure.in"
101 if ! use gzip-el; then
102 # Emacs' build system automatically detects the gzip binary and
103 # compresses el files. We don't want that so confuse it with a
104 # wrong binary name
105 sed -i -e "s/ gzip/ PrEvEnTcOmPrEsSiOn/" configure.in \
106 || die "unable to sed configure.in"
109 eautoreconf
112 src_compile() {
113 export SANDBOX_ON=0 # for the unbelievers, see Bug #131505
115 unset ALLOWED_FLAGS
116 setup-allowed-flags
117 ALLOWED_FLAGS="${ALLOWED_FLAGS} -DSYSTEM_PURESIZE_EXTRA -DSITELOAD_PURESIZE_EXTRA"
118 strip-flags
119 replace-flags -O[3-9] -O2
120 replace-flags -Os -O2
122 local myconf
124 if use alsa && ! use sound; then
125 echo
126 einfo "Although sound USE flag is disabled you chose to have alsa,"
127 einfo "so sound is switched on anyway."
128 echo
129 myconf="${myconf} --with-sound"
130 else
131 myconf="${myconf} $(use_with sound)"
134 if use X; then
135 myconf="${myconf} --with-x"
136 myconf="${myconf} $(use_with toolkit-scroll-bars)"
137 myconf="${myconf} $(use_with gif) $(use_with jpeg)"
138 myconf="${myconf} $(use_with png) $(use_with svg rsvg)"
139 myconf="${myconf} $(use_with tiff) $(use_with xpm)"
141 myconf="${myconf} $(use_enable xft font-backend)"
142 myconf="${myconf} $(use_with xft freetype) $(use_with xft)"
144 if use xft; then
145 myconf="${myconf} $(use_with m17n-lib libotf)"
146 myconf="${myconf} $(use_with m17n-lib m17n-flt)"
147 else
148 myconf="${myconf} --without-libotf --without-m17n-flt"
149 use m17n-lib && einfo \
150 "USE flag \"m17n-lib\" has no effect because xft is not set."
153 # GTK+ is the default toolkit if USE=gtk is chosen with other
154 # possibilities. Emacs upstream thinks this should be standard
155 # policy on all distributions
156 if use gtk; then
157 einfo "Configuring to build with GIMP Toolkit (GTK+)"
158 myconf="${myconf} --with-x-toolkit=gtk"
159 elif use Xaw3d; then
160 einfo "Configuring to build with Xaw3d (Athena) toolkit"
161 myconf="${myconf} --with-x-toolkit=athena"
162 elif use motif; then
163 einfo "Configuring to build with Motif toolkit"
164 myconf="${myconf} --with-x-toolkit=motif"
165 else
166 einfo "Configuring to build with no toolkit"
167 myconf="${myconf} --with-x-toolkit=no"
169 else
170 myconf="${myconf} --without-x"
173 myconf="${myconf} $(use_with hesiod)"
174 myconf="${myconf} $(use_with kerberos) $(use_with kerberos kerberos5)"
175 myconf="${myconf} $(use_with gpm) $(use_with dbus)"
177 econf \
178 --program-suffix=-${EMACS_SUFFIX} \
179 --infodir=/usr/share/info/${EMACS_SUFFIX} \
180 --without-carbon \
181 ${myconf} || die "econf emacs failed"
183 emake CC="$(tc-getCC)" bootstrap || die "make bootstrap failed"
186 src_install () {
187 local i m
189 emake install DESTDIR="${D}" || die "make install failed"
191 rm "${D}"/usr/bin/emacs-${FULL_VERSION}-${EMACS_SUFFIX} \
192 || die "removing duplicate emacs executable failed"
193 mv "${D}"/usr/bin/emacs-${EMACS_SUFFIX} "${D}"/usr/bin/${EMACS_SUFFIX} \
194 || die "moving Emacs executable failed"
196 # move info documentation to the correct place
197 einfo "Fixing info documentation ..."
198 for i in "${D}"/usr/share/info/${EMACS_SUFFIX}/*; do
199 mv "${i}" "${i}.info" || die "mv info failed"
200 done
202 # move man pages to the correct place
203 einfo "Fixing manpages ..."
204 for m in "${D}"/usr/share/man/man1/* ; do
205 mv "${m}" "${m%.1}-${EMACS_SUFFIX}.1" || die "mv man failed"
206 done
208 # avoid collision between slots, see bug #169033 e.g.
209 rm "${D}"/usr/share/emacs/site-lisp/subdirs.el
210 rm -rf "${D}"/usr/share/{applications,icons}
211 rm "${D}"/var/lib/games/emacs/{snake,tetris}-scores
212 keepdir /usr/share/emacs/site-lisp
213 keepdir /var/lib/games/emacs
215 if use source; then
216 insinto /usr/share/emacs/${FULL_VERSION}/src
217 # This is not meant to install all the source -- just the
218 # C source you might find via find-function
219 doins src/*.[ch]
220 sed 's/^X//' >10${PN}-${SLOT}-gentoo.el <<-EOF
222 ;;; ${PN}-${SLOT} site-lisp configuration
224 (if (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
225 X (setq find-function-C-source-directory
226 X "/usr/share/emacs/${FULL_VERSION}/src"))
228 elisp-site-file-install 10${PN}-${SLOT}-gentoo.el
231 dodoc README BUGS || die "dodoc failed"
234 emacs-infodir-rebuild() {
235 # Depending on the Portage version, the Info dir file is compressed
236 # or removed. It is only rebuilt by Portage if our directory is in
237 # INFOPATH, which is not guaranteed. So we rebuild it ourselves.
239 local infodir=/usr/share/info/${EMACS_SUFFIX} f
240 einfo "Regenerating Info directory index in ${infodir} ..."
241 rm -f "${ROOT}"${infodir}/dir{,.*}
242 for f in "${ROOT}"${infodir}/*.info*; do
243 [[ ${f##*/} == *[0-9].info* ]] \
244 || install-info --info-dir="${ROOT}"${infodir} "${f}" &>/dev/null
245 done
246 rmdir "${ROOT}"${infodir} 2>/dev/null # remove dir if it is empty
247 echo
250 pkg_postinst() {
251 [[ -f "${ROOT}"/usr/share/emacs/site-lisp/subdirs.el ]] \
252 || cp "${ROOT}"/usr/share/emacs{/${FULL_VERSION},}/site-lisp/subdirs.el
254 local f
255 for f in "${ROOT}"/var/lib/games/emacs/{snake,tetris}-scores; do
256 [[ -e "${f}" ]] || touch "${f}"
257 done
259 elisp-site-regen
260 emacs-infodir-rebuild
261 eselect emacs update ifunset
263 if use X; then
264 elog "You need to install some fonts for Emacs. Under monolithic"
265 elog "XFree86/Xorg you typically had such fonts installed by default."
266 elog "With modular Xorg, you will have to perform this step yourself."
267 elog "Installing media-fonts/font-adobe-{75,100}dpi on the X server's"
268 elog "machine would satisfy basic Emacs requirements under X11."
271 echo
272 elog "You can set the version to be started by /usr/bin/emacs through"
273 elog "the Emacs eselect module, which also redirects man and info pages."
274 elog "You can therefore test emacs-cvs along with the stable release."
275 elog "\"man emacs.eselect\" for details."
278 pkg_postrm() {
279 elisp-site-regen
280 emacs-infodir-rebuild
281 eselect emacs update ifunset