Add spec for tizen rpm packaging
[platform/upstream/gdb.git] / packaging / gdb.spec
1 %if 0%{?run_tests}
2 %define gdb_run_tests 1
3 %endif
4
5 # Enable this when testing on device to:
6 # 1. Enable macro to turn on testsuite building ('gdb_run_tests 1')
7 # 2. Skip configure and make commands and go directly to 'make check'
8 %if 0%{?run_tests_on_device}
9 %define gdb_run_tests 1
10 %define gdb_skip_configure 1
11 %define gdb_skip_make 1
12 %endif
13
14 # Exit right after 'make ..' step to keep all object files produced by gdb build
15 %if 0%{?exit_on_make_finish}
16 %define gdb_exit_on_make_finish 1
17 %endif
18
19 Name:           gdb
20 Version:        13.2
21 Release:        0
22 License:        GPL-3.0+
23 Summary:        A GNU source-level debugger for C, C++, Java and other languages
24 Url:            http://gnu.org/software/gdb/
25 Group:          Development/Toolchain
26 Source:         ftp://ftp.gnu.org/gnu/gdb/gdb-%{version}.tar.gz
27 Source1001:     gdb.manifest
28 %define gdb_src gdb-%{version}
29 %define gdb_build build-%{_target_platform}
30 Requires:       python3
31 Requires:       libgmp
32 BuildRequires:  bison
33 BuildRequires:  expat-devel
34 BuildRequires:  flex
35 BuildRequires:  gettext-tools
36 BuildRequires:  python3-devel
37 BuildRequires:  gcc-c++
38 BuildRequires:  ncurses-devel
39 BuildRequires:  makeinfo
40 BuildRequires:  gmp-devel
41 %if 0%{?gdb_run_tests}
42 BuildRequires:  dejagnu
43 BuildRequires:  glibc-devel-static
44 %endif
45
46 %description
47 GDB, the GNU debugger, allows you to debug programs written in C, C++,
48 Java, and other languages, by executing them in a controlled fashion
49 and printing their data.
50
51 %package devel
52 Summary:        Development files for gdb
53
54 %description devel
55 Development files for gdb.
56
57 %ifnarch riscv64
58 %package server
59 Summary:        A standalone server for GDB (the GNU source-level debugger)
60
61 %description server
62 GDB, the GNU debugger, allows you to debug programs written in C, C++,
63 Java, and other languages, by executing them in a controlled fashion
64 and printing their data.
65
66 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.
67 %endif
68
69 %{?gdb_run_tests:
70 %package testresults
71 Summary:       Testsuite results
72 License:       Public Domain
73 Group:         Development/Building
74 %description testresults
75 Results from running the gdb tests.
76 }
77
78 %prep
79 %setup -q
80 cp %{SOURCE1001} .
81
82 # Remove the info and other generated files added by the FSF release
83 # process.
84 rm -f libdecnumber/gstdint.h
85 rm -f bfd/doc/*.info
86 rm -f bfd/doc/*.info-*
87 rm -f gdb/doc/*.info
88 rm -f gdb/doc/*.info-*
89
90 %build
91 export CFLAGS+=" -fPIE"
92 #If you want to add a new LDFLAGS to IPA, add it to `IPA_LDFLAGS` rather than` LDFLAGS`.
93 export LIB_CXXFLAGS=$CXXFLAGS
94 export IPA_LDFLAGS=$LDFLAGS
95 export CXXFLAGS+=" -fPIE"
96 export LDFLAGS+=" -pie"
97
98 %{!?gdb_skip_configure:
99 %configure                                              \
100         --with-gdb-datadir=%{_datadir}/gdb              \
101         --enable-gdb-build-warnings=,-Wno-unused        \
102         --disable-werror                                \
103         --with-separate-debug-dir=/usr/lib/debug        \
104         %{!?gdb_run_tests:--disable-sim}                \
105         --disable-rpath                                 \
106         --with-expat                                    \
107         --enable-64-bit-bfd                             \
108         --enable-debug                                  \
109         %{!?gdb_run_tests: --enable-static --disable-shared}
110 }
111
112 %{!?gdb_skip_make:
113 make %{?_smp_mflags}
114 }
115
116 %{?gdb_exit_on_make_finish:
117 exit 1
118 }
119
120 %{?gdb_run_tests:
121 echo "Run testsuite"
122 # asan needs a whole shadow address space
123 ulimit -v unlimited || true
124 make -k check %{?_smp_mflags} || true
125 mkdir ./testresults
126 for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
127 ./contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ./testresults/test_summary.txt
128 done
129 }
130
131
132 %install
133 %make_install
134
135 %{?gdb_run_tests:
136   find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
137   mkdir -p ./testresults && tar -xf testresults.tar -C ./testresults
138   find ./testresults/ -type f -exec chmod 644 {} \;
139 }
140
141 %find_lang opcodes
142 %find_lang bfd
143 mv opcodes.lang %{name}.lang
144 cat bfd.lang >> %{name}.lang
145
146 %docs_package
147
148 %lang_package
149
150 %files
151 %defattr(-,root,root)
152 %manifest %{name}.manifest
153 %license COPYING COPYING.LIB
154 %{_bindir}/*
155 %{_datadir}/gdb
156
157 %ifnarch riscv64
158 %files server
159 %manifest %{name}.manifest
160 %defattr(-,root,root)
161 %{_bindir}/gdbserver
162 %{_mandir}/*/gdbserver.1*
163 %ifarch %{ix86} x86_64 aarch64
164 %{_libdir}/libinproctrace.so
165 %endif
166 %endif
167
168 %files devel
169 %manifest %{name}.manifest
170 %{_includedir}/*.h
171 %{_includedir}/gdb/*.h
172
173 %{?gdb_run_tests:
174 %files testresults
175 %defattr(-,root,root)
176 %doc testresults/test_summary.txt
177 %doc testresults/*
178 }