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.1-patches-${PATCH_VER}.tar.xz}
57 ${PATCH_VER:+mirror://gentoo/${PN}-8.1-patches-${PATCH_VER}.tar.xz}
60 LICENSE="GPL-2 LGPL-2"
62 if [[ ${PV} != 9999* ]] ; then
63 KEYWORDS="~alpha ~amd64 ~arm ~arm64 hppa ia64 m68k ~mips ~ppc ~ppc64 s390 sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
65 IUSE="+client lzma multitarget nls +python +server test vanilla xml"
67 python? ( ${PYTHON_REQUIRED_USE} )
72 server? ( !dev-util/gdbserver )
75 >=sys-libs/ncurses-5.2-r2:0=
77 lzma? ( app-arch/xz-utils )
78 python? ( ${PYTHON_DEPS} )
79 xml? ( dev-libs/expat )
87 test? ( dev-util/dejagnu )
88 nls? ( sys-devel/gettext )
91 S=${WORKDIR}/${PN}-${MY_PV}
94 use python && python-single-r1_pkg_setup
98 [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
99 ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
103 strip-linguas -u bfd/po opcodes/po
107 printf "Gentoo ${PV} "
108 if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
109 printf "p${PATCH_VER}"
113 [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
117 strip-unsupported-flags
120 --with-pkgversion="$(gdb_branding)"
121 --with-bugurl='https://bugs.gentoo.org/'
123 # Disable modules that are in a combined binutils/gdb tree. #490566
124 --disable-{binutils,etc,gas,gold,gprof,ld}
126 local sysroot="${EPREFIX}/usr/${CTARGET}"
127 is_cross && myconf+=(
128 --with-sysroot="${sysroot}"
129 --includedir="${sysroot}/usr/include"
130 --with-gdb-datadir="\${datadir}/gdb/${CTARGET}"
133 if use server && ! use client ; then
134 # just configure+build in the gdbserver subdir to speed things up
136 myconf+=( --program-transform-name='' )
138 # gdbserver only works for native targets (CHOST==CTARGET).
139 # it also doesn't support all targets, so rather than duplicate
140 # the target list (which changes between versions), use the
141 # "auto" value when things are turned on.
143 && myconf+=( --disable-gdbserver ) \
144 || myconf+=( $(use_enable server gdbserver auto) )
147 if ! ( use server && ! use client ) ; then
148 # if we are configuring in the top level, then use all
149 # the additional global options
152 --disable-install-libbfd
153 --disable-install-libiberty
154 # Disable guile for now as it requires guile-2.x #562902
156 # This only disables building in the readline subdir.
157 # For gdb itself, it'll use the system version.
159 --with-system-readline
160 # This only disables building in the zlib subdir.
161 # For gdb itself, it'll use the system version.
164 --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
165 $(use_with xml expat)
168 $(use multitarget && echo --enable-targets=all)
169 $(use_with python python "${EPYTHON}")
172 if use sparc-solaris || use x86-solaris ; then
173 # disable largefile support
174 # https://sourceware.org/ml/gdb-patches/2014-12/msg00058.html
175 myconf+=( --disable-largefile )
182 nonfatal emake check || ewarn "tests failed"
186 if use server && ! use client; then
187 cd gdb/gdbserver || die
191 find "${ED}"/usr -name libiberty.a -delete || die
195 # Delete translations that conflict with binutils-libs. #528088
196 # Note: Should figure out how to store these in an internal gdb dir.
199 -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
203 # Don't install docs when building a cross-gdb
204 if [[ ${CTARGET} != ${CHOST} ]] ; then
205 rm -rf "${ED}"/usr/share/{doc,info,locale} || die
207 for f in "${ED}"/usr/share/man/*/* ; do
208 if [[ ${f##*/} != ${CTARGET}-* ]] ; then
209 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
214 # Install it by hand for now:
215 # https://sourceware.org/ml/gdb-patches/2011-12/msg00915.html
216 # Only install if it exists due to the twisted behavior (see
217 # notes in src_configure above).
218 [[ -e gdb/gdbserver/gdbreplay ]] && dobin gdb/gdbserver/gdbreplay
222 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
223 gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
226 dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
229 dodoc gdb/gdbserver/{ChangeLog,README}
232 if [[ -n ${PATCH_VER} ]] ; then
233 dodoc "${WORKDIR}"/extra/gdbinit.sample
236 # Remove shared info pages
237 rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
239 # gcore is part of ubin on freebsd
240 if [[ ${CHOST} == *-freebsd* ]]; then
241 rm "${ED}"/usr/bin/gcore || die
246 # portage sucks and doesnt unmerge files in /etc
247 rm -vf "${EROOT}"/etc/skel/.gdbinit
249 if use prefix && [[ ${CHOST} == *-darwin* ]] ; then
250 ewarn "gdb is unable to get a mach task port when installed by Prefix"
251 ewarn "Portage, unprivileged. To make gdb fully functional you'll"
252 ewarn "have to perform the following steps:"
253 ewarn " % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb"
254 ewarn " % sudo chmod g+s ${EPREFIX}/usr/bin/gdb"