emacs-vcs-26.0.9999.ebuild 12 KB

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