packaging: fix testsuite build.
[external/binutils.git] / packaging / binutils.spec
1 %ifarch armv7l
2 %define ARCH armv7l
3 %define ABI eabi
4 %endif
5 %ifarch armv7hl
6 %define ARCH armv7hl
7 %define ABI eabihf
8 %endif
9 %ifarch %ix86
10 %define ARCH i586
11 %endif
12 %ifarch x86_64
13 %define ARCH x86_64
14 %endif
15 %ifarch aarch64
16 %define ARCH aarch64
17 %endif
18
19 %define host_arch %{ARCH}-tizen-linux-gnu%{?ABI}
20
21 %define target_cpu %{?cross}%{!?cross:%{ARCH}}
22 %define target_abi %{?cross:%{?armv7l:eabi}%{?armv7hl:eabihf}}%{!?cross:%{?ABI}}
23
24 %define target_arch %{target_cpu}-tizen-linux-gnu%{?target_abi}
25
26 %if 0%{?run_tests}
27 %define binutils_run_tests 1
28 %endif
29
30 Name:           binutils%{?cross:-%{cross}}
31 BuildRequires:  makeinfo
32 BuildRequires:  bison
33 BuildRequires:  flex
34 BuildRequires:  ncurses-devel
35 BuildRequires:  zlib-devel
36 BuildRequires:  gcc-c++
37 %if 0%{?binutils_run_tests}
38 BuildRequires:  dejagnu
39 BuildRequires:  gdb
40 BuildRequires:  glibc-devel-static
41 %endif
42 Version:        2.27
43 Release:        0
44 Url:            http://www.gnu.org/software/binutils/
45 Summary:        GNU Binutils
46 License:        GFDL-1.3 and GPL-3.0+
47 Group:          Development/Building
48 %{?cross:ExcludeArch: %{cross}}
49 Source:         binutils-%{version}.tar.bz2
50 Source1001:     binutils.manifest
51
52 %description
53 C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
54 size, strings, and strip. These utilities are needed whenever you want
55 to compile a program or kernel.
56
57
58 %package gold
59 Summary:        The gold linker
60 License:        GPL-3.0+
61 Group:          Development/Building
62
63 %description gold
64 gold is an ELF linker.  It is intended to have complete support for ELF
65 and to run as fast as possible on modern systems.  For normal use it is
66 a drop-in replacement for the older GNU linker.
67
68
69 %package devel
70 Summary:        GNU binutils (BFD development files)
71 License:        GPL-3.0+
72 Group:          Development/Building
73 Requires: zlib-devel
74
75 %description devel
76 This package includes header files and static libraries necessary to
77 build programs which use the GNU BFD library, which is part of
78 binutils.
79
80
81 %prep
82 %setup -q -n binutils-%{version}
83 cp %{SOURCE1001} .
84
85
86 %build
87 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error %{?cross:-DIGNORE_BROKEN_PLUGINS}"
88 export CFLAGS="${RPM_OPT_FLAGS}"
89 export CXXFLAGS="${RPM_OPT_FLAGS}"
90
91 mkdir build-dir
92 cd build-dir
93
94 ../configure \
95         --prefix=%{_prefix} --libdir=%{_libdir} \
96         --infodir=%{_infodir} --mandir=%{_mandir} \
97         --with-bugurl=http://bugs.tizen.org/ \
98         --with-sysroot=/ \
99         --disable-nls \
100         --with-separate-debug-dir=%{_prefix}/lib/debug \
101         --with-pic \
102         --build=%{host_arch} --target=%{target_arch} \
103         --host=%{host_arch} \
104 %{?cross: \
105         --enable-targets=%{target_arch} \
106         --enable-64-bit-bfd \
107 } \
108 %{!?cross: \
109         --enable-targets=aarch64-tizen-linux,armv7l-tizen-linux,armv7hl-tizen-linux,armv8l-tizen-linux,i686-tizen-linux,x86_64-tizen-linux \
110 } \
111         --enable-plugins \
112         --enable-gold \
113         --enable-shared \
114         --enable-new-dtags
115
116 make %{?_smp_mflags}
117
118 %check
119 %{?binutils_run_tests:
120     make %{?_smp_mflags} -C build-dir check -k
121 }
122
123 %install
124 cd build-dir
125 make DESTDIR=$RPM_BUILD_ROOT install
126
127 # Copy instead of hardlinks
128 for binary in ar as ld{,.bfd,.gold} nm obj{dump,copy} ranlib strip
129 do
130   rm %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
131 %{!?cross:
132   cp %{buildroot}%{_bindir}/$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
133 }
134 %{?cross:
135   cp %{buildroot}%{_bindir}/%{target_arch}-$binary %{buildroot}%{_prefix}/%{target_arch}/bin/$binary
136 }
137 done
138
139 install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_prefix}/%{_lib}
140 install -m 644 ../include/libiberty.h %{buildroot}%{_prefix}/include
141
142 # Remove unwanted files to shut up rpm
143 %{remove_docs}
144 rm -rf %{buildroot}%{_bindir}/gcore
145 rm -rf %{buildroot}%{_bindir}/gdb*
146 rm -rf %{buildroot}%{_datadir}/gdb
147 rm -rf %{buildroot}%{_libdir}/lib{bfd,opcodes,inproctrace}.{so,la}
148 %{?cross:
149 rm -rf %{buildroot}%{_prefix}/%{target_arch}/lib/ldscripts
150 rm -rf %{buildroot}%{_prefix}/%{host_arch}
151 rm -rf %{buildroot}%{_includedir}
152 rm -rf %{buildroot}%{_prefix}/lib*
153 rm -rf %{buildroot}%{_datadir}
154 }
155
156 %files
157 %manifest binutils.manifest
158 %defattr(-,root,root)
159 %{_bindir}/*
160 %{_prefix}/%{target_arch}/bin/*
161 %{!?cross:
162 %exclude %{_bindir}/ld.gold
163 %exclude %{_prefix}/%{target_arch}/bin/ld.gold
164 %{_libdir}/*.so
165 %{_prefix}/%{host_arch}/lib/ldscripts
166
167 %files devel
168 %manifest binutils.manifest
169 %defattr(-,root,root)
170 %{_includedir}/*.h
171 %{_includedir}/gdb/*.h
172 %{_libdir}/*.a
173
174 %files gold
175 %manifest binutils.manifest
176 %defattr(-,root,root)
177 %{_bindir}/ld.gold
178 %{_prefix}/%{target_arch}/bin/ld.gold
179 }
180
181 %changelog