emacs-25.1.ebuild 11 KB

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