gdb-7.11.ebuild 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. PYTHON_COMPAT=( python{2_7,3_4,3_5} )
  5. inherit flag-o-matic eutils python-single-r1
  6. export CTARGET=${CTARGET:-${CHOST}}
  7. if [[ ${CTARGET} == ${CHOST} ]] ; then
  8. if [[ ${CATEGORY} == cross-* ]] ; then
  9. export CTARGET=${CATEGORY#cross-}
  10. fi
  11. fi
  12. is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
  13. RPM=
  14. MY_PV=${PV}
  15. case ${PV} in
  16. 9999*)
  17. # live git tree
  18. EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
  19. inherit git-2
  20. SRC_URI=""
  21. ;;
  22. *.*.50.2???????)
  23. # weekly snapshots
  24. SRC_URI="ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${PV}.tar.xz"
  25. ;;
  26. *.*.*.*.*.*)
  27. # fedora versions; note we swap the rpm & fedora core versions.
  28. # gdb-6.8.50.20090302-8.fc11.src.rpm -> gdb-6.8.50.20090302.11.8.ebuild
  29. # gdb-7.9-11.fc23.src.rpm -> gdb-7.9.23.11.ebuild
  30. inherit versionator rpm
  31. gvcr() { get_version_component_range "$@"; }
  32. parse_fedora_ver() {
  33. set -- $(get_version_components)
  34. MY_PV=$(gvcr 1-$(( $# - 2 )))
  35. RPM="${PN}-${MY_PV}-$(gvcr $#).fc$(gvcr $(( $# - 1 ))).src.rpm"
  36. }
  37. parse_fedora_ver
  38. SRC_URI="mirror://fedora-dev/development/rawhide/source/SRPMS/g/${RPM}"
  39. ;;
  40. *)
  41. # Normal upstream release
  42. SRC_URI="mirror://gnu/gdb/${P}.tar.xz
  43. ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
  44. ;;
  45. esac
  46. PATCH_VER=""
  47. DESCRIPTION="GNU debugger"
  48. HOMEPAGE="https://sourceware.org/gdb/"
  49. SRC_URI="${SRC_URI} ${PATCH_VER:+mirror://gentoo/${P}-patches-${PATCH_VER}.tar.xz}"
  50. LICENSE="GPL-2 LGPL-2"
  51. SLOT="0"
  52. if [[ ${PV} != 9999* ]] ; then
  53. # alpha #562128
  54. KEYWORDS="-alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
  55. fi
  56. IUSE="+client expat lzma multitarget nls +python +server test vanilla"
  57. REQUIRED_USE="
  58. python? ( ${PYTHON_REQUIRED_USE} )
  59. || ( client server )
  60. "
  61. RDEPEND="server? ( !dev-util/gdbserver )
  62. client? (
  63. >=sys-libs/ncurses-5.2-r2:0=
  64. sys-libs/readline:0=
  65. expat? ( dev-libs/expat )
  66. lzma? ( app-arch/xz-utils )
  67. python? ( ${PYTHON_DEPS} )
  68. sys-libs/zlib
  69. )"
  70. DEPEND="${RDEPEND}
  71. app-arch/xz-utils
  72. client? (
  73. virtual/yacc
  74. test? ( dev-util/dejagnu )
  75. nls? ( sys-devel/gettext )
  76. )"
  77. S=${WORKDIR}/${PN}-${MY_PV}
  78. pkg_setup() {
  79. use python && python-single-r1_pkg_setup
  80. }
  81. src_prepare() {
  82. [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
  83. ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
  84. epatch_user
  85. strip-linguas -u bfd/po opcodes/po
  86. }
  87. gdb_branding() {
  88. printf "Gentoo ${PV} "
  89. if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
  90. printf "p${PATCH_VER}"
  91. else
  92. printf "vanilla"
  93. fi
  94. [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
  95. }
  96. src_configure() {
  97. strip-unsupported-flags
  98. local myconf=(
  99. --with-pkgversion="$(gdb_branding)"
  100. --with-bugurl='https://bugs.gentoo.org/'
  101. --disable-werror
  102. # Disable modules that are in a combined binutils/gdb tree. #490566
  103. --disable-{binutils,etc,gas,gold,gprof,ld}
  104. )
  105. local sysroot="${EPREFIX}/usr/${CTARGET}"
  106. is_cross && myconf+=(
  107. --with-sysroot="${sysroot}"
  108. --includedir="${sysroot}/usr/include"
  109. --with-gdb-datadir="\${datadir}/gdb/${CTARGET}"
  110. )
  111. if use server && ! use client ; then
  112. # just configure+build in the gdbserver subdir to speed things up
  113. cd gdb/gdbserver
  114. myconf+=( --program-transform-name='' )
  115. else
  116. # gdbserver only works for native targets (CHOST==CTARGET).
  117. # it also doesn't support all targets, so rather than duplicate
  118. # the target list (which changes between versions), use the
  119. # "auto" value when things are turned on.
  120. is_cross \
  121. && myconf+=( --disable-gdbserver ) \
  122. || myconf+=( $(use_enable server gdbserver auto) )
  123. fi
  124. if ! ( use server && ! use client ) ; then
  125. # if we are configuring in the top level, then use all
  126. # the additional global options
  127. myconf+=(
  128. --enable-64-bit-bfd
  129. --disable-install-libbfd
  130. --disable-install-libiberty
  131. # Disable guile for now as it requires guile-2.x #562902
  132. --without-guile
  133. # This only disables building in the readline subdir.
  134. # For gdb itself, it'll use the system version.
  135. --disable-readline
  136. --with-system-readline
  137. # This only disables building in the zlib subdir.
  138. # For gdb itself, it'll use the system version.
  139. --without-zlib
  140. --with-system-zlib
  141. --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
  142. $(use_with expat)
  143. $(use_with lzma)
  144. $(use_enable nls)
  145. $(use multitarget && echo --enable-targets=all)
  146. $(use_with python python "${EPYTHON}")
  147. )
  148. fi
  149. econf "${myconf[@]}"
  150. }
  151. src_test() {
  152. nonfatal emake check || ewarn "tests failed"
  153. }
  154. src_install() {
  155. use server && ! use client && cd gdb/gdbserver
  156. default
  157. use client && find "${ED}"/usr -name libiberty.a -delete
  158. cd "${S}"
  159. # Delete translations that conflict with binutils-libs. #528088
  160. # Note: Should figure out how to store these in an internal gdb dir.
  161. if use nls ; then
  162. find "${ED}" \
  163. -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
  164. -delete
  165. fi
  166. # Don't install docs when building a cross-gdb
  167. if [[ ${CTARGET} != ${CHOST} ]] ; then
  168. rm -r "${ED}"/usr/share/{doc,info,locale}
  169. local f
  170. for f in "${ED}"/usr/share/man/*/* ; do
  171. if [[ ${f##*/} != ${CTARGET}-* ]] ; then
  172. mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
  173. fi
  174. done
  175. return 0
  176. fi
  177. # Install it by hand for now:
  178. # https://sourceware.org/ml/gdb-patches/2011-12/msg00915.html
  179. # Only install if it exists due to the twisted behavior (see
  180. # notes in src_configure above).
  181. [[ -e gdb/gdbserver/gdbreplay ]] && dobin gdb/gdbserver/gdbreplay
  182. if use client ; then
  183. docinto gdb
  184. dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
  185. gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
  186. fi
  187. docinto sim
  188. dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
  189. if use server ; then
  190. docinto gdbserver
  191. dodoc gdb/gdbserver/{ChangeLog,README}
  192. fi
  193. if [[ -n ${PATCH_VER} ]] ; then
  194. dodoc "${WORKDIR}"/extra/gdbinit.sample
  195. fi
  196. # Remove shared info pages
  197. rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
  198. }
  199. pkg_postinst() {
  200. # portage sucks and doesnt unmerge files in /etc
  201. rm -vf "${EROOT}"/etc/skel/.gdbinit
  202. if use prefix && [[ ${CHOST} == *-darwin* ]] ; then
  203. ewarn "gdb is unable to get a mach task port when installed by Prefix"
  204. ewarn "Portage, unprivileged. To make gdb fully functional you'll"
  205. ewarn "have to perform the following steps:"
  206. ewarn " % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb"
  207. ewarn " % sudo chmod g+s ${EPREFIX}/usr/bin/gdb"
  208. fi
  209. }