emacs-23.4-r15.ebuild 11 KB

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