packaging: keep shared libraries for libbfd & libopcodes
[platform/upstream/binutils.git] / packaging / binutils-armv7hl.spec
1 %define cross armv7hl
2 %define armv7hl 1
3
4 %ifarch armv7l
5 %define ARCH armv7l
6 %define ABI eabi
7 %endif
8 %ifarch armv7hl
9 %define ARCH armv7hl
10 %define ABI eabihf
11 %endif
12 %ifarch %ix86
13 %define ARCH i586
14 %endif
15 %ifarch x86_64
16 %define ARCH x86_64
17 %endif
18 %ifarch aarch64
19 %define ARCH aarch64
20 %endif
21
22 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
23
24 %define target_cpu %{?cross}%{!?cross:%{ARCH}}
25 %define target_abi %{?cross:%{?armv7l:eabi}%{?armv7hl:eabihf}}%{!?cross:%{?ABI}}
26
27 %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
28
29 %if 0%{?run_tests}
30 %{!?cross:
31 %define binutils_run_tests 1
32 }
33 %endif
34
35 %if 0%{?dump_configure}
36 %define binutils_dump_configure 1
37 %endif
38
39 # Enable this when testing on device to:
40 # 1. Enable macro to turn on testsuite building ('binutils_run_tests 1')
41 # 2. Keep 'build-dir/' folder in build stage as we do not want to rebuild all
42 # binutils again on device after invoking rpmbuild --short-circuit -bc ...
43 # 3. Skip configure and make commands and go directly to 'make check'
44 %if 0%{?run_tests_on_device}
45 %define binutils_run_tests 1
46 %define binutils_keep_build_dir 1
47 %define binutils_skip_configure 1
48 %define binutils_skip_make 1
49 %endif
50
51 # Exit right after 'make ..' step to keep all object files produced by binutils build
52 %if 0%{?exit_on_make_finish}
53 %define binutils_exit_on_make_finish 1
54 %endif
55
56 Name:           binutils%{?cross:-%{cross}}
57 BuildRequires:  makeinfo
58 BuildRequires:  bison
59 BuildRequires:  flex
60 BuildRequires:  ncurses-devel
61 BuildRequires:  zlib-devel
62 BuildRequires:  gcc-c++
63 %if 0%{?binutils_run_tests}
64 BuildRequires:  dejagnu
65 BuildRequires:  glibc-devel-static
66 %endif
67 %if 0%{?binutils_dump_configure}
68 BuildRequires: configure-dumper
69 %endif
70 Version:        2.33.1
71 Release:        0
72 Url:            http://www.gnu.org/software/binutils/
73 Summary:        GNU Binutils
74 License:        GFDL-1.3 and GPL-3.0+
75 Group:          Development/Building
76 %{?cross:ExcludeArch: %{cross}}
77 Source:         binutils-%{version}.tar.bz2
78 Source1001:     binutils.manifest
79
80 %description
81 C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
82 size, strings, and strip. These utilities are needed whenever you want
83 to compile a program or kernel.
84
85
86 %package gold
87 Summary:        The gold linker
88 License:        GPL-3.0+
89 Group:          Development/Building
90
91 %description gold
92 gold is an ELF linker.  It is intended to have complete support for ELF
93 and to run as fast as possible on modern systems.  For normal use it is
94 a drop-in replacement for the older GNU linker.
95
96
97 %package devel
98 Summary:        GNU binutils (BFD development files)
99 License:        GPL-3.0+
100 Group:          Development/Building
101 Requires: zlib-devel
102
103 %description devel
104 This package includes header files and static libraries necessary to
105 build programs which use the GNU BFD library, which is part of
106 binutils.
107
108 %{?binutils_run_tests:
109 %package testresults
110 Summary:       Testsuite results
111 License:       Public Domain
112 Group:         Development/Building
113 %description testresults
114 Results from running the binutils tests.
115 }
116
117 %{?binutils_dump_configure:
118 %package configure-dump
119 Summary:       GNU Binutils configure dump
120 License:       GPL-3.0+
121 Group:         Development/Languages
122 %description configure-dump
123 This package contains dump of configure variables of Binutils
124 }
125
126 %prep
127 %setup -q -n binutils-%{version}
128 cp %{SOURCE1001} .
129
130
131 %build
132 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error %{?cross:-DIGNORE_BROKEN_PLUGINS}"
133 export CFLAGS="${RPM_OPT_FLAGS}"
134 export CXXFLAGS="${RPM_OPT_FLAGS}"
135
136 %{!?binutils_keep_build_dir:
137 rm -rf build-dir
138 }
139 # Remove gdb and sim since they have separate gdb package
140 rm -rf gdb sim
141
142 mkdir -p build-dir
143 cd build-dir
144
145 %{!?binutils_skip_configure:
146 %{?binutils_dump_configure:patch_configure.pl ..}   # Add debug prints into configure
147 ../configure \
148         --prefix=%{_prefix} --libdir=%{_libdir} \
149         --infodir=%{_infodir} --mandir=%{_mandir} \
150         --with-bugurl=http://bugs.tizen.org/ \
151         --with-sysroot=/ \
152         --disable-nls \
153         --with-separate-debug-dir=%{_prefix}/lib/debug \
154         --with-pic \
155         --build=%{host_arch} --target=%{target_arch} \
156         --host=%{host_arch} \
157 %{?cross: \
158         --enable-targets=%{target_arch} \
159         --enable-64-bit-bfd \
160 } \
161 %{!?cross: \
162         --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
163 } \
164         --enable-plugins \
165         --enable-gold \
166         --enable-shared \
167         --enable-new-dtags \
168         --enable-relro=no \
169 %ifarch %ix86
170         --disable-separate-code
171 %endif
172
173 }
174
175 %{!?binutils_skip_make:
176 make %{?_smp_mflags}
177 %{?binutils_dump_configure:
178  dump_configure.pl .. . \
179                    --project binutils \
180                    --project-version %{version} \
181                    --out_db binutils-%{version}-%{release}-%_project-%_repository.db
182  }
183 }
184
185 %{?binutils_exit_on_make_finish:
186 exit 1
187 }
188
189 %{?binutils_run_tests:
190 echo "Run testsuite"
191 # asan needs a whole shadow address space
192 ulimit -v unlimited || true
193 make -k check %{?_smp_mflags} || true
194 mkdir ../testresults
195 for tool in $(find -name '*.sum' -exec basename {} \; | sort -u | sed -e 's/.sum//'); do
196 ../contrib/dg-extract-results.sh -t $tool $(find -name '*.sum') | tee -a ../testresults/test_summary.txt
197 done
198 }
199
200 %install
201 cd build-dir
202 make DESTDIR=$RPM_BUILD_ROOT install
203
204 # Copy instead of hardlinks
205 for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
206 do
207   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
208 %{!?cross:
209   cp %{buildroot}%{_bindir}/$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
210 }
211 %{?cross:
212   cp %{buildroot}%{_bindir}/%{target_arch}-$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
213 }
214 done
215
216 install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_prefix}/%{_lib}
217 install -m 644 ../include/libiberty.h %{buildroot}%{_prefix}/include
218
219 %{?binutils_run_tests:
220   find . \( -name "*.sum" -o -name "*.log" -a \! -name "config.log" \) -exec tar -rf testresults.tar {} \;
221   mkdir -p ../testresults && tar -xf testresults.tar -C ../testresults
222   find ../testresults/ -type f -exec chmod 644 {} \;
223 }
224
225 # Remove unwanted files to shut up rpm
226 %{remove_docs}
227 rm -rf %{buildroot}%{_bindir}/gcore
228 rm -rf %{buildroot}%{_libdir}/lib{bfd,opcodes,inproctrace}.{la}
229 %{?cross:
230 rm -rf %{buildroot}%{_prefix}/%{target_arch}/lib/ldscripts
231 rm -rf %{buildroot}%{_prefix}/%{host_arch}
232 rm -rf %{buildroot}%{_includedir}
233 rm -rf %{buildroot}%{_prefix}/lib*
234 rm -rf %{buildroot}%{_datadir}
235 }
236
237 %{?binutils_dump_configure:
238   install -D -m 0644 binutils-%{version}-%{release}-%_project-%_repository.db %{buildroot}%{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
239 }
240
241 %files
242 %manifest binutils.manifest
243 %defattr(-,root,root)
244 %{_bindir}/*
245 %{_prefix}/%{target_arch}/bin/*
246 %{!?cross:
247 %exclude %{_bindir}/ld.gold
248 %exclude %{_prefix}/%{target_arch}/bin/ld.gold
249 %{_libdir}/*.so
250 %{_prefix}/%{host_arch}/lib/ldscripts
251
252 %files devel
253 %manifest binutils.manifest
254 %defattr(-,root,root)
255 %{_includedir}/*.h
256 %{_libdir}/*.a
257
258 %files gold
259 %manifest binutils.manifest
260 %defattr(-,root,root)
261 %{_bindir}/ld.gold
262 %{_prefix}/%{target_arch}/bin/ld.gold
263 }
264
265 %{?binutils_run_tests:
266 %files testresults
267 %defattr(-,root,root)
268 %doc testresults/test_summary.txt
269 %doc testresults/*
270 }
271
272 %{?binutils_dump_configure:
273 %files configure-dump
274 %manifest binutils.manifest
275 %{_datadir}/binutils-%{version}-%{release}-%_project-%_repository.db
276 }
277
278 %changelog