sys-devel/gdb: git-2->git-r3
[gentoo.git] / sys-devel / gdb / gdb-8.0.1-r1.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.0.1-patches-${PATCH_VER}.tar.xz}
57         ${PATCH_VER:+mirror://gentoo/${PN}-8.0.1-patches-${PATCH_VER}.tar.xz}
58 "
59
60 LICENSE="GPL-2 LGPL-2"
61 SLOT="0"
62 if [[ ${PV} != 9999* ]] ; then
63         # alpha #562128
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"
65 fi
66 IUSE="+client lzma multitarget nls +python +server test vanilla xml"
67 REQUIRED_USE="
68         python? ( ${PYTHON_REQUIRED_USE} )
69         || ( client server )
70 "
71
72 RDEPEND="server? ( !dev-util/gdbserver )
73         client? (
74                 >=sys-libs/ncurses-5.2-r2:0=
75                 sys-libs/readline:0=
76                 lzma? ( app-arch/xz-utils )
77                 python? ( ${PYTHON_DEPS} )
78                 xml? ( dev-libs/expat )
79                 sys-libs/zlib
80         )"
81 DEPEND="${RDEPEND}
82         app-arch/xz-utils
83         sys-apps/texinfo
84         client? (
85                 virtual/yacc
86                 test? ( dev-util/dejagnu )
87                 nls? ( sys-devel/gettext )
88         )"
89
90 S=${WORKDIR}/${PN}-${MY_PV}
91
92 pkg_setup() {
93         use python && python-single-r1_pkg_setup
94 }
95
96 src_prepare() {
97         [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
98         ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
99
100         default
101
102         strip-linguas -u bfd/po opcodes/po
103 }
104
105 gdb_branding() {
106         printf "Gentoo ${PV} "
107         if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
108                 printf "p${PATCH_VER}"
109         else
110                 printf "vanilla"
111         fi
112         [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}"
113 }
114
115 src_configure() {
116         strip-unsupported-flags
117
118         local myconf=(
119                 --with-pkgversion="$(gdb_branding)"
120                 --with-bugurl='https://bugs.gentoo.org/'
121                 --disable-werror
122                 # Disable modules that are in a combined binutils/gdb tree. #490566
123                 --disable-{binutils,etc,gas,gold,gprof,ld}
124         )
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}"
130         )
131
132         if use server && ! use client ; then
133                 # just configure+build in the gdbserver subdir to speed things up
134                 cd gdb/gdbserver
135                 myconf+=( --program-transform-name='' )
136         else
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.
141                 is_cross \
142                         && myconf+=( --disable-gdbserver ) \
143                         || myconf+=( $(use_enable server gdbserver auto) )
144         fi
145
146         if ! ( use server && ! use client ) ; then
147                 # if we are configuring in the top level, then use all
148                 # the additional global options
149                 myconf+=(
150                         --enable-64-bit-bfd
151                         --disable-install-libbfd
152                         --disable-install-libiberty
153                         # Disable guile for now as it requires guile-2.x #562902
154                         --without-guile
155                         # This only disables building in the readline subdir.
156                         # For gdb itself, it'll use the system version.
157                         --disable-readline
158                         --with-system-readline
159                         # This only disables building in the zlib subdir.
160                         # For gdb itself, it'll use the system version.
161                         --without-zlib
162                         --with-system-zlib
163                         --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
164                         $(use_with xml expat)
165                         $(use_with lzma)
166                         $(use_enable nls)
167                         $(use multitarget && echo --enable-targets=all)
168                         $(use_with python python "${EPYTHON}")
169                 )
170         fi
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 )
175         fi
176
177         econf "${myconf[@]}"
178 }
179
180 src_test() {
181         nonfatal emake check || ewarn "tests failed"
182 }
183
184 src_install() {
185         if use server && ! use client; then
186                 cd gdb/gdbserver || die
187         fi
188         default
189         if use client; then
190                 find "${ED}"/usr -name libiberty.a -delete || die
191         fi
192         cd "${S}" || die
193
194         # Delete translations that conflict with binutils-libs. #528088
195         # Note: Should figure out how to store these in an internal gdb dir.
196         if use nls ; then
197                 find "${ED}" \
198                         -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \
199                         -delete || die
200         fi
201
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
205                 local f
206                 for f in "${ED}"/usr/share/man/*/* ; do
207                         if [[ ${f##*/} != ${CTARGET}-* ]] ; then
208                                 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
209                         fi
210                 done
211                 return 0
212         fi
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
218
219         if use client ; then
220                 docinto gdb
221                 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
222                         gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
223         fi
224         docinto sim
225         dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
226         if use server ; then
227                 docinto gdbserver
228                 dodoc gdb/gdbserver/{ChangeLog,README}
229         fi
230
231         if [[ -n ${PATCH_VER} ]] ; then
232                 dodoc "${WORKDIR}"/extra/gdbinit.sample
233         fi
234
235         # Remove shared info pages
236         rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
237 }
238
239 pkg_postinst() {
240         # portage sucks and doesnt unmerge files in /etc
241         rm -vf "${EROOT}"/etc/skel/.gdbinit
242
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"
249         fi
250 }