source: rtems/scripts/gcc3newlib/gccnewlib.add @ b64edb5b

4.104.114.84.95
Last change on this file since b64edb5b was b64edb5b, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/12/05 at 06:37:51

Apply patches in tool subdirs.

  • Property mode set to 100644
File size: 11.5 KB
Line 
1
2%define gcc_version     @gcc_version@
3%define newlib_version  @newlib_version@
4
5%define gcc_target      @target_alias@
6
7Name:           %{rpmprefix}%{gcc_target}-gcc-newlib
8Summary:        gcc and newlib C Library for %{gcc_target}.
9Group:          %{rpmgroup}
10Release:        @Release@
11Epoch:          0
12License:        gcc is GPL/LGPL ; newlib no has restrictions on run-time usage
13
14Autoreqprov:    on
15Packager:       ralf.corsepius@rtems.org and joel@OARcorp.com
16
17Version:        gcc%{gcc_version}newlib%{newlib_version}
18
19%if "%{gcc_version}" >= "3.2.2"
20Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}@gcc_suffix@
21%else
22%if "%{gcc_version}" >= "3.0"
23Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}.tar.gz
24%else
25Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}-everything.tar.gz
26%endif
27%endif
28Source1:        ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_version}@newlib_suffix@
29@PATCH1@
30@PATCH3@
31BuildPreReq:    texinfo >= 4.2
32BuildPreReq:    %{rpmprefix}%{gcc_target}-binutils
33#
34# The original sources are not included in the source RPM.
35# If we included them, then the source RPMs for each target
36# would duplicate MBs of source unnecessarily.  This is
37# a duplication of over 30 MBs of source for each of
38# the more than 10 targets it is possible to build.
39#
40# You can get them yourself from the Internet and copy them to
41# your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR).
42# Or you can try the ftp options of rpm :-)
43#
44%{?!_with_sources:NoSource:     0}
45%{?!_with_sources:NoSource:     1}
46
47# Use rpm -ba --define 'gnat [0|1]' xxx.spec to override building gnat for
48# those targets wanting to support ada.
49
50# default to not building gnat
51# gcc-3.3: Doesn't support cross-building gnatlib
52# gcc-3.4.0: Doesn't support cross-build gnattools
53# gcc-4.0.0: Doesn't support newlib
54%define _gnat   %{?gnat:%gnat}%{!?gnat:0}
55
56# Use rpm -ba --define 'gcj [0|1]' xxx.spec to override building gcj for
57# those targets wanting to support gcj.
58
59%if "%{gcc_version}" >= "3.4"
60# default to building gcj
61%define _gcj    %{?gcj:%gcj}%{!?gcj:1}
62%else
63# default to not building gcj
64%define _gcj    %{?gcj:%gcj}%{!?gcj:0}
65%endif
66
67
68%define build_cxx       %{?cxx:%cxx}%{!?cxx:1}
69%define build_g77       %{?g77:%g77}%{!?g77:0}
70%define build_objc      %{?objc:%objc}%{!?objc:0}
71%define build_gcj       0
72%define build_gnat      0
73
74%if "%{gcc_target}" == "arm-rtems@osversion@"
75%define build_gcj       %_gcj
76%endif
77
78%if "%{gcc_target}" == "avr-rtems@osversion@"
79%define build_cxx       0
80%endif
81
82%if "%{gcc_target}" == "tic4x-rtems@osversion@"
83%define build_cxx       0
84%endif
85
86# OBSOLETE: use tic4x instead
87%if "%{gcc_target}" == "c4x-rtems@osversion@"
88%define build_cxx       0
89%endif
90
91%if "%{gcc_target}" == "i386-rtems@osversion@"
92%define build_gnat      %_gnat
93%define build_gcj       %_gcj
94%endif
95
96%if "%{gcc_target}" == "m68k-rtems@osversion@"
97%define build_gcj       %_gcj
98%endif
99
100%if "%{gcc_target}" == "mips-rtems@osversion@"
101%define build_gnat      %_gnat
102%define build_gcj       %_gcj
103%endif
104
105%if "%{gcc_target}" == "powerpc-rtems@osversion@"
106%define build_gnat      %_gnat
107%define build_gcj       %_gcj
108%endif
109
110# gcc 3.4.0 is broken for embedded sparc and gnat trips it.
111%if "%{gcc_target}" == "sparc-rtems@osversion@"
112%if "%{gcc_version}" >= "3.4"
113%define build_gnat      0
114%else
115%define build_gnat      %_gnat
116%endif
117%define build_gcj       %_gcj
118%endif
119
120%if %build_gcj
121# Building gcj requires bison and zlib
122BuildPreReq:    bison
123%if "%_vendor" == "redhat"
124BuildPreReq:    zlib-devel
125%endif
126%endif
127
128%if %build_gnat
129# Building gnat requires gnat
130%if "%_vendor" == "redhat"
131# This really isn't available until RedHat 8.0.  How to conditionalize this?
132# BuildPreReq:  gcc-gnat
133%endif
134%endif
135
136%if "%{gcc_version}" >= "3.4"
137%define gcclib %{_libdir}/gcc
138%define gccexec %{_libexecdir}/gcc
139%else
140%define gcclib %{_libdir}/gcc-lib
141%define gccexec %{_libdir}/gcc-lib
142%endif
143
144%description
145RTEMS is an open source operating system for embedded systems.
146
147This is gcc's and newlib C Library's sources with patches for RTEMS.
148
149 The original sources are not included in the source RPM.
150 If we included them, then the source RPMs for each target
151 would duplicate MBs of source unnecessarily.  This is
152 a duplication of over 30 MBs of source for each of
153 the more than 10 targets it is possible to build.
154
155 You can get them yourself from the Internet and copy them to
156 your /usr/src/[redhat|packages]/SOURCES directory ($RPM_SOURCE_DIR).
157 Or you can try the ftp options of rpm :-)
158
159%prep
160# untar the sources inside %{gcc_target}-gcc-newlib
161%setup -c -T -n %{name}-%{version} -a0 -a1
162
163cd gcc-%{gcc_version}
164%{?PATCH0:%patch0 -p1}
165cd ..
166cd newlib-%{newlib_version}
167%{?PATCH1:%patch1 -p1}
168cd ..
169
170  cd gcc-%{gcc_version}
171    sed -e 's/\(version_string = \"[^\"]*\)/\1 (RTEMS gcc-%{gcc_version}-@gcc_patch_version@\/newlib-%{newlib_version}-@newlib_patch_version@-@Release@)/' \
172    gcc/version.c > gcc/version.c~
173    mv gcc/version.c~  gcc/version.c
174
175  # Fix timestamps
176    contrib/gcc_update --touch
177  cd ..
178
179  # Copy the C library into gcc's source tree
180  ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version}
181  test -d build || mkdir build
182
183%build
184  cd build
185
186#  ALERT: GCJ would be better if we could add this flag and build
187#  it's libraries but this code isn't ready to be embedded.
188#  libgcj_flag="--enable-libgcj"
189
190  languages="c"
191%if %build_cxx
192  languages="$languages,c++"
193%endif
194%if %build_g77
195  languages="$languages,g77"
196%endif
197%if %build_gcj
198  languages="$languages,java"
199%endif
200%if %build_objc
201  languages="$languages,objc"
202%endif
203%if %build_gnat
204  languages="$languages,ada"
205%endif
206
207  export PATH="%{_bindir}:${PATH}"
208  ../gcc-%{gcc_version}/configure \
209    --prefix=%{_prefix} --mandir=%{_mandir} \
210    --infodir=%{_infodir} \
211    --build=%_build --host=%_host \
212    --target=%{gcc_target} \
213    --with-gnu-as --with-gnu-ld --with-newlib --verbose \
214    --with-system-zlib --disable-nls \
215    --enable-version-specific-runtime-libs \
216    --enable-threads=rtems \
217    --enable-languages=$languages ${libgcj_flag}
218
219%if "%_host" != "%_build"
220  # Bug in gcc-3.2.1:
221  # Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
222  test -d gcc/include || mkdir -p gcc/include
223  cp ../gcc-%{gcc_version}/gcc/gsyslimits.h gcc/include/syslimits.h
224%endif
225
226%if %build_gnat
227%if "%{gcc_version}" < "3.4"
228  cd ../gcc-%{gcc_version}/gcc/ada
229  touch treeprs.ads [es]info.h nmake.ad[bs]
230  cd ../../../build
231%endif
232%endif
233
234  make all
235%if %build_gnat
236# This gnat configuration is crap :(
237
238%if "%{gcc_version}" >= "3.4"
239# This is what is documented - Of cause it doesn't work.
240  make -C gcc gnatlib
241  make -C gcc cross-gnattools
242  make -C gcc ada.all.cross
243%endif
244
245%if "%{gcc_version}" < "3.4"
246# This is what had worked for some versions of gcc.
247  make -C gcc cross-gnattools
248  make -C gcc ada.all.cross
249# This is what gcc/ada/Makefile.in contains by default,
250# but what we override below
251  GNATLIBCFLAGS="-g -O2"
252# Let gnatlib building find newlib's headers
253  GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/%{gcc_target}/newlib/targ-include"
254  GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/../newlib-%{newlib_version}/newlib/libc/include"
255  GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/../gcc-%{gcc_version}/include"
256# Without this xgcc doesn't find the target's binutils.
257  GNATLIBCFLAGS="$GNATLIBCFLAGS -B%{_prefix}/%{gcc_target}/bin/"
258%if "%{gcc_target}" == "mips-rtems@osversion@"
259  GNATLIBCFLAGS="$GNATLIBCFLAGS -G0"
260%endif
261  make -C gcc GNATLIBCFLAGS="${GNATLIBCFLAGS}" gnatlib
262%endif
263%endif
264  make info
265
266%install
267  export PATH="%{_bindir}:${PATH}"
268  test $RPM_BUILD_ROOT = "%{_defaultbuildroot}" && \
269    rm -rf $RPM_BUILD_ROOT
270
271  cd build
272# Bug in gcc-2.95.1: It doesn't build this installation directory
273# If it doesn't find it, gcc doesn't install %{gcc_target}/bin/gcc
274%if "%{gcc_version}" < "3.0"
275  ../gcc-%{gcc_version}/mkinstalldirs \
276    $RPM_BUILD_ROOT%{_prefix}/%{gcc_target}/bin
277%endif
278
279  make prefix=$RPM_BUILD_ROOT%{_prefix} \
280    bindir=$RPM_BUILD_ROOT%{_bindir} \
281    mandir=$RPM_BUILD_ROOT%{_mandir} \
282    infodir=$RPM_BUILD_ROOT%{_infodir} \
283    install
284  cd %{gcc_target}/newlib
285  make prefix=$RPM_BUILD_ROOT%{_prefix} \
286    bindir=$RPM_BUILD_ROOT%{_bindir} \
287    mandir=$RPM_BUILD_ROOT%{_mandir} \
288    infodir=$RPM_BUILD_ROOT%{_infodir} \
289    install-info
290  # cd back to build/
291  cd ../..
292
293%if %build_gnat
294# Install a copy of gcc as gnatgcc
295# Enables us to mix different versions of gnat and gnatgcc
296  rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gnatgcc%{_exeext}
297  ln $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gcc%{_exeext} \
298    $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gnatgcc%{_exeext}
299%endif
300
301  # Bug in gcc-3.x: It puts the build dirs into *.la files
302
303  # host library
304  rm -f  ${RPM_BUILD_ROOT}%{_prefix}/lib/libiberty.a
305
306  # We use the version from binutils
307  rm -f $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target}-c++filt%{_exeext}
308
309  # We don't ship info/dir
310  rm -f $RPM_BUILD_ROOT%{_infodir}/dir
311
312%if "%{gcc_version}" >= "3.4"
313  # Bug in gcc-3.4.0pre
314  rm -f $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target}-%{gcc_target}-gcjh%{_exeext}
315%endif
316
317%if "%{gcc_version}" >= "3.3"
318  # Bug in gcc-3.3.x/gcc-3.4.x: Despite we don't need fixincludes, it installs
319  # the fixinclude-install-tools
320  rm -rf ${RPM_BUILD_ROOT}%{gccexec}/%{gcc_target}/%{gcc_version}/install-tools
321%endif
322
323%if "%{gcc_version}" < "3.0"
324  # Bug in gcc-2.95.x: It bogusly tries to share cpp for all targets.
325  # Rename it to target_alias-cpp
326  if test -f $RPM_BUILD_ROOT%{_prefix}/bin/cpp%{_exeext};
327  then
328    mv $RPM_BUILD_ROOT%{_prefix}/bin/cpp%{_exeext} \
329      $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target}-cpp%{_exeext}
330  fi
331%endif
332
333  # gzip info files
334  ls $RPM_BUILD_ROOT%{_infodir}/*.info \
335    $RPM_BUILD_ROOT%{_infodir}/*.info-? \
336    $RPM_BUILD_ROOT%{_infodir}/*.info-?? \
337  | while read a; do \
338    gzip -9qf $a 2>/dev/null; \
339  done
340
341  # gzip man pages
342  gzip -9qf $RPM_BUILD_ROOT%{_mandir}/man?/*.? 2>/dev/null
343
344  rm -f dirs ;
345  echo "%defattr(-,root,root)" >> dirs
346  echo "%dir %{_prefix}/lib" >> dirs ;
347  echo "%dir %{gcclib}" >> dirs ;
348  echo "%dir %{gcclib}/%{gcc_target}" >> dirs ;
349
350  # Collect multilib subdirectories
351  f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'`
352
353  TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}"
354  for i in $f; do
355    case $i in
356    \.) echo "%dir ${TGTDIR}" >> dirs
357      ;;
358    *)  echo "%dir ${TGTDIR}/$i" >> dirs
359      ;;
360    esac
361  done
362
363  TGTDIR="%{_prefix}/%{gcc_target}/lib"
364  for i in $f; do
365    case $i in
366    \.) echo "%dir ${TGTDIR}" >> dirs
367      ;;
368    *)  echo "%dir ${TGTDIR}/$i" >> dirs
369      ;;
370    esac
371  done
372
373  # Collect files to go into different packages
374  cp dirs files.gcc
375  cp dirs files.g77
376  cp dirs files.objc
377  cp dirs files.gcj
378  cp dirs files.g++
379
380  TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}"
381  f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
382  for i in $f; do
383    case $i in
384    *lib*.la) rm ${RPM_BUILD_ROOT}/$i ;; # ignore: gcc produces bogus libtool libs
385    *f771) ;;
386    *cc1) ;;
387    *cc1obj) ;;
388    *cc1plus) ;; # ignore: explicitly put into rpm elsewhere
389    *collect2) ;;
390    *libobjc*) echo "$i" >> files.objc ;;
391    *include/objc*) ;;
392    *include/g++*);;
393    *include/c++*);;
394    *adainclude*);;
395    *adalib*);;
396    *gnat1);;
397    *jc1) ;;
398    *jvgenmain) ;;
399    *libstdc++.a) echo "$i" >> files.g++ ;;
400    *libsupc++.a) echo "$i" >> files.g++ ;;
401    *) echo "$i" >> files.gcc ;;
402    esac
403  done
404
405  TGTDIR="%{_prefix}/%{gcc_target}/lib"
406  f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
407  for i in $f; do
408    case $i in
409    *lib*.la) rm ${RPM_BUILD_ROOT}/$i;; # ignore - gcc produces bogus libtool libs
410    *libiberty.a) rm ${RPM_BUILD_ROOT}/$i ;; # ignore - GPL'ed
411# all other files belong to gcc
412    *) echo "$i" >> files.gcc ;;
413    esac
414  done
415
Note: See TracBrowser for help on using the repository browser.