sys-devel: Remove *-fbsd KEYWORDS
[gentoo.git] / sys-devel / gdb / gdb-9999.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python{2_7,3_5,3_6,3_7} )
6
7 inherit 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         # Normal upstream release
32         SRC_URI="mirror://gnu/gdb/${P}.tar.xz
33                 ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
34         ;;
35 esac
36
37 PATCH_VER=""
38 PATCH_DEV=""
39 DESCRIPTION="GNU debugger"
40 HOMEPAGE="https://sourceware.org/gdb/"
41 SRC_URI="${SRC_URI}
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}
44 "
45
46 LICENSE="GPL-2 LGPL-2"
47 SLOT="0"
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"
50 fi
51 IUSE="+client lzma multitarget nls +python +server source-highlight test vanilla xml"
52 REQUIRED_USE="
53         python? ( ${PYTHON_REQUIRED_USE} )
54         || ( client server )
55 "
56
57 # ia64 kernel crashes when gdb testsuite is running
58 # hppa kernel crashes when gdb testsuite is running
59 RESTRICT="
60         hppa? ( test )
61         ia64? ( test )
62 "
63
64 RDEPEND="
65         server? ( !dev-util/gdbserver )
66         client? (
67                 dev-libs/mpfr:0=
68                 >=sys-libs/ncurses-5.2-r2:0=
69                 sys-libs/readline:0=
70                 lzma? ( app-arch/xz-utils )
71                 python? ( ${PYTHON_DEPS} )
72                 xml? ( dev-libs/expat )
73                 sys-libs/zlib
74         )
75         source-highlight? (
76                 dev-util/source-highlight
77         )
78 "
79 DEPEND="${RDEPEND}"
80 BDEPEND="
81         app-arch/xz-utils
82         sys-apps/texinfo
83         client? (
84                 virtual/yacc
85                 test? ( dev-util/dejagnu )
86                 nls? ( sys-devel/gettext )
87         )"
88
89 S=${WORKDIR}/${PN}-${MY_PV}
90
91 PATCHES=(
92         "${FILESDIR}"/${PN}-8.3.1-verbose-build.patch
93 )
94
95 pkg_setup() {
96         use python && python-single-r1_pkg_setup
97 }
98
99 src_prepare() {
100         [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
101
102         default
103
104         strip-linguas -u bfd/po opcodes/po
105 }
106
107 gdb_branding() {
108         printf "Gentoo ${PV} "
109         if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
110                 printf "p${PATCH_VER}"
111         else
112                 printf "vanilla"
113         fi
114         [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
115 }
116
117 src_configure() {
118         strip-unsupported-flags
119
120         local myconf=(
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
125
126                 --with-pkgversion="$(gdb_branding)"
127                 --with-bugurl='https://bugs.gentoo.org/'
128                 --disable-werror
129                 # Disable modules that are in a combined binutils/gdb tree. #490566
130                 --disable-{binutils,etc,gas,gold,gprof,ld}
131         )
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}"
137         )
138
139         if use server && ! use client ; then
140                 # just configure+build in the gdbserver subdir to speed things up
141                 cd gdb/gdbserver
142                 myconf+=( --program-transform-name='' )
143         else
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.
148                 is_cross \
149                         && myconf+=( --disable-gdbserver ) \
150                         || myconf+=( $(use_enable server gdbserver auto) )
151         fi
152
153         if ! ( use server && ! use client ) ; then
154                 # if we are configuring in the top level, then use all
155                 # the additional global options
156                 myconf+=(
157                         --enable-64-bit-bfd
158                         --disable-install-libbfd
159                         --disable-install-libiberty
160                         # Disable guile for now as it requires guile-2.x #562902
161                         --without-guile
162                         # This only disables building in the readline subdir.
163                         # For gdb itself, it'll use the system version.
164                         --disable-readline
165                         --with-system-readline
166                         # This only disables building in the zlib subdir.
167                         # For gdb itself, it'll use the system version.
168                         --without-zlib
169                         --with-system-zlib
170                         --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
171                         $(use_with xml expat)
172                         $(use_with lzma)
173                         $(use_enable nls)
174                         $(use_enable source-highlight)
175                         $(use multitarget && echo --enable-targets=all)
176                         $(use_with python python "${EPYTHON}")
177                 )
178         fi
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 )
183         fi
184
185         econf "${myconf[@]}"
186 }
187
188 src_install() {
189         if use server && ! use client; then
190                 cd gdb/gdbserver || die
191         fi
192         default
193         if use client; then
194                 find "${ED}"/usr -name libiberty.a -delete || die
195         fi
196         cd "${S}" || die
197
198         # Delete translations that conflict with binutils-libs. #528088
199         # Note: Should figure out how to store these in an internal gdb dir.
200         if use nls ; then
201                 find "${ED}" \
202                         -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
203                         -delete || die
204         fi
205
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
209                 local f
210                 for f in "${ED}"/usr/share/man/*/* ; do
211                         if [[ ${f##*/} != ${CTARGET}-* ]] ; then
212                                 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
213                         fi
214                 done
215                 return 0
216         fi
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
222
223         if use client ; then
224                 docinto gdb
225                 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
226                         gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
227         fi
228         docinto sim
229         dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
230         if use server ; then
231                 docinto gdbserver
232                 dodoc gdb/gdbserver/{ChangeLog,README}
233         fi
234
235         if [[ -n ${PATCH_VER} ]] ; then
236                 dodoc "${WORKDIR}"/extra/gdbinit.sample
237         fi
238
239         # Remove shared info pages
240         rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
241
242         # gcore is part of ubin on freebsd
243         if [[ ${CHOST} == *-freebsd* ]]; then
244                 rm "${ED}"/usr/bin/gcore || die
245         fi
246 }
247
248 pkg_postinst() {
249         # portage sucks and doesnt unmerge files in /etc
250         rm -vf "${EROOT}"/etc/skel/.gdbinit
251
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"
258         fi
259 }