emacs-23.4-r14.ebuild 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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-19.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. }
  89. src_configure() {
  90. strip-flags
  91. filter-flags -fstrict-aliasing -pie
  92. append-flags $(test-flags -fno-strict-aliasing)
  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 && ! use sound; then
  102. einfo "Although sound USE flag is disabled you chose to have alsa,"
  103. einfo "so sound is switched on anyway."
  104. myconf+=" --with-sound"
  105. else
  106. myconf+=" $(use_with sound)"
  107. fi
  108. if use X; then
  109. myconf+=" --with-x --without-ns"
  110. myconf+=" $(use_with gconf)"
  111. myconf+=" $(use_with toolkit-scroll-bars)"
  112. myconf+=" $(use_with gif)"
  113. myconf+=" $(use_with jpeg)"
  114. myconf+=" $(use_with png)"
  115. myconf+=" $(use_with svg rsvg)"
  116. myconf+=" $(use_with tiff)"
  117. myconf+=" $(use_with xpm)"
  118. if use xft; then
  119. myconf+=" --with-xft"
  120. myconf+=" $(use_with m17n-lib libotf)"
  121. myconf+=" $(use_with m17n-lib m17n-flt)"
  122. else
  123. myconf+=" --without-xft"
  124. myconf+=" --without-libotf --without-m17n-flt"
  125. use m17n-lib && ewarn \
  126. "USE flag \"m17n-lib\" has no effect if \"xft\" is not set."
  127. fi
  128. # GTK+ is the default toolkit if USE=gtk is chosen with other
  129. # possibilities. Emacs upstream thinks this should be standard
  130. # policy on all distributions
  131. local f
  132. if use gtk; then
  133. einfo "Configuring to build with GIMP Toolkit (GTK+)"
  134. myconf+=" --with-x-toolkit=gtk"
  135. for f in motif Xaw3d athena; do
  136. use ${f} && ewarn \
  137. "USE flag \"${f}\" has no effect if \"gtk\" is set."
  138. done
  139. elif use motif; then
  140. einfo "Configuring to build with Motif toolkit"
  141. myconf+=" --with-x-toolkit=motif"
  142. for f in Xaw3d athena; do
  143. use ${f} && ewarn \
  144. "USE flag \"${f}\" has no effect if \"motif\" is set."
  145. done
  146. elif use athena || use Xaw3d; then
  147. einfo "Configuring to build with Athena/Lucid toolkit"
  148. myconf+=" --with-x-toolkit=lucid $(use_with Xaw3d xaw3d)"
  149. else
  150. einfo "Configuring to build with no toolkit"
  151. myconf+=" --with-x-toolkit=no"
  152. fi
  153. elif use aqua; then
  154. einfo "Configuring to build with Nextstep (Cocoa) support"
  155. myconf+=" --with-ns --disable-ns-self-contained"
  156. myconf+=" --without-x"
  157. else
  158. myconf+=" --without-x --without-ns"
  159. fi
  160. # Save version information in the Emacs binary. It will be available
  161. # in variable "system-configuration-options".
  162. myconf+=" GENTOO_PACKAGE=${CATEGORY}/${PF}"
  163. # According to configure, this option is only used for GNU/Linux
  164. # (x86_64 and s390). For Gentoo Prefix we have to explicitly spell
  165. # out the location because $(get_libdir) does not necessarily return
  166. # something that matches the host OS's libdir naming (e.g. RHEL).
  167. local crtdir=$($(tc-getCC) -print-file-name=crt1.o)
  168. crtdir=${crtdir%/*}
  169. econf \
  170. --program-suffix="-${EMACS_SUFFIX}" \
  171. --infodir="${EPREFIX}"/usr/share/info/${EMACS_SUFFIX} \
  172. --localstatedir="${EPREFIX}"/var \
  173. --enable-locallisppath="${EPREFIX}/etc/emacs:${EPREFIX}${SITELISP}" \
  174. --with-crt-dir="${crtdir}" \
  175. --with-gameuser=":gamestat" \
  176. $(use_with hesiod) \
  177. $(use_with kerberos) $(use_with kerberos kerberos5) \
  178. $(use_with gpm) \
  179. $(use_with dbus) \
  180. ${myconf}
  181. }
  182. src_compile() {
  183. export SANDBOX_ON=0 # for the unbelievers, see Bug #131505
  184. emake CC="$(tc-getCC)" \
  185. AR="$(tc-getAR) cq" \
  186. RANLIB="$(tc-getRANLIB)"
  187. }
  188. src_install () {
  189. emake DESTDIR="${D}" install
  190. rm "${ED}"/usr/bin/emacs-${FULL_VERSION}-${EMACS_SUFFIX} \
  191. || die "removing duplicate emacs executable failed"
  192. mv "${ED}"/usr/bin/emacs-${EMACS_SUFFIX} "${ED}"/usr/bin/${EMACS_SUFFIX} \
  193. || die "moving emacs executable failed"
  194. # move man pages to the correct place
  195. local m
  196. mv "${ED}"/usr/share/man/man1/{emacs,${EMACS_SUFFIX}}.1 \
  197. || die "moving emacs man page failed"
  198. for m in b2m ctags ebrowse emacsclient etags grep-changelog rcs-checkin; do
  199. mv "${ED}"/usr/share/man/man1/${m}{,-${EMACS_SUFFIX}}.1 \
  200. || die "moving ${m} man page failed"
  201. done
  202. # move info dir to avoid collisions with the dir file generated by portage
  203. mv "${ED}"/usr/share/info/${EMACS_SUFFIX}/dir{,.orig} \
  204. || die "moving info dir failed"
  205. touch "${ED}"/usr/share/info/${EMACS_SUFFIX}/.keepinfodir
  206. docompress -x /usr/share/info/${EMACS_SUFFIX}/dir.orig
  207. # avoid collision between slots, see bug #169033 e.g.
  208. rm "${ED}"/usr/share/emacs/site-lisp/subdirs.el
  209. rm -rf "${ED}"/usr/share/{applications,icons}
  210. rm -rf "${ED}"/var
  211. # remove unused <version>/site-lisp dir
  212. rm -rf "${ED}"/usr/share/emacs/${FULL_VERSION}/site-lisp
  213. # remove COPYING file (except for etc/COPYING used by describe-copying)
  214. rm "${ED}"/usr/share/emacs/${FULL_VERSION}/lisp/COPYING
  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. doins -r src/{m,s}
  223. rm "${ED}"/usr/share/emacs/${FULL_VERSION}/src/Makefile.c
  224. rm "${ED}"/usr/share/emacs/${FULL_VERSION}/src/{m,s}/README
  225. elif has installsources ${FEATURES}; then
  226. cdir="/usr/src/debug/${CATEGORY}/${PF}/${S#"${WORKDIR}/"}/src"
  227. fi
  228. sed -e "${cdir:+#}/^Y/d" -e "s/^[XY]//" >"${T}/${SITEFILE}" <<-EOF
  229. X
  230. ;;; ${PN}-${SLOT} site-lisp configuration
  231. X
  232. (when (string-match "\\\\\`${FULL_VERSION//./\\\\.}\\\\>" emacs-version)
  233. Y (setq find-function-C-source-directory
  234. Y "${EPREFIX}${cdir}")
  235. X (let ((path (getenv "INFOPATH"))
  236. X (dir "${EPREFIX}/usr/share/info/${EMACS_SUFFIX}")
  237. X (re "\\\\\`${EPREFIX}/usr/share/info\\\\>"))
  238. X (and path
  239. X ;; move Emacs Info dir before anything else in /usr/share/info
  240. X (let* ((p (cons nil (split-string path ":" t))) (q p))
  241. X (while (and (cdr q) (not (string-match re (cadr q))))
  242. X (setq q (cdr q)))
  243. X (setcdr q (cons dir (delete dir (cdr q))))
  244. X (setq Info-directory-list (prune-directory-list (cdr p)))))))
  245. EOF
  246. elisp-site-file-install "${T}/${SITEFILE}" || die
  247. dodoc README BUGS
  248. if use aqua; then
  249. dodir /Applications/Gentoo
  250. rm -rf "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app
  251. mv nextstep/Emacs.app \
  252. "${ED}"/Applications/Gentoo/Emacs${EMACS_SUFFIX#emacs}.app || die
  253. fi
  254. DOC_CONTENTS="You can set the version to be started by /usr/bin/emacs
  255. through the Emacs eselect module, which also redirects man and info
  256. pages. Therefore, several Emacs versions can be installed at the
  257. same time. \"man emacs.eselect\" for details.
  258. \\n\\nIf you upgrade from a previous major version of Emacs, then
  259. it is strongly recommended that you use app-admin/emacs-updater
  260. to rebuild all byte-compiled elisp files of the installed Emacs
  261. packages."
  262. use X && DOC_CONTENTS+="\\n\\nYou need to install some fonts for Emacs.
  263. Installing media-fonts/font-adobe-{75,100}dpi on the X server's
  264. machine would satisfy basic Emacs requirements under X11.
  265. See also https://wiki.gentoo.org/wiki/Xft_support_for_GNU_Emacs
  266. for how to enable anti-aliased fonts."
  267. use aqua && DOC_CONTENTS+="\\n\\nEmacs${EMACS_SUFFIX#emacs}.app is in
  268. \"${EPREFIX}/Applications/Gentoo\". You may want to copy or symlink
  269. it into /Applications by yourself."
  270. readme.gentoo_create_doc
  271. }
  272. pkg_preinst() {
  273. # move Info dir file to correct name
  274. local infodir=/usr/share/info/${EMACS_SUFFIX} f
  275. if [[ -f ${ED}${infodir}/dir.orig ]]; then
  276. mv "${ED}"${infodir}/dir{.orig,} || die "moving info dir failed"
  277. elif [[ -d "${ED}"${infodir} ]]; then
  278. # this should not happen in EAPI 4
  279. ewarn "Regenerating Info directory index in ${infodir} ..."
  280. rm -f "${ED}"${infodir}/dir{,.*}
  281. for f in "${ED}"${infodir}/*; do
  282. if [[ ${f##*/} != *-[0-9]* && -e ${f} ]]; then
  283. install-info --info-dir="${ED}"${infodir} "${f}" \
  284. || die "install-info failed"
  285. fi
  286. done
  287. fi
  288. }
  289. pkg_postinst() {
  290. elisp-site-regen
  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. }