1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
7 inherit epatch eutils flag-o-matic python-single-r1
9 export CTARGET=${CTARGET:-${CHOST}}
10 if [[ ${CTARGET} == ${CHOST} ]] ; then
11 if [[ ${CATEGORY} == cross-* ]] ; then
12 export CTARGET=${CATEGORY#cross-}
15 is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
22 EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
28 SRC_URI="ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${PV}.tar.xz"
31 # fedora versions; note we swap the rpm & fedora core versions.
32 # gdb-6.8.50.20090302-8.fc11.src.rpm -> gdb-6.8.50.20090302.11.8.ebuild
33 # gdb-7.9-11.fc23.src.rpm -> gdb-7.9.23.11.ebuild
34 inherit versionator rpm
35 gvcr() { get_version_component_range "$@"; }
37 set -- $(get_version_components)
38 MY_PV=$(gvcr 1-$(( $# - 2 )))
39 RPM="${PN}-${MY_PV}-$(gvcr $#).fc$(gvcr $(( $# - 1 ))).src.rpm"
42 SRC_URI="mirror://fedora-dev/development/rawhide/source/SRPMS/g/${RPM}"
45 # Normal upstream release
46 SRC_URI="mirror://gnu/gdb/${P}.tar.xz
47 ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
53 DESCRIPTION="GNU debugger"
54 HOMEPAGE="https://sourceware.org/gdb/"
56 ${PATCH_DEV:+https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${PN}-8.0.1-patches-${PATCH_VER}.tar.xz}
57 ${PATCH_VER:+mirror://gentoo/${PN}-8.0.1-patches-${PATCH_VER}.tar.xz}
60 LICENSE="GPL-2 LGPL-2"
62 if [[ ${PV} != 9999* ]] ; then
64 KEYWORDS="-alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
66 IUSE="+client lzma multitarget nls +python +server test vanilla xml"
68 python? ( ${PYTHON_REQUIRED_USE} )
72 RDEPEND="server? ( !dev-util/gdbserver )
74 >=sys-libs/ncurses-5.2-r2:0=
76 lzma? ( app-arch/xz-utils )
77 python? ( ${PYTHON_DEPS} )
78 xml? ( dev-libs/expat )
86 test? ( dev-util/dejagnu )
87 nls? ( sys-devel/gettext )
90 S=${WORKDIR}/${PN}-${MY_PV}
93 use python && python-single-r1_pkg_setup
97 [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
98 ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
102 strip-linguas -u bfd/po opcodes/po
106 printf "Gentoo ${PV} "
107 if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
108 printf "p${PATCH_VER}"
112 [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
116 strip-unsupported-flags
119 --with-pkgversion="$(gdb_branding)"
120 --with-bugurl='https://bugs.gentoo.org/'
122 # Disable modules that are in a combined binutils/gdb tree. #490566
123 --disable-{binutils,etc,gas,gold,gprof,ld}
125 local sysroot="${EPREFIX}/usr/${CTARGET}"
126 is_cross && myconf+=(
127 --with-sysroot="${sysroot}"
128 --includedir="${sysroot}/usr/include"
129 --with-gdb-datadir="\${datadir}/gdb/${CTARGET}"
132 if use server && ! use client ; then
133 # just configure+build in the gdbserver subdir to speed things up
135 myconf+=( --program-transform-name='' )
137 # gdbserver only works for native targets (CHOST==CTARGET).
138 # it also doesn't support all targets, so rather than duplicate
139 # the target list (which changes between versions), use the
140 # "auto" value when things are turned on.
142 && myconf+=( --disable-gdbserver ) \
143 || myconf+=( $(use_enable server gdbserver auto) )
146 if ! ( use server && ! use client ) ; then
147 # if we are configuring in the top level, then use all
148 # the additional global options
151 --disable-install-libbfd
152 --disable-install-libiberty
153 # Disable guile for now as it requires guile-2.x #562902
155 # This only disables building in the readline subdir.
156 # For gdb itself, it'll use the system version.
158 --with-system-readline
159 # This only disables building in the zlib subdir.
160 # For gdb itself, it'll use the system version.
163 --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
164 $(use_with xml expat)
167 $(use multitarget && echo --enable-targets=all)
168 $(use_with python python "${EPYTHON}")
171 if use sparc-solaris || use x86-solaris ; then
172 # disable largefile support
173 # https://sourceware.org/ml/gdb-patches/2014-12/msg00058.html
174 myconf+=( --disable-largefile )
181 nonfatal emake check || ewarn "tests failed"
185 if use server && ! use client; then
186 cd gdb/gdbserver || die
190 find "${ED}"/usr -name libiberty.a -delete || die
194 # Delete translations that conflict with binutils-libs. #528088
195 # Note: Should figure out how to store these in an internal gdb dir.
198 -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
202 # Don't install docs when building a cross-gdb
203 if [[ ${CTARGET} != ${CHOST} ]] ; then
204 rm -rf "${ED}"/usr/share/{doc,info,locale} || die
206 for f in "${ED}"/usr/share/man/*/* ; do
207 if [[ ${f##*/} != ${CTARGET}-* ]] ; then
208 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
213 # Install it by hand for now:
214 # https://sourceware.org/ml/gdb-patches/2011-12/msg00915.html
215 # Only install if it exists due to the twisted behavior (see
216 # notes in src_configure above).
217 [[ -e gdb/gdbserver/gdbreplay ]] && dobin gdb/gdbserver/gdbreplay
221 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
222 gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
225 dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
228 dodoc gdb/gdbserver/{ChangeLog,README}
231 if [[ -n ${PATCH_VER} ]] ; then
232 dodoc "${WORKDIR}"/extra/gdbinit.sample
235 # Remove shared info pages
236 rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
240 # portage sucks and doesnt unmerge files in /etc
241 rm -vf "${EROOT}"/etc/skel/.gdbinit
243 if use prefix && [[ ${CHOST} == *-darwin* ]] ; then
244 ewarn "gdb is unable to get a mach task port when installed by Prefix"
245 ewarn "Portage, unprivileged. To make gdb fully functional you'll"
246 ewarn "have to perform the following steps:"
247 ewarn " % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb"
248 ewarn " % sudo chmod g+s ${EPREFIX}/usr/bin/gdb"