+%if 0%{?run_tests}
+%define gdb_run_tests 1
+%endif
+
+# Enable this when testing on device to:
+# 1. Enable macro to turn on testsuite building ('gdb_run_tests 1')
+# 2. Skip configure and make commands and go directly to 'make check'
+%if 0%{?run_tests_on_device}
+%define gdb_run_tests 1
+%define gdb_skip_configure 1
+%define gdb_skip_make 1
+%endif
+
+# Exit right after 'make ..' step to keep all object files produced by gdb build
+%if 0%{?exit_on_make_finish}
+%define gdb_exit_on_make_finish 1
+%endif
+
Name: gdb
Version: 8.3.1
Release: 0
BuildRequires: gcc-c++
BuildRequires: ncurses-devel
BuildRequires: makeinfo
+%if 0%{?gdb_run_tests}
+BuildRequires: dejagnu
+BuildRequires: glibc-devel-static
+%endif
%description
GDB, the GNU debugger, allows you to debug programs written in C, C++,
This package provides a program that allows you to run GDB on a different machine than the one which is running the program being debugged.
+%{?gdb_run_tests:
+%package testresults
+Summary: Testsuite results
+License: Public Domain
+Group: Development/Building
+%description testresults
+Results from running the gdb tests.
+}
+
%prep
%setup -q
cp %{SOURCE1001} .
#If you want to add a new LDFLAGS to IPA, add it to `IPA_LDFLAGS` rather than` LDFLAGS`.
IPA_LDFLAGS+=""
+%{!?gdb_skip_configure:
%configure \
--with-gdb-datadir=%{_datadir}/gdb \
--enable-gdb-build-warnings=,-Wno-unused \
--disable-werror \
--with-separate-debug-dir=/usr/lib/debug \
- --disable-sim \
+ %{!?gdb_run_tests:--disable-sim} \
--disable-rpath \
--with-expat \
--enable-64-bit-bfd \
- --enable-static --disable-shared --enable-debug
+ --enable-debug \
+ %{!?gdb_run_tests: --enable-static --disable-shared}
+}
+%{!?gdb_skip_make:
make %{?_smp_mflags}
+}
+
+%{?gdb_exit_on_make_finish:
+exit 1
+}
+
+%{?gdb_run_tests:
+echo "Run testsuite"
+# asan needs a whole shadow address space
+ulimit -v unlimited || true
+make -k check %{?_smp_mflags} || true
+mkdir ./testresults
+for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
+./contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ./testresults/test_summary.txt
+done
+}
%install
%make_install
+%{?gdb_run_tests:
+ find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
+ mkdir -p ./testresults && tar -xf testresults.tar -C ./testresults
+ find ./testresults/ -type f -exec chmod 644 {} \;
+}
+
%find_lang opcodes
%find_lang bfd
mv opcodes.lang %{name}.lang
%manifest %{name}.manifest
%{_includedir}/*.h
%{_includedir}/gdb/*.h
+
+%{?gdb_run_tests:
+%files testresults
+%defattr(-,root,root)
+%doc testresults/test_summary.txt
+%doc testresults/*
+}