1 | |
---|
2 | %define gcc_version @gcc_version@ |
---|
3 | %define newlib_version @newlib_version@ |
---|
4 | |
---|
5 | %define gcc_target @target_alias@ |
---|
6 | |
---|
7 | Name: %{rpmprefix}%{gcc_target}-gcc-newlib |
---|
8 | Summary: gcc and newlib C Library for %{gcc_target}. |
---|
9 | Group: %{rpmgroup} |
---|
10 | Release: @Release@ |
---|
11 | License: gcc is GPL/LGPL ; newlib no has restrictions on run-time usage |
---|
12 | |
---|
13 | Packager: ralf.corsepius@rtems.org and joel@OARcorp.com |
---|
14 | |
---|
15 | Version: gcc%{gcc_version}newlib%{newlib_version} |
---|
16 | |
---|
17 | Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}@gcc_suffix@ |
---|
18 | Source1: ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_version}@newlib_suffix@ |
---|
19 | @PATCH0@ |
---|
20 | @PATCH1@ |
---|
21 | BuildRequires: texinfo >= 4.2 |
---|
22 | BuildRequires: %{rpmprefix}%{gcc_target}-binutils |
---|
23 | |
---|
24 | # |
---|
25 | # The original sources are not included in the source RPM. |
---|
26 | # If we included them, then the source RPMs for each target |
---|
27 | # would duplicate MBs of source unnecessarily. This is |
---|
28 | # a duplication of over 30 MBs of source for each of |
---|
29 | # the more than 10 targets it is possible to build. |
---|
30 | # |
---|
31 | # You can get them yourself from the Internet and copy them to |
---|
32 | # your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR). |
---|
33 | # Or you can try the ftp options of rpm :-) |
---|
34 | # |
---|
35 | %{?!_with_sources:NoSource: 0} |
---|
36 | %{?!_with_sources:NoSource: 1} |
---|
37 | |
---|
38 | # default languages to build |
---|
39 | %define _cxx 1 |
---|
40 | %define _fortran 0 |
---|
41 | %define _gcj 0 |
---|
42 | %define _gnat 0 |
---|
43 | %define _objc 0 |
---|
44 | %define _libgcj 0 |
---|
45 | |
---|
46 | |
---|
47 | # custom defaults for specific targets |
---|
48 | %if "%{gcc_target}" == "arm-rtems@osversion@" |
---|
49 | # Gnat lacks arm support |
---|
50 | %define _gnat 0 |
---|
51 | %endif |
---|
52 | |
---|
53 | %if "%{gcc_target}" == "avr-rtems@osversion@" |
---|
54 | %define _cxx 0 |
---|
55 | %define _fortran 0 |
---|
56 | %define _gcj 0 |
---|
57 | %define _gnat 0 |
---|
58 | %endif |
---|
59 | |
---|
60 | %if "%{gcc_target}" == "h8300-rtems@osversion@" |
---|
61 | %define _fortran 0 |
---|
62 | %define _gcj 0 |
---|
63 | %define _gnat 0 |
---|
64 | %endif |
---|
65 | |
---|
66 | %if "%{gcc_target}" == "sh-rtems@osversion@" |
---|
67 | # Triggers an ICE in GCC-4.0.0 |
---|
68 | %define _gnat 0 |
---|
69 | %endif |
---|
70 | |
---|
71 | %if "%{gcc_target}" == "tic4x-rtems@osversion@" |
---|
72 | %define _cxx 0 |
---|
73 | %define _gnat 0 |
---|
74 | %define _gcj 0 |
---|
75 | %define _fortran 0 |
---|
76 | %endif |
---|
77 | |
---|
78 | |
---|
79 | # Allow the user to build arbitrary languages |
---|
80 | %{?_with_cxx:%define _cxx 1} |
---|
81 | %{?_with_fortran:%define _fortran 1} |
---|
82 | %{?_with_gcj:%define _gcj 1} |
---|
83 | %{?_with_gnat:%define _gnat 1} |
---|
84 | %{?_with_objc:%define _objc 1} |
---|
85 | %{?_with_libgcj:%define _libgcj 1} |
---|
86 | |
---|
87 | # Allow the user to suppress building languages |
---|
88 | %{?_without_cxx:%define _cxx 0} |
---|
89 | %{?_without_fortran:%define _fortran 0} |
---|
90 | %{?_without_gcj:%define _gcj 0} |
---|
91 | %{?_without_gnat:%define _gnat 0} |
---|
92 | %{?_without_objc:%define _objc 0} |
---|
93 | %{?_without_libgcj:%define _libgcj 0} |
---|
94 | |
---|
95 | %define build_cxx %_cxx |
---|
96 | %if "%{gcc_version}" >= "4.0.0" |
---|
97 | %define build_f95 %_fortran |
---|
98 | %define build_g77 0 |
---|
99 | %else |
---|
100 | %define build_f95 0 |
---|
101 | %define build_g77 %_fortran |
---|
102 | %endif |
---|
103 | %define build_gnat %_gnat |
---|
104 | %define build_gcj %_gcj |
---|
105 | %define build_objc %_objc |
---|
106 | %define build_libgcj %_libgcj |
---|
107 | |
---|
108 | %if %build_gcj |
---|
109 | # Building gcj requires bison and zlib |
---|
110 | BuildRequires: bison |
---|
111 | %endif |
---|
112 | |
---|
113 | %if "%_vendor" == "redhat" |
---|
114 | %if %build_gcj |
---|
115 | BuildRequires: zlib-devel |
---|
116 | %endif |
---|
117 | %if %build_gnat |
---|
118 | # Building gnat requires gnat |
---|
119 | # This really isn't available until RedHat 8.0. How to conditionalize this? |
---|
120 | BuildRequires: gcc-gnat |
---|
121 | # Urgh, building gnat requires the target c-toolchain |
---|
122 | BuildRequires: %{rpmprefix}%{gcc_target}-gcc < %{version}-%{release} |
---|
123 | %endif |
---|
124 | %if %build_f95 |
---|
125 | BuildRequires: gmp-devel |
---|
126 | %endif |
---|
127 | %endif |
---|
128 | |
---|
129 | %if "%{gcc_version}" >= "3.4" |
---|
130 | %define gcclib %{_libdir}/gcc |
---|
131 | %define gccexec %{_libexecdir}/gcc |
---|
132 | %else |
---|
133 | %define gcclib %{_libdir}/gcc-lib |
---|
134 | %define gccexec %{_libdir}/gcc-lib |
---|
135 | %endif |
---|
136 | |
---|
137 | %description |
---|
138 | RTEMS is an open source operating system for embedded systems. |
---|
139 | |
---|
140 | This is gcc's and newlib C Library's sources with patches for RTEMS. |
---|
141 | |
---|
142 | %prep |
---|
143 | # untar the sources inside %{gcc_target}-gcc-newlib |
---|
144 | %setup -c -T -n %{name}-%{version} -a0 -a1 |
---|
145 | |
---|
146 | cd gcc-%{gcc_version} |
---|
147 | %{?PATCH0:%patch0 -p1} |
---|
148 | cd .. |
---|
149 | cd newlib-%{newlib_version} |
---|
150 | %{?PATCH1:%patch1 -p1} |
---|
151 | cd .. |
---|
152 | |
---|
153 | cd gcc-%{gcc_version} |
---|
154 | sed -e 's/\(version_string.* = \"[^\"]*\)/\1 (RTEMS gcc-%{gcc_version}-@gcc_patch_version@\/newlib-%{newlib_version}-@newlib_patch_version@-@Release@)/' \ |
---|
155 | gcc/version.c > gcc/version.c~ |
---|
156 | mv gcc/version.c~ gcc/version.c |
---|
157 | |
---|
158 | # Fix timestamps |
---|
159 | contrib/gcc_update --touch |
---|
160 | cd .. |
---|
161 | |
---|
162 | # Copy the C library into gcc's source tree |
---|
163 | ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version} |
---|
164 | test -d build || mkdir build |
---|
165 | |
---|
166 | %build |
---|
167 | cd build |
---|
168 | |
---|
169 | languages="c" |
---|
170 | %if %build_cxx |
---|
171 | languages="$languages,c++" |
---|
172 | %endif |
---|
173 | %if %build_g77 |
---|
174 | languages="$languages,g77" |
---|
175 | %endif |
---|
176 | %if %build_f95 |
---|
177 | languages="$languages,f95" |
---|
178 | %endif |
---|
179 | %if %build_gcj |
---|
180 | languages="$languages,java" |
---|
181 | %endif |
---|
182 | %if %build_objc |
---|
183 | languages="$languages,objc" |
---|
184 | %endif |
---|
185 | %if %build_gnat |
---|
186 | languages="$languages,ada" |
---|
187 | %endif |
---|
188 | %if %build_libgcj |
---|
189 | optargs="--enable-libgcj" |
---|
190 | %endif |
---|
191 | export PATH="%{_bindir}:${PATH}" |
---|
192 | ../gcc-%{gcc_version}/configure \ |
---|
193 | --prefix=%{_prefix} \ |
---|
194 | --bindir=%{_bindir} \ |
---|
195 | --includedir=%{_includedir} \ |
---|
196 | --libdir=%{_libdir} \ |
---|
197 | --mandir=%{_mandir} \ |
---|
198 | --infodir=%{_infodir} \ |
---|
199 | --build=%_build --host=%_host \ |
---|
200 | --target=%{gcc_target} \ |
---|
201 | --with-gnu-as --with-gnu-ld --with-newlib --verbose \ |
---|
202 | --with-system-zlib --disable-nls \ |
---|
203 | --enable-version-specific-runtime-libs \ |
---|
204 | --enable-threads=rtems \ |
---|
205 | --enable-languages=$languages $optargs |
---|
206 | |
---|
207 | %if "%_host" != "%_build" |
---|
208 | # Bug in gcc-3.2.1: |
---|
209 | # Somehow, gcc doesn't get syslimits.h right for Cdn-Xs |
---|
210 | test -d gcc/include || mkdir -p gcc/include |
---|
211 | cp ../gcc-%{gcc_version}/gcc/gsyslimits.h gcc/include/syslimits.h |
---|
212 | %endif |
---|
213 | |
---|
214 | make all |
---|
215 | make info |
---|
216 | |
---|
217 | %install |
---|
218 | export PATH="%{_bindir}:${PATH}" |
---|
219 | rm -rf $RPM_BUILD_ROOT |
---|
220 | |
---|
221 | cd build |
---|
222 | # Bug in gcc-2.95.1: It doesn't build this installation directory |
---|
223 | # If it doesn't find it, gcc doesn't install %{gcc_target}/bin/gcc |
---|
224 | %if "%{gcc_version}" < "3.0" |
---|
225 | mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{gcc_target}/bin |
---|
226 | %endif |
---|
227 | |
---|
228 | make prefix=$RPM_BUILD_ROOT%{_prefix} \ |
---|
229 | bindir=$RPM_BUILD_ROOT%{_bindir} \ |
---|
230 | libdir=$RPM_BUILD_ROOT%{_libdir} \ |
---|
231 | includedir=$RPM_BUILD_ROOT%{_includedir} \ |
---|
232 | mandir=$RPM_BUILD_ROOT%{_mandir} \ |
---|
233 | infodir=$RPM_BUILD_ROOT%{_infodir} \ |
---|
234 | install |
---|
235 | cd %{gcc_target}/newlib |
---|
236 | make prefix=$RPM_BUILD_ROOT%{_prefix} \ |
---|
237 | bindir=$RPM_BUILD_ROOT%{_bindir} \ |
---|
238 | libdir=$RPM_BUILD_ROOT%{_libdir} \ |
---|
239 | includedir=$RPM_BUILD_ROOT%{_includedir} \ |
---|
240 | mandir=$RPM_BUILD_ROOT%{_mandir} \ |
---|
241 | infodir=$RPM_BUILD_ROOT%{_infodir} \ |
---|
242 | install-info |
---|
243 | # cd back to build/ |
---|
244 | cd ../.. |
---|
245 | |
---|
246 | # Bug in gcc-3.x: It puts the build dirs into *.la files |
---|
247 | |
---|
248 | # host library |
---|
249 | rm -f ${RPM_BUILD_ROOT}%{_prefix}/lib/libiberty.a |
---|
250 | |
---|
251 | # We use the version from binutils |
---|
252 | rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-c++filt%{_exeext} |
---|
253 | |
---|
254 | # We don't ship info/dir |
---|
255 | rm -f $RPM_BUILD_ROOT%{_infodir}/dir |
---|
256 | touch $RPM_BUILD_ROOT%{_infodir}/dir |
---|
257 | |
---|
258 | %if %build_f95 |
---|
259 | # # Bug in gcc-4.0.0pre |
---|
260 | # mv $RPM_BUILD_ROOT%{_bindir}/gfortran $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gfortran |
---|
261 | %endif |
---|
262 | |
---|
263 | %if "%{gcc_version}" >= "3.4" |
---|
264 | # Bug in gcc-3.4.0pre |
---|
265 | rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-%{gcc_target}-gcjh%{_exeext} |
---|
266 | %endif |
---|
267 | |
---|
268 | %if "%{gcc_version}" >= "3.3" |
---|
269 | # Bug in gcc-3.3.x/gcc-3.4.x: Despite we don't need fixincludes, it installs |
---|
270 | # the fixinclude-install-tools |
---|
271 | rm -rf ${RPM_BUILD_ROOT}%{gcclib}/%{gcc_target}/%{gcc_version}/install-tools |
---|
272 | rm -rf ${RPM_BUILD_ROOT}%{gccexec}/%{gcc_target}/%{gcc_version}/install-tools |
---|
273 | %endif |
---|
274 | |
---|
275 | %if "%{gcc_version}" < "3.0" |
---|
276 | # Bug in gcc-2.95.x: It bogusly tries to share cpp for all targets. |
---|
277 | # Rename it to target_alias-cpp |
---|
278 | if test -f $RPM_BUILD_ROOT%{_bindir}/cpp%{_exeext}; |
---|
279 | then |
---|
280 | mv $RPM_BUILD_ROOT%{_bindir}/cpp%{_exeext} \ |
---|
281 | $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-cpp%{_exeext} |
---|
282 | fi |
---|
283 | %endif |
---|
284 | |
---|
285 | # gzip info files |
---|
286 | ls $RPM_BUILD_ROOT%{_infodir}/*.info \ |
---|
287 | $RPM_BUILD_ROOT%{_infodir}/*.info-? \ |
---|
288 | $RPM_BUILD_ROOT%{_infodir}/*.info-?? \ |
---|
289 | | while read a; do \ |
---|
290 | gzip -9qf $a 2>/dev/null; \ |
---|
291 | done |
---|
292 | |
---|
293 | # gzip man pages |
---|
294 | gzip -9qf $RPM_BUILD_ROOT%{_mandir}/man?/*.? 2>/dev/null |
---|
295 | |
---|
296 | rm -f dirs ; |
---|
297 | echo "%defattr(-,root,root)" >> dirs |
---|
298 | echo "%dir %{_prefix}/lib" >> dirs ; |
---|
299 | echo "%dir %{gcclib}" >> dirs ; |
---|
300 | echo "%dir %{gcclib}/%{gcc_target}" >> dirs ; |
---|
301 | |
---|
302 | # Collect multilib subdirectories |
---|
303 | f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'` |
---|
304 | |
---|
305 | TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}" |
---|
306 | for i in $f; do |
---|
307 | case $i in |
---|
308 | \.) echo "%dir ${TGTDIR}" >> dirs |
---|
309 | ;; |
---|
310 | *) echo "%dir ${TGTDIR}/$i" >> dirs |
---|
311 | ;; |
---|
312 | esac |
---|
313 | done |
---|
314 | |
---|
315 | TGTDIR="%{_prefix}/%{gcc_target}/lib" |
---|
316 | for i in $f; do |
---|
317 | case $i in |
---|
318 | \.) echo "%dir ${TGTDIR}" >> dirs |
---|
319 | ;; |
---|
320 | *) echo "%dir ${TGTDIR}/$i" >> dirs |
---|
321 | ;; |
---|
322 | esac |
---|
323 | done |
---|
324 | |
---|
325 | # Collect files to go into different packages |
---|
326 | cp dirs files.gcc |
---|
327 | cp dirs files.g77 |
---|
328 | cp dirs files.gfortran |
---|
329 | cp dirs files.objc |
---|
330 | cp dirs files.gcj |
---|
331 | cp dirs files.g++ |
---|
332 | |
---|
333 | TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}" |
---|
334 | f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`; |
---|
335 | for i in $f; do |
---|
336 | case $i in |
---|
337 | *lib*.la) rm ${RPM_BUILD_ROOT}/$i ;; # ignore: gcc produces bogus libtool libs |
---|
338 | *f771) ;; |
---|
339 | *f951) ;; |
---|
340 | *cc1) ;; |
---|
341 | *cc1obj) ;; |
---|
342 | *cc1plus) ;; # ignore: explicitly put into rpm elsewhere |
---|
343 | *collect2) ;; |
---|
344 | *libobjc*) echo "$i" >> files.objc ;; |
---|
345 | *include/objc*) ;; |
---|
346 | *include/g++*);; |
---|
347 | *include/c++*);; |
---|
348 | *adainclude*);; |
---|
349 | *adalib*);; |
---|
350 | *gnat1);; |
---|
351 | *jc1) ;; |
---|
352 | *jvgenmain) ;; |
---|
353 | *libgfortran*.a) echo "$i" >> files.gfortran ;; |
---|
354 | *libstdc++.a) echo "$i" >> files.g++ ;; |
---|
355 | *libsupc++.a) echo "$i" >> files.g++ ;; |
---|
356 | *) echo "$i" >> files.gcc ;; |
---|
357 | esac |
---|
358 | done |
---|
359 | |
---|
360 | TGTDIR="%{_prefix}/%{gcc_target}/lib" |
---|
361 | f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`; |
---|
362 | for i in $f; do |
---|
363 | case $i in |
---|
364 | *lib*.la) rm ${RPM_BUILD_ROOT}/$i;; # ignore - gcc produces bogus libtool libs |
---|
365 | *libiberty.a) rm ${RPM_BUILD_ROOT}/$i ;; # ignore - GPL'ed |
---|
366 | # all other files belong to gcc |
---|
367 | *) echo "$i" >> files.gcc ;; |
---|
368 | esac |
---|
369 | done |
---|
370 | |
---|