emacs-24.4-r4.ebuild 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit autotools elisp-common eutils flag-o-matic multilib readme.gentoo
  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-5.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 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"
  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. gfile? ( >=dev-libs/glib-2.28.6 )
  22. gnutls? ( net-libs/gnutls )
  23. gpm? ( sys-libs/gpm )
  24. hesiod? ( net-dns/hesiod )
  25. kerberos? ( virtual/krb5 )
  26. libxml2? ( >=dev-libs/libxml2-2.2.0 )
  27. selinux? ( sys-libs/libselinux )
  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. EPATCH_SUFFIX=patch epatch
  78. epatch_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. }
  84. src_configure() {
  85. strip-flags
  86. filter-flags -pie #526948
  87. if use sh; then
  88. replace-flags "-O[1-9]" -O0 #262359
  89. elif use ia64; then
  90. replace-flags "-O[2-9]" -O1 #325373
  91. else
  92. replace-flags "-O[3-9]" -O2
  93. fi
  94. local myconf
  95. if use alsa; then
  96. use sound || ewarn \
  97. "USE flag \"alsa\" overrides \"-sound\"; enabling sound support."
  98. myconf+=" --with-sound=alsa"
  99. else
  100. myconf+=" --with-sound=$(usex sound oss)"
  101. fi
  102. if use X; then
  103. myconf+=" --with-x --without-ns"
  104. myconf+=" $(use_with gconf)"
  105. myconf+=" $(use_with gsettings)"
  106. myconf+=" $(use_with toolkit-scroll-bars)"
  107. myconf+=" $(use_with gif)"
  108. myconf+=" $(use_with jpeg)"
  109. myconf+=" $(use_with png)"
  110. myconf+=" $(use_with svg rsvg)"
  111. myconf+=" $(use_with tiff)"
  112. myconf+=" $(use_with xpm)"
  113. myconf+=" $(use_with imagemagick)"
  114. if use xft; then
  115. myconf+=" --with-xft"
  116. myconf+=" $(use_with m17n-lib libotf)"
  117. myconf+=" $(use_with m17n-lib m17n-flt)"
  118. else
  119. myconf+=" --without-xft"
  120. myconf+=" --without-libotf --without-m17n-flt"
  121. use m17n-lib && ewarn \
  122. "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
  123. fi
  124. local f
  125. if use gtk; then
  126. einfo "Configuring to build with GIMP Toolkit (GTK+)"
  127. myconf+=" --with-x-toolkit=$(usex gtk3 gtk3 gtk2)"
  128. for f in motif Xaw3d athena; do
  129. use ${f} && ewarn \
  130. "USE flag \"${f}\" has no effect if \"gtk\" is set."
  131. done
  132. elif use motif; then
  133. einfo "Configuring to build with Motif toolkit"
  134. myconf+=" --with-x-toolkit=motif"
  135. for f in Xaw3d athena; do
  136. use ${f} && ewarn \
  137. "USE flag \"${f}\" has no effect if \"motif\" is set."
  138. done
  139. elif use athena || use Xaw3d; then
  140. einfo "Configuring to build with Athena/Lucid toolkit"
  141. myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
  142. else
  143. einfo "Configuring to build with no toolkit"
  144. myconf+=" --with-x-toolkit=no"
  145. fi
  146. elif use aqua; then
  147. einfo "Configuring to build with Nextstep (Cocoa) support"
  148. myconf+=" --with-ns --disable-ns-self-contained"
  149. myconf+=" --without-x"
  150. else
  151. myconf+=" --without-x --without-ns"
  152. fi
  153. # Save version information in the Emacs binary. It will be available
  154. # in variable "system-configuration-options".
  155. myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
  156. econf \
  157. --program-suffix="-${EMACS_SUFFIX}" \
  158. --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
  159. --localstatedir="${EPREFIX}"/var \
  160. --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
  161. --with-gameuser=":gamestat" \
  162. --without-compress-install \
  163. --with-file-notification=$(usev gfile || usev inotify || echo no) \
  164. $(use_enable acl) \
  165. $(use_with dbus) \
  166. $(use_with gnutls) \
  167. $(use_with gpm) \
  168. $(use_with hesiod) \
  169. $(use_with kerberos) $(use_with kerberos kerberos5) \
  170. $(use_with libxml2 xml2) \
  171. $(use_with selinux) \
  172. $(use_with wide-int) \
  173. $(use_with zlib) \
  174. ${myconf}
  175. }
  176. src_compile() {
  177. export SANDBOX_ON=0 # for the unbelievers, see Bug #131505
  178. emake
  179. }
  180. src_install () {
  181. emake DESTDIR="${D}" NO_BIN_LINK=t install
  182. mv "${ED}"/usr/bin/{emacs-${FULL_VERSION}-,}${EMACS_SUFFIX} \
  183. || die "moving emacs executable failed"
  184. mv "${ED}"/usr/share/man/man1/{emacs-,}${EMACS_SUFFIX}.1 \
  185. || die "moving emacs man page failed"
  186. # move info dir to avoid collisions with the dir file generated by portage
  187. mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
  188. || die "moving info dir failed"
  189. touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
  190. docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
  191. # avoid collision between slots, see bug #169033 e.g.
  192. rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
  193. rm -rf "${ED}"/usr/share/{applications,icons}
  194. rm -rf "${ED}"/var
  195. # remove unused <version>/site-lisp dir
  196. rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
  197. # remove COPYING file (except for etc/COPYING used by describe-copying)
  198. rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
  199. if use gzip-el; then
  200. # compress .el files when a corresponding .elc exists
  201. find "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp -type f \
  202. -name "*.elc" -print | sed 's/\.elc$/.el/' | xargs gzip -9n
  203. assert "gzip .el failed"
  204. fi
  205. local cdir
  206. if use source; then
  207. cdir="/usr/share/emacs/${FULL_VERSION}/src"
  208. insinto "${cdir}"
  209. # This is not meant to install all the source -- just the
  210. # C source you might find via find-function
  211. doins src/*.{c,h,m}
  212. elif has installsources ${FEATURES}; then
  213. cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
  214. fi
  215. sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
  216. X
  217. ;;; ${PN}-${SLOT} site-lisp configuration
  218. X
  219. (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
  220. Y (setq find-function-C-source-directory
  221. Y "${EPREFIX}${cdir}")
  222. X (let ((path (getenv "INFOPATH"))
  223. X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
  224. X (re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
  225. X (and path
  226. X ;; move Emacs Info dir before anything else in /usr/share/info
  227. X (let* ((p (cons nil (split-string path ":" t))) (q p))
  228. X (while (and (cdr q) (not (string-match re (cadr q))))
  229. X (setq q (cdr q)))
  230. X (setcdr q (cons dir (delete dir (cdr q))))
  231. X (setq Info-directory-list (prune-directory-list (cdr p)))))))
  232. EOF
  233. elisp-site-file-install "${T}/${SITEFILE}" || die
  234. dodoc README BUGS
  235. if use aqua; then
  236. dodir /Applications/Gentoo
  237. rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
  238. mv nextstep/Emacs.app \
  239. "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
  240. fi
  241. DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
  242. through the Emacs eselect module, which also redirects man and info
  243. pages. Therefore, several Emacs versions can be installed at the
  244. same time. \"man emacs.eselect\" for details.
  245. \\n\\nIf you upgrade from Emacs version 24.2 or earlier, then it is
  246. strongly recommended that you use app-admin/emacs-updater to rebuild
  247. all byte-compiled elisp files of the installed Emacs packages."
  248. use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
  249. Installing media-fonts/font-adobe-{75,100}dpi on the X server's
  250. machine would satisfy basic Emacs requirements under X11.
  251. See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
  252. for how to enable anti-aliased fonts."
  253. use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
  254. \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
  255. it into /Applications by yourself."
  256. readme.gentoo_create_doc
  257. }
  258. pkg_preinst() {
  259. # move Info dir file to correct name
  260. local infodir=/usr/share/info/${EMACS_SUFFIX} f
  261. if [[ -f ${ED}${infodir}/dir.orig ]]; then
  262. mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
  263. elif [[ -d "${ED}"${infodir} ]]; then
  264. # this should not happen in EAPI 4
  265. ewarn "Regenerating Info directory index in ${infodir} ..."
  266. rm -f "${ED}"${infodir}/dir{,.*}
  267. for f in "${ED}"${infodir}/*; do
  268. if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
  269. install-info --info-dir="${ED}"${infodir} "${f}" \
  270. || die "install-info failed"
  271. fi
  272. done
  273. fi
  274. }
  275. pkg_postinst() {
  276. elisp-site-regen
  277. local pvr
  278. for pvr in ${REPLACING_VERSIONS}; do
  279. [[ ${pvr%%[-_]*} = 24.[12] ]] && FORCE_PRINT_ELOG=1
  280. done
  281. readme.gentoo_print_elog
  282. if use livecd; then
  283. # force an update of the emacs symlink for the livecd/dvd,
  284. # because some microemacs packages set it with USE=livecd
  285. eselect emacs update
  286. elif [[ $(readlink "${EROOT}"/usr/bin/emacs) = ${EMACS_SUFFIX} ]]; then
  287. # refresh symlinks in case any installed files have changed
  288. eselect emacs set ${EMACS_SUFFIX}
  289. else
  290. eselect emacs update ifunset
  291. fi
  292. }
  293. pkg_postrm() {
  294. elisp-site-regen
  295. eselect emacs update ifunset
  296. }