sys-devel/gdb: bump up to 8.2.1
[gentoo.git] / sys-devel / gdb / gdb-8.1-r2.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
6
7 inherit epatch eutils flag-o-matic python-single-r1
8
9 export CTARGET=${CTARGET:-${CHOST}}
10 if [[ ${CTARGET} == ${CHOST} ]] ; then
11         if [[ ${CATEGORY} == cross-* ]] ; then
12                 export CTARGET=${CATEGORY#cross-}
13         fi
14 fi
15 is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
16
17 RPM=
18 MY_PV=${PV}
19 case ${PV} in
20 9999*)
21         # live git tree
22         EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
23         inherit git-r3
24         SRC_URI=""
25         ;;
26 *.*.50.2???????)
27         # weekly snapshots
28         SRC_URI="ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${PV}.tar.xz"
29         ;;
30 *.*.*.*.*.*)
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 "$@"; }
36         parse_fedora_ver() {
37                 set -- $(get_version_components)
38                 MY_PV=$(gvcr 1-$(( $# - 2 )))
39                 RPM="${PN}-${MY_PV}-$(gvcr $#).fc$(gvcr $(( $# - 1 ))).src.rpm"
40         }
41         parse_fedora_ver
42         SRC_URI="mirror://fedora-dev/development/rawhide/source/SRPMS/g/${RPM}"
43         ;;
44 *)
45         # Normal upstream release
46         SRC_URI="mirror://gnu/gdb/${P}.tar.xz
47                 ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
48         ;;
49 esac
50
51 PATCH_VER="1"
52 PATCH_DEV="slyfox"
53 DESCRIPTION="GNU debugger"
54 HOMEPAGE="https://sourceware.org/gdb/"
55 SRC_URI="${SRC_URI}
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}
58 "
59
60 LICENSE="GPL-2 LGPL-2"
61 SLOT="0"
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"
64 fi
65 IUSE="+client lzma multitarget nls +python +server test vanilla xml"
66 REQUIRED_USE="
67         python? ( ${PYTHON_REQUIRED_USE} )
68         || ( client server )
69 "
70
71 RDEPEND="
72         server? ( !dev-util/gdbserver )
73         client? (
74                 dev-libs/mpfr:0=
75                 >=sys-libs/ncurses-5.2-r2:0=
76                 sys-libs/readline:0=
77                 lzma? ( app-arch/xz-utils )
78                 python? ( ${PYTHON_DEPS} )
79                 xml? ( dev-libs/expat )
80                 sys-libs/zlib
81         )"
82 DEPEND="${RDEPEND}
83         app-arch/xz-utils
84         sys-apps/texinfo
85         client? (
86                 virtual/yacc
87                 test? ( dev-util/dejagnu )
88                 nls? ( sys-devel/gettext )
89         )"
90
91 S=${WORKDIR}/${PN}-${MY_PV}
92
93 pkg_setup() {
94         use python && python-single-r1_pkg_setup
95 }
96
97 src_prepare() {
98         [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
99         ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
100
101         default
102
103         strip-linguas -u bfd/po opcodes/po
104 }
105
106 gdb_branding() {
107         printf "Gentoo ${PV} "
108         if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
109                 printf "p${PATCH_VER}"
110         else
111                 printf "vanilla"
112         fi
113         [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
114 }
115
116 src_configure() {
117         strip-unsupported-flags
118
119         local myconf=(
120                 --with-pkgversion="$(gdb_branding)"
121                 --with-bugurl='https://bugs.gentoo.org/'
122                 --disable-werror
123                 # Disable modules that are in a combined binutils/gdb tree. #490566
124                 --disable-{binutils,etc,gas,gold,gprof,ld}
125         )
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}"
131         )
132
133         if use server && ! use client ; then
134                 # just configure+build in the gdbserver subdir to speed things up
135                 cd gdb/gdbserver
136                 myconf+=( --program-transform-name='' )
137         else
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.
142                 is_cross \
143                         && myconf+=( --disable-gdbserver ) \
144                         || myconf+=( $(use_enable server gdbserver auto) )
145         fi
146
147         if ! ( use server && ! use client ) ; then
148                 # if we are configuring in the top level, then use all
149                 # the additional global options
150                 myconf+=(
151                         --enable-64-bit-bfd
152                         --disable-install-libbfd
153                         --disable-install-libiberty
154                         # Disable guile for now as it requires guile-2.x #562902
155                         --without-guile
156                         # This only disables building in the readline subdir.
157                         # For gdb itself, it'll use the system version.
158                         --disable-readline
159                         --with-system-readline
160                         # This only disables building in the zlib subdir.
161                         # For gdb itself, it'll use the system version.
162                         --without-zlib
163                         --with-system-zlib
164                         --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
165                         $(use_with xml expat)
166                         $(use_with lzma)
167                         $(use_enable nls)
168                         $(use multitarget && echo --enable-targets=all)
169                         $(use_with python python "${EPYTHON}")
170                 )
171         fi
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 )
176         fi
177
178         econf "${myconf[@]}"
179 }
180
181 src_test() {
182         nonfatal emake check || ewarn "tests failed"
183 }
184
185 src_install() {
186         if use server && ! use client; then
187                 cd gdb/gdbserver || die
188         fi
189         default
190         if use client; then
191                 find "${ED}"/usr -name libiberty.a -delete || die
192         fi
193         cd "${S}" || die
194
195         # Delete translations that conflict with binutils-libs. #528088
196         # Note: Should figure out how to store these in an internal gdb dir.
197         if use nls ; then
198                 find "${ED}" \
199                         -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
200                         -delete || die
201         fi
202
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
206                 local f
207                 for f in "${ED}"/usr/share/man/*/* ; do
208                         if [[ ${f##*/} != ${CTARGET}-* ]] ; then
209                                 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
210                         fi
211                 done
212                 return 0
213         fi
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
219
220         if use client ; then
221                 docinto gdb
222                 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
223                         gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
224         fi
225         docinto sim
226         dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
227         if use server ; then
228                 docinto gdbserver
229                 dodoc gdb/gdbserver/{ChangeLog,README}
230         fi
231
232         if [[ -n ${PATCH_VER} ]] ; then
233                 dodoc "${WORKDIR}"/extra/gdbinit.sample
234         fi
235
236         # Remove shared info pages
237         rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
238
239         # gcore is part of ubin on freebsd
240         if [[ ${CHOST} == *-freebsd* ]]; then
241                 rm "${ED}"/usr/bin/gcore || die
242         fi
243 }
244
245 pkg_postinst() {
246         # portage sucks and doesnt unmerge files in /etc
247         rm -vf "${EROOT}"/etc/skel/.gdbinit
248
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"
255         fi
256 }