emacs-24.5-r3.ebuild 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. inherit autotools elisp-common eutils flag-o-matic multilib readme.gentoo-r1
  5. DESCRIPTION="The extensible, customizable, self-documenting real-time display editor"
  6. HOMEPAGE="https://www.gnu.org/software/emacs/"
  7. SRC_URI="mirror://gnu/emacs/${P}.tar.xz
  8. https://dev.gentoo.org/~ulm/emacs/${P}-patches-3.tar.xz"
  9. LICENSE="GPL-3+ FDL-1.3+ BSD HPND MIT W3C unicode PSF-2"
  10. SLOT="24"
  11. KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
  12. IUSE="acl alsa aqua athena dbus games gconf gfile gif gpm gsettings gtk +gtk3 gzip-el hesiod imagemagick +inotify jpeg kerberos libxml2 livecd m17n-lib motif pax_kernel png selinux sound source ssl svg tiff toolkit-scroll-bars wide-int X Xaw3d xft +xpm zlib"
  13. REQUIRED_USE="?? ( aqua X )"
  14. RDEPEND="sys-libs/ncurses:0=
  15. >=app-eselect/eselect-emacs-1.16
  16. >=app-emacs/emacs-common-gentoo-1.5[games?,X?]
  17. net-libs/liblockfile
  18. acl? ( virtual/acl )
  19. alsa? ( media-libs/alsa-lib )
  20. dbus? ( sys-apps/dbus )
  21. gpm? ( sys-libs/gpm )
  22. hesiod? ( net-dns/hesiod )
  23. !inotify? ( gfile? ( >=dev-libs/glib-2.28.6 ) )
  24. kerberos? ( virtual/krb5 )
  25. libxml2? ( >=dev-libs/libxml2-2.2.0 )
  26. selinux? ( sys-libs/libselinux )
  27. ssl? ( net-libs/gnutls )
  28. zlib? ( sys-libs/zlib )
  29. X? (
  30. x11-libs/libXmu
  31. x11-libs/libXt
  32. x11-misc/xbitmaps
  33. gconf? ( >=gnome-base/gconf-2.26.2 )
  34. gsettings? ( >=dev-libs/glib-2.28.6 )
  35. gif? ( media-libs/giflib:0= )
  36. jpeg? ( virtual/jpeg:0= )
  37. png? ( >=media-libs/libpng-1.4:0= )
  38. svg? ( >=gnome-base/librsvg-2.0 )
  39. tiff? ( media-libs/tiff:0 )
  40. xpm? ( x11-libs/libXpm )
  41. imagemagick? ( >=media-gfx/imagemagick-6.6.2:0= )
  42. xft? (
  43. media-libs/fontconfig
  44. media-libs/freetype
  45. x11-libs/libXft
  46. m17n-lib? (
  47. >=dev-libs/libotf-0.9.4
  48. >=dev-libs/m17n-lib-1.5.1
  49. )
  50. )
  51. gtk? (
  52. gtk3? ( x11-libs/gtk+:3 )
  53. !gtk3? ( x11-libs/gtk+:2 )
  54. )
  55. !gtk? (
  56. motif? ( >=x11-libs/motif-2.3:0 )
  57. !motif? (
  58. Xaw3d? ( x11-libs/libXaw3d )
  59. !Xaw3d? ( athena? ( x11-libs/libXaw ) )
  60. )
  61. )
  62. )"
  63. DEPEND="${RDEPEND}
  64. virtual/pkgconfig
  65. gzip-el? ( app-arch/gzip )
  66. pax_kernel? ( sys-apps/attr )"
  67. RDEPEND="${RDEPEND}
  68. !<app-editors/emacs-vcs-${PV}"
  69. EMACS_SUFFIX="${PN/emacs/emacs-${SLOT}}"
  70. SITEFILE="20${PN}-${SLOT}-gentoo.el"
  71. # FULL_VERSION keeps the full version number, which is needed in
  72. # order to determine some path information correctly for copy/move
  73. # operations later on
  74. FULL_VERSION="${PV%%_*}"
  75. S="${WORKDIR}/emacs-${FULL_VERSION}"
  76. src_prepare() {
  77. eapply ../patch
  78. eapply_user
  79. # Fix filename reference in redirected man page
  80. sed -i -e "/^\\.so/s/etags/&-${EMACS_SUFFIX}/" doc/man/ctags.1 \
  81. || die "unable to sed ctags.1"
  82. AT_M4DIR=m4 eautoreconf
  83. touch src/stamp-h.in || die
  84. }
  85. src_configure() {
  86. strip-flags
  87. filter-flags -pie #526948
  88. if use sh; then
  89. replace-flags "-O[1-9]" -O0 #262359
  90. elif use ia64; then
  91. replace-flags "-O[2-9]" -O1 #325373
  92. else
  93. replace-flags "-O[3-9]" -O2
  94. fi
  95. local myconf
  96. if use alsa; then
  97. use sound || ewarn \
  98. "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
  99. myconf+=" --with-sound=alsa"
  100. else
  101. myconf+=" --with-sound=$(usex sound oss)"
  102. fi
  103. if use X; then
  104. myconf+=" --with-x --without-ns"
  105. myconf+=" $(use_with gconf)"
  106. myconf+=" $(use_with gsettings)"
  107. myconf+=" $(use_with toolkit-scroll-bars)"
  108. myconf+=" $(use_with gif)"
  109. myconf+=" $(use_with jpeg)"
  110. myconf+=" $(use_with png)"
  111. myconf+=" $(use_with svg rsvg)"
  112. myconf+=" $(use_with tiff)"
  113. myconf+=" $(use_with xpm)"
  114. myconf+=" $(use_with imagemagick)"
  115. if use xft; then
  116. myconf+=" --with-xft"
  117. myconf+=" $(use_with m17n-lib libotf)"
  118. myconf+=" $(use_with m17n-lib m17n-flt)"
  119. else
  120. myconf+=" --without-xft"
  121. myconf+=" --without-libotf --without-m17n-flt"
  122. use m17n-lib && ewarn \
  123. "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
  124. fi
  125. local f line
  126. if use gtk; then
  127. einfo "Configuring to build with GIMP Toolkit (GTK+)"
  128. while read line; do ewarn "${line}"; done <<-EOF
  129. Your version of GTK+ will have problems with closing open
  130. displays. This is no problem if you just use one display, but
  131. if you use more than one and close one of them Emacs may crash.
  132. See <https://bugzilla.gnome.org/show_bug.cgi?id=85715>.
  133. If you intend to use more than one display, then it is strongly
  134. recommended that you compile Emacs with the Athena/Lucid or the
  135. Motif toolkit instead.
  136. EOF
  137. myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)"
  138. for f in motif Xaw3d athena; do
  139. use ${f} && ewarn \
  140. "USE flag \"${f}\" has no effect if \"gtk\" is set."
  141. done
  142. elif use motif; then
  143. einfo "Configuring to build with Motif toolkit"
  144. myconf+=" --with-x-toolkit=motif"
  145. for f in Xaw3d athena; do
  146. use ${f} && ewarn \
  147. "USE flag \"${f}\" has no effect if \"motif\" is set."
  148. done
  149. elif use athena || use Xaw3d; then
  150. einfo "Configuring to build with Athena/Lucid toolkit"
  151. myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
  152. else
  153. einfo "Configuring to build with no toolkit"
  154. myconf+=" --with-x-toolkit=no"
  155. fi
  156. elif use aqua; then
  157. einfo "Configuring to build with Nextstep (Cocoa) support"
  158. myconf+=" --with-ns --disable-ns-self-contained"
  159. myconf+=" --without-x"
  160. else
  161. myconf+=" --without-x --without-ns"
  162. fi
  163. # Save version information in the Emacs binary. It will be available
  164. # in variable "system-configuration-options".
  165. myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
  166. econf \
  167. --program-suffix="-${EMACS_SUFFIX}" \
  168. --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
  169. --localstatedir="${EPREFIX}"/var \
  170. --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
  171. --with-gameuser=":gamestat" \
  172. --without-compress-install \
  173. --with-file-notification=$(usev inotify || usev gfile || echo no) \
  174. $(use_enable acl) \
  175. $(use_with dbus) \
  176. $(use_with gpm) \
  177. $(use_with hesiod) \
  178. $(use_with kerberos) $(use_with kerberos kerberos5) \
  179. $(use_with libxml2 xml2) \
  180. $(use_with selinux) \
  181. $(use_with ssl gnutls) \
  182. $(use_with wide-int) \
  183. $(use_with zlib) \
  184. ${myconf}
  185. }
  186. src_compile() {
  187. export SANDBOX_ON=0 # for the unbelievers, see Bug #131505
  188. emake
  189. }
  190. src_install () {
  191. emake DESTDIR="${D}" NO_BIN_LINK=t install
  192. mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} \
  193. || die "moving emacs executable failed"
  194. mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 \
  195. || die "moving emacs man page failed"
  196. # move info dir to avoid collisions with the dir file generated by portage
  197. mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
  198. || die "moving info dir failed"
  199. touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
  200. docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
  201. # avoid collision between slots, see bug #169033 e.g.
  202. rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
  203. rm -rf "${ED}"/usr/share/{applications,icons}
  204. rm -rf "${ED}"/var
  205. # remove unused <version>/site-lisp dir
  206. rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
  207. # remove COPYING file (except for etc/COPYING used by describe-copying)
  208. rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
  209. if use gzip-el; then
  210. # compress .el files when a corresponding .elc exists
  211. find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \
  212. -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n
  213. assert "gzip .el failed"
  214. fi
  215. local cdir
  216. if use source; then
  217. cdir="/usr/share/emacs/${FULL_VERSION}/src"
  218. insinto "${cdir}"
  219. # This is not meant to install all the source -- just the
  220. # C source you might find via find-function
  221. doins src/*.{c,h,m}
  222. elif has installsources ${FEATURES}; then
  223. cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
  224. fi
  225. sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
  226. X
  227. ;;; ${PN}-${SLOT} site-lisp configuration
  228. X
  229. (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
  230. Y (setq find-function-C-source-directory
  231. Y "${EPREFIX}${cdir}")
  232. X (let ((path (getenv "INFOPATH"))
  233. X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
  234. X (re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
  235. X (and path
  236. X ;; move Emacs Info dir before anything else in /usr/share/info
  237. X (let* ((p (cons nil (split-string path ":" t))) (q p))
  238. X (while (and (cdr q) (not (string-match re (cadr q))))
  239. X (setq q (cdr q)))
  240. X (setcdr q (cons dir (delete dir (cdr q))))
  241. X (setq Info-directory-list (prune-directory-list (cdr p)))))))
  242. EOF
  243. elisp-site-file-install "${T}/${SITEFILE}" || die
  244. dodoc README BUGS
  245. if use aqua; then
  246. dodir /Applications/Gentoo
  247. rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
  248. mv nextstep/Emacs.app \
  249. "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
  250. fi
  251. DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
  252. through the Emacs eselect module, which also redirects man and info
  253. pages. Therefore, several Emacs versions can be installed at the
  254. same time. \"man emacs.eselect\" for details.
  255. \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is
  256. strongly recommended that you use app-admin/emacs-updater to rebuild
  257. all byte-compiled elisp files of the installed Emacs packages."
  258. use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
  259. Installing media-fonts/font-adobe-{75,100}dpi on the X server's
  260. machine would satisfy basic Emacs requirements under X11.
  261. See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
  262. for how to enable anti-aliased fonts."
  263. use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
  264. \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
  265. it into /Applications by yourself."
  266. readme.gentoo_create_doc
  267. }
  268. pkg_preinst() {
  269. # move Info dir file to correct name
  270. local infodir=/usr/share/info/${EMACS_SUFFIX} f
  271. if [[ -f ${ED}${infodir}/dir.orig ]]; then
  272. mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
  273. elif [[ -d "${ED}"${infodir} ]]; then
  274. # this should not happen in EAPI 4
  275. ewarn "Regenerating Info directory index in ${infodir} ..."
  276. rm -f "${ED}"${infodir}/dir{,.*}
  277. for f in "${ED}"${infodir}/*; do
  278. if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
  279. install-info --info-dir="${ED}"${infodir} "${f}" \
  280. || die "install-info failed"
  281. fi
  282. done
  283. fi
  284. }
  285. pkg_postinst() {
  286. elisp-site-regen
  287. local pvr
  288. for pvr in ${REPLACING_VERSIONS}; do
  289. [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1
  290. done
  291. readme.gentoo_print_elog
  292. if use livecd; then
  293. # force an update of the emacs symlink for the livecd/dvd,
  294. # because some microemacs packages set it with USE=livecd
  295. eselect emacs update
  296. elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
  297. # refresh symlinks in case any installed files have changed
  298. eselect emacs set ${EMACS_SUFFIX}
  299. else
  300. eselect emacs update ifunset
  301. fi
  302. }
  303. pkg_postrm() {
  304. elisp-site-regen
  305. eselect emacs update ifunset
  306. }