%global target arm-none-eabi
%global gdb_datarootdir %{_datadir}/gdb-%{target}-%{version}

Name:           %{target}-gdb
Version:        10.2
Release:        1%{?dist}
Summary:        GDB for (remote) debugging ARM bare-metal targets
License:        GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Boost and zlib and ISC and FSFULLR and FSFAP and Public Domain and GFDL
URL:            http://www.sourceware.org/gdb/
Source0:        http://ftp.gnu.org/gnu/gdb/gdb-%{version}.tar.xz

Provides: bundled(gnulib)

BuildRequires:  autoconf
BuildRequires:  pkgconfig(expat)
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  make
BuildRequires:  pkgconfig(mpfr)
BuildRequires:  pkgconfig(ncurses)
BuildRequires:  texinfo
BuildRequires:  texinfo-tex


%description
This is a version of GDB, the GNU Project debugger, for (remote)
debugging %{target} binaries. GDB allows you to see and modify what is
going on inside another program while it is executing.

%prep
%setup -q -c -n %{name}
cd gdb-%{version}

%build
mkdir -p build
cd build
# Set datarootdir to have target and version in so that we can exist
# side-by-side with other gdb installations of different versions
CFLAGS="%{optflags}" ../gdb-%{version}/configure --prefix=%{_prefix} \
        --libdir=%{_libdir} --mandir=%{_mandir} --infodir=%{_infodir} \
        --datarootdir=%{gdb_datarootdir} --disable-rpath \
        --target=%{target} --disable-nls --disable-werror --without-python --without-doc --with-xml --with-expat

%make_build

%install
cd build
%make_install -p

# we don't want these as this is a cross-compiler
rm -rf %{buildroot}/%{_infodir}
rm -f %{buildroot}/%{_libdir}/libiberty.a

# Get rid of the shared lib
rm -f %{buildroot}/%{_libdir}/lib%{target}-sim.a

# Exclude jit-reader.h since it is included by normal gdb
rm -f %{buildroot}/%{_includedir}/gdb/jit-reader.h

# Non-linux targets don't have syscalls
rm -rf %{buildroot}/%{_prefix}/share/gdb/syscalls

%files
%license gdb-%{version}/{COPYING?,COPYING?.LIB}

%{_bindir}/%{target}-gdb
%{_bindir}/%{target}-gdb-add-index
%{_bindir}/%{target}-run
%{_mandir}/man1/%{target}-gdb.1.gz
%{_mandir}/man1/%{target}-gdbserver.1.gz
%{_mandir}/man1/%{target}-gdb-add-index.1.gz
%{_mandir}/man5/%{target}-gdbinit.5.gz
%{_datadir}/gdb-%{target}-%{version}/

%changelog
* Mon Apr 26 2021 Jaroslav Kysela <perex@perex.cz> - 10.2-1
- Rebuild for 10.2

* Wed Jul 22 2020 Austin Chang <austin880625@gmail.com> - 9.2-1
- Rebuilt the package for newer version.

* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 7.6.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 7.6.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 7.6.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 7.6.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7.6.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Fri Aug 15 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 7.6.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Tue Jun 17 2014 Jérôme Glisse <jglisse@redhat.com> 7.6.2-1
- Drop texinfo patch, update to 7.6.2, fix rpath and other rpmlint warnings and errors.

* Fri Feb 7 2014 Maroš Zaťko <mzatko@fedoraproject.org> 7.4.1-2
- Add patch to fix texinfo build error

* Sun Oct 06 2013 David Lanzendörfer <david.lanzendoerfer@o2s.ch> 7.4.1-1
- Initial release