1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python{2_7,3_5,3_6,3_7} )
7 inherit 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 # Normal upstream release
32 SRC_URI="mirror://gnu/gdb/${P}.tar.xz
33 ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
39 DESCRIPTION="GNU debugger"
40 HOMEPAGE="https://sourceware.org/gdb/"
42 ${PATCH_DEV:+https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz}
43 ${PATCH_VER:+mirror://gentoo/${P}-patches-${PATCH_VER}.tar.xz}
46 LICENSE="GPL-2 LGPL-2"
48 if [[ ${PV} != 9999* ]] ; then
49 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
51 IUSE="+client lzma multitarget nls +python +server source-highlight test vanilla xml"
53 python? ( ${PYTHON_REQUIRED_USE} )
57 # ia64 kernel crashes when gdb testsuite is running
58 # hppa kernel crashes when gdb testsuite is running
65 server? ( !dev-util/gdbserver )
68 >=sys-libs/ncurses-5.2-r2:0=
70 lzma? ( app-arch/xz-utils )
71 python? ( ${PYTHON_DEPS} )
72 xml? ( dev-libs/expat )
76 dev-util/source-highlight
85 test? ( dev-util/dejagnu )
86 nls? ( sys-devel/gettext )
89 S=${WORKDIR}/${PN}-${MY_PV}
92 "${FILESDIR}"/${PN}-8.3.1-verbose-build.patch
96 use python && python-single-r1_pkg_setup
100 [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
104 strip-linguas -u bfd/po opcodes/po
108 printf "Gentoo ${PV} "
109 if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
110 printf "p${PATCH_VER}"
114 [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
118 strip-unsupported-flags
121 # portage's econf() does not detect presence of --d-d-t
122 # because it greps only top-level ./configure. But not
123 # gnulib's or gdb's configure.
124 --disable-dependency-tracking
126 --with-pkgversion="$(gdb_branding)"
127 --with-bugurl='https://bugs.gentoo.org/'
129 # Disable modules that are in a combined binutils/gdb tree. #490566
130 --disable-{binutils,etc,gas,gold,gprof,ld}
132 local sysroot="${EPREFIX}/usr/${CTARGET}"
133 is_cross && myconf+=(
134 --with-sysroot="${sysroot}"
135 --includedir="${sysroot}/usr/include"
136 --with-gdb-datadir="\${datadir}/gdb/${CTARGET}"
139 if use server && ! use client ; then
140 # just configure+build in the gdbserver subdir to speed things up
142 myconf+=( --program-transform-name='' )
144 # gdbserver only works for native targets (CHOST==CTARGET).
145 # it also doesn't support all targets, so rather than duplicate
146 # the target list (which changes between versions), use the
147 # "auto" value when things are turned on.
149 && myconf+=( --disable-gdbserver ) \
150 || myconf+=( $(use_enable server gdbserver auto) )
153 if ! ( use server && ! use client ) ; then
154 # if we are configuring in the top level, then use all
155 # the additional global options
158 --disable-install-libbfd
159 --disable-install-libiberty
160 # Disable guile for now as it requires guile-2.x #562902
162 # This only disables building in the readline subdir.
163 # For gdb itself, it'll use the system version.
165 --with-system-readline
166 # This only disables building in the zlib subdir.
167 # For gdb itself, it'll use the system version.
170 --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
171 $(use_with xml expat)
174 $(use_enable source-highlight)
175 $(use multitarget && echo --enable-targets=all)
176 $(use_with python python "${EPYTHON}")
179 if use sparc-solaris || use x86-solaris ; then
180 # disable largefile support
181 # https://sourceware.org/ml/gdb-patches/2014-12/msg00058.html
182 myconf+=( --disable-largefile )
189 if use server && ! use client; then
190 cd gdb/gdbserver || die
194 find "${ED}"/usr -name libiberty.a -delete || die
198 # Delete translations that conflict with binutils-libs. #528088
199 # Note: Should figure out how to store these in an internal gdb dir.
202 -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
206 # Don't install docs when building a cross-gdb
207 if [[ ${CTARGET} != ${CHOST} ]] ; then
208 rm -rf "${ED}"/usr/share/{doc,info,locale} || die
210 for f in "${ED}"/usr/share/man/*/* ; do
211 if [[ ${f##*/} != ${CTARGET}-* ]] ; then
212 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
217 # Install it by hand for now:
218 # https://sourceware.org/ml/gdb-patches/2011-12/msg00915.html
219 # Only install if it exists due to the twisted behavior (see
220 # notes in src_configure above).
221 [[ -e gdb/gdbserver/gdbreplay ]] && dobin gdb/gdbserver/gdbreplay
225 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
226 gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
229 dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
232 dodoc gdb/gdbserver/{ChangeLog,README}
235 if [[ -n ${PATCH_VER} ]] ; then
236 dodoc "${WORKDIR}"/extra/gdbinit.sample
239 # Remove shared info pages
240 rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
242 # gcore is part of ubin on freebsd
243 if [[ ${CHOST} == *-freebsd* ]]; then
244 rm "${ED}"/usr/bin/gcore || die
249 # portage sucks and doesnt unmerge files in /etc
250 rm -vf "${EROOT}"/etc/skel/.gdbinit
252 if use prefix && [[ ${CHOST} == *-darwin* ]] ; then
253 ewarn "gdb is unable to get a mach task port when installed by Prefix"
254 ewarn "Portage, unprivileged. To make gdb fully functional you'll"
255 ewarn "have to perform the following steps:"
256 ewarn " % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb"
257 ewarn " % sudo chmod g+s ${EPREFIX}/usr/bin/gdb"