Use https by default
[gentoo.git] / app-editors / emacs-vcs / emacs-vcs-25.0.50_pre20150531.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit autotools elisp-common eutils flag-o-matic multilib readme.gentoo
8
9 if [[ ${PV##*.} = 9999 ]]; then
10         inherit git-r3
11         EGIT_REPO_URI="git://git.sv.gnu.org/emacs.git"
12         EGIT_BRANCH="master"
13         EGIT_CHECKOUT_DIR="${WORKDIR}/emacs"
14         S="${EGIT_CHECKOUT_DIR}"
15 else
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
21         # operations later on
22         FULL_VERSION="${PV%%_*}"
23         #S="${WORKDIR}/emacs-${FULL_VERSION}"
24         S="${WORKDIR}/emacs"
25 fi
26
27 DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
28 HOMEPAGE="http://www.gnu.org/software/emacs/"
29
30 LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
31 SLOT="25"
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 )"
34
35 RDEPEND="sys-libs/ncurses
36         >=app-eselect/eselect-emacs-1.16
37         >=app-emacs/emacs-common-gentoo-1.5[games?,X?]
38         net-libs/liblockfile
39         acl? ( virtual/acl )
40         alsa? ( media-libs/alsa-lib )
41         dbus? ( sys-apps/dbus )
42         gfile? ( >=dev-libs/glib-2.28.6 )
43         gnutls? ( net-libs/gnutls )
44         gpm? ( sys-libs/gpm )
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 )
50         X? (
51                 x11-libs/libXmu
52                 x11-libs/libXt
53                 x11-misc/xbitmaps
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 )
63                 xft? (
64                         media-libs/fontconfig
65                         media-libs/freetype
66                         x11-libs/libXft
67                         cairo? ( >=x11-libs/cairo-1.12.18 )
68                         m17n-lib? (
69                                 >=dev-libs/libotf-0.9.4
70                                 >=dev-libs/m17n-lib-1.5.1
71                         )
72                 )
73                 gtk? (
74                         gtk3? ( x11-libs/gtk+:3 )
75                         !gtk3? ( x11-libs/gtk+:2 )
76                 )
77                 !gtk? (
78                         motif? ( >=x11-libs/motif-2.3:0 )
79                         !motif? (
80                                 Xaw3d? ( x11-libs/libXaw3d )
81                                 !Xaw3d? ( athena? ( x11-libs/libXaw ) )
82                         )
83                 )
84         )"
85
86 DEPEND="${RDEPEND}
87         virtual/pkgconfig
88         gzip-el? ( app-arch/gzip )
89         pax_kernel? (
90                 sys-apps/attr
91                 sys-apps/paxctl
92         )"
93
94 if [[ ${PV##*.} = 9999 ]]; then
95         DEPEND="${DEPEND}
96         sys-apps/texinfo"
97 fi
98
99 EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}"
100 SITEFILE="20${PN}-${SLOT}-gentoo.el"
101
102 src_prepare() {
103         if [[ ${PV##*.} = 9999 ]]; then
104                 FULL_VERSION=$(sed -n 's/^AC_INIT([^,]*,[ \t]*\([^ \t,)]*\).*/\1/p' \
105                         configure.ac)
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}"
112         fi
113
114         epatch_user
115
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"
119
120         AT_M4DIR=m4 eautoreconf
121 }
122
123 src_configure() {
124         strip-flags
125         filter-flags -pie                                       #526948
126
127         if use sh; then
128                 replace-flags "-O[1-9]" -O0             #262359
129         elif use ia64; then
130                 replace-flags "-O[2-9]" -O1             #325373
131         else
132                 replace-flags "-O[3-9]" -O2
133         fi
134
135         local myconf
136
137         if use alsa; then
138                 use sound || ewarn \
139                         "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
140                 myconf+=" --with-sound=alsa"
141         else
142                 myconf+=" --with-sound=$(usex sound oss)"
143         fi
144
145         if use X; then
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)"
157
158                 if use xft; then
159                         myconf+=" --with-xft"
160                         myconf+=" $(use_with cairo)"
161                         myconf+=" $(use_with m17n-lib libotf)"
162                         myconf+=" $(use_with m17n-lib m17n-flt)"
163                 else
164                         myconf+=" --without-xft"
165                         myconf+=" --without-cairo"
166                         myconf+=" --without-libotf --without-m17n-flt"
167                         use cairo && ewarn \
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."
171                 fi
172
173                 local f
174                 if use gtk; then
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.
184                         EOF
185                         myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)"
186                         for f in motif Xaw3d athena; do
187                                 use ${f} && ewarn \
188                                         "USE flag \"${f}\" has no effect if \"gtk\" is set."
189                         done
190                 elif use motif; then
191                         einfo "Configuring to build with Motif toolkit"
192                         myconf+=" --with-x-toolkit=motif"
193                         for f in Xaw3d athena; do
194                                 use ${f} && ewarn \
195                                         "USE flag \"${f}\" has no effect if \"motif\" is set."
196                         done
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)"
200                 else
201                         einfo "Configuring to build with no toolkit"
202                         myconf+=" --with-x-toolkit=no"
203                 fi
204         elif use aqua; then
205                 einfo "Configuring to build with Nextstep (Cocoa) support"
206                 myconf+=" --with-ns --disable-ns-self-contained"
207                 myconf+=" --without-x"
208         else
209                 myconf+=" --without-x --without-ns"
210         fi
211
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}"
217         fi
218
219         econf \
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) \
227                 $(use_enable acl) \
228                 $(use_with dbus) \
229                 $(use_with gnutls) \
230                 $(use_with gpm) \
231                 $(use_with hesiod) \
232                 $(use_with kerberos) $(use_with kerberos kerberos5) \
233                 $(use_with libxml2 xml2) \
234                 $(use_with selinux) \
235                 $(use_with wide-int) \
236                 $(use_with zlib) \
237                 ${myconf}
238 }
239
240 src_compile() {
241         export SANDBOX_ON=0                     # for the unbelievers, see Bug #131505
242         emake
243 }
244
245 src_install () {
246         emake DESTDIR="${D}" NO_BIN_LINK=t install
247
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"
252
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
258
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}
262         rm -rf "${ED}"/var
263
264         # remove unused <version>/site-lisp dir
265         rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
266
267         # remove COPYING file (except for etc/COPYING used by describe-copying)
268         rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
269
270         if use gzip-el; then
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"
275         fi
276
277         local cdir
278         if use source; then
279                 cdir="/usr/share/emacs/${FULL_VERSION}/src"
280                 insinto "${cdir}"
281                 # This is not meant to install all the source -- just the
282                 # C source you might find via find-function
283                 doins src/*.{c,h,m}
284         elif has installsources ${FEATURES}; then
285                 cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
286         fi
287
288         sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
289         X
290         ;;; ${PN}-${SLOT} site-lisp configuration
291         X
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\\\\>"))
298         X    (and path
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))))
302         X            (setq q (cdr q)))
303         X          (setcdr q (cons dir (delete dir (cdr q))))
304         X          (setq Info-directory-list (prune-directory-list (cdr p)))))))
305         EOF
306         elisp-site-file-install "${T}/${SITEFILE}" || die
307
308         dodoc README BUGS CONTRIBUTE
309
310         if use aqua; then
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
315         fi
316
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
333 }
334
335 pkg_preinst() {
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"
348                         fi
349                 done
350         fi
351 }
352
353 pkg_postinst() {
354         elisp-site-regen
355
356         local pvr
357         for pvr in ${REPLACING_VERSIONS}; do
358                 [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1
359         done
360         readme.gentoo_print_elog
361
362         if use livecd; then
363                 # force an update of the emacs symlink for the livecd/dvd,
364                 # because some microemacs packages set it with USE=livecd
365                 eselect emacs update
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}
369         else
370                 eselect emacs update ifunset
371         fi
372 }
373
374 pkg_postrm() {
375         elisp-site-regen
376         eselect emacs update ifunset
377 }