proj/gentoo: Initial commit
[gentoo.git] / sys-devel / gdb / gdb-7.8.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
7
8 inherit flag-o-matic eutils python-single-r1
9
10 export CTARGET=${CTARGET:-${CHOST}}
11 if [[ ${CTARGET} == ${CHOST} ]] ; then
12         if [[ ${CATEGORY} == cross-* ]] ; then
13                 export CTARGET=${CATEGORY#cross-}
14         fi
15 fi
16 is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
17
18 RPM=
19 MY_PV=${PV}
20 case ${PV} in
21 *.*.50.*)
22         # weekly snapshots
23         SRC_URI="ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${PV}.tar.bz2"
24         ;;
25 9999*)
26         # live git tree
27         EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
28         inherit git-2
29         SRC_URI=""
30         ;;
31 *)
32         # Normal upstream release
33         SRC_URI="mirror://gnu/gdb/${P}.tar.xz
34                 ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz"
35         ;;
36 esac
37
38 PATCH_VER=""
39 DESCRIPTION="GNU debugger"
40 HOMEPAGE="http://sourceware.org/gdb/"
41 SRC_URI="${SRC_URI} ${PATCH_VER:+mirror://gentoo/${P}-patches-${PATCH_VER}.tar.xz}"
42
43 LICENSE="GPL-2 LGPL-2"
44 SLOT="0"
45 if [[ ${PV} != 9999* ]] ; then
46         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~x64-freebsd ~amd64-linux ~arm-linux ~x86-linux ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
47 fi
48 IUSE="+client expat lzma multitarget nls +python +server test vanilla zlib"
49 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
50
51 RDEPEND="!dev-util/gdbserver
52         >=sys-libs/ncurses-5.2-r2
53         sys-libs/readline
54         expat? ( dev-libs/expat )
55         lzma? ( app-arch/xz-utils )
56         python? ( ${PYTHON_DEPS} )
57         zlib? ( sys-libs/zlib )"
58 DEPEND="${RDEPEND}
59         app-arch/xz-utils
60         virtual/yacc
61         test? ( dev-util/dejagnu )
62         nls? ( sys-devel/gettext )"
63
64 S=${WORKDIR}/${PN}-${MY_PV}
65
66 pkg_setup() {
67         use python && python-single-r1_pkg_setup
68 }
69
70 src_prepare() {
71         [[ -n ${RPM} ]] && rpm_spec_epatch "${WORKDIR}"/gdb.spec
72         ! use vanilla && [[ -n ${PATCH_VER} ]] && EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
73         epatch_user
74         strip-linguas -u bfd/po opcodes/po
75 }
76
77 gdb_branding() {
78         printf "Gentoo ${PV} "
79         if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then
80                 printf "p${PATCH_VER}"
81         else
82                 printf "vanilla"
83         fi
84 }
85
86 src_configure() {
87         strip-unsupported-flags
88
89         local myconf=(
90                 --with-pkgversion="$(gdb_branding)"
91                 --with-bugurl='http://bugs.gentoo.org/'
92                 --disable-werror
93                 # Disable modules that are in a combined binutils/gdb tree. #490566
94                 --disable-{binutils,etc,gas,gold,gprof,ld}
95         )
96         local sysroot="${EPREFIX}/usr/${CTARGET}"
97         is_cross && myconf+=(
98                 --with-sysroot="${sysroot}"
99                 --includedir="${sysroot}/usr/include"
100                 --with-gdb-datadir="\${datadir}/gdb/${CTARGET}"
101         )
102
103         if use server && ! use client ; then
104                 # just configure+build in the gdbserver subdir to speed things up
105                 cd gdb/gdbserver
106                 myconf+=( --program-transform-name='' )
107         else
108                 # gdbserver only works for native targets (CHOST==CTARGET).
109                 # it also doesn't support all targets, so rather than duplicate
110                 # the target list (which changes between versions), use the
111                 # "auto" value when things are turned on.
112                 is_cross \
113                         && myconf+=( --disable-gdbserver ) \
114                         || myconf+=( $(use_enable server gdbserver auto) )
115         fi
116
117         if ! ( use server && ! use client ) ; then
118                 # if we are configuring in the top level, then use all
119                 # the additional global options
120                 myconf+=(
121                         --enable-64-bit-bfd
122                         --disable-install-libbfd
123                         --disable-install-libiberty
124                         # This only disables building in the readline subdir.
125                         # For gdb itself, it'll use the system version.
126                         --disable-readline
127                         --with-system-readline
128                         --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug
129                         $(use_with expat)
130                         $(use_with lzma)
131                         $(use_enable nls)
132                         $(use multitarget && echo --enable-targets=all)
133                         $(use_with python python "${EPYTHON}")
134                         $(use_with zlib)
135                 )
136         fi
137
138         econf "${myconf[@]}"
139 }
140
141 src_test() {
142         nonfatal emake check || ewarn "tests failed"
143 }
144
145 src_install() {
146         use server && ! use client && cd gdb/gdbserver
147         default
148         use client && find "${ED}"/usr -name libiberty.a -delete
149         cd "${S}"
150
151         # Don't install docs when building a cross-gdb
152         if [[ ${CTARGET} != ${CHOST} ]] ; then
153                 rm -r "${ED}"/usr/share/{doc,info,locale}
154                 local f
155                 for f in "${ED}"/usr/share/man/*/* ; do
156                         if [[ ${f##*/} != ${CTARGET}-* ]] ; then
157                                 mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die
158                         fi
159                 done
160                 return 0
161         fi
162         # Install it by hand for now:
163         # http://sourceware.org/ml/gdb-patches/2011-12/msg00915.html
164         # Only install if it exists due to the twisted behavior (see
165         # notes in src_configure above).
166         [[ -e gdb/gdbserver/gdbreplay ]] && dobin gdb/gdbserver/gdbreplay
167
168         if use client ; then
169                 docinto gdb
170                 dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \
171                         gdb/NEWS gdb/ChangeLog gdb/PROBLEMS
172         fi
173         docinto sim
174         dodoc sim/{ChangeLog,MAINTAINERS,README-HACKING}
175         if use server ; then
176                 docinto gdbserver
177                 dodoc gdb/gdbserver/{ChangeLog,README}
178         fi
179
180         if [[ -n ${PATCH_VER} ]] ; then
181                 dodoc "${WORKDIR}"/extra/gdbinit.sample
182         fi
183
184         # Remove shared info pages
185         rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,standards}.info*
186 }
187
188 pkg_postinst() {
189         # portage sucks and doesnt unmerge files in /etc
190         rm -vf "${EROOT}"/etc/skel/.gdbinit
191
192         if use prefix && [[ ${CHOST} == *-darwin* ]] ; then
193                 ewarn "gdb is unable to get a mach task port when installed by Prefix"
194                 ewarn "Portage, unprivileged.  To make gdb fully functional you'll"
195                 ewarn "have to perform the following steps:"
196                 ewarn "  % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb"
197                 ewarn "  % sudo chmod g+s ${EPREFIX}/usr/bin/gdb"
198         fi
199 }