source: rtems/scripts/gccnewlib/gccnewlib.add @ 5537653

4.104.114.84.95
Last change on this file since 5537653 was 5537653, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 25, 2005 at 12:33:38 PM

2005-04-25 Ralf Corsepius <ralf.corsepius@…>

  • Property mode set to 100644
File size: 11.6 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
14Packager:       ralf.corsepius@rtems.org and joel@OARcorp.com
15
16Version:        gcc%{gcc_version}newlib%{newlib_version}
17
18Source0:        ftp://ftp.gnu.org/pub/gnu/gcc/gcc-%{gcc_version}/gcc-%{gcc_version}@gcc_suffix@
19Source1:        ftp://sources.redhat.com/pub/newlib/newlib-%{newlib_version}@newlib_suffix@
20@PATCH1@
21@PATCH3@
22BuildRequires:  texinfo >= 4.2
23BuildRequires:  %{rpmprefix}%{gcc_target}-binutils
24
25#
26# The original sources are not included in the source RPM.
27# If we included them, then the source RPMs for each target
28# would duplicate MBs of source unnecessarily.  This is
29# a duplication of over 30 MBs of source for each of
30# the more than 10 targets it is possible to build.
31#
32# You can get them yourself from the Internet and copy them to
33# your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR).
34# Or you can try the ftp options of rpm :-)
35#
36%{?!_with_sources:NoSource:     0}
37%{?!_with_sources:NoSource:     1}
38
39# Use rpm -ba --define 'gnat [0|1]' xxx.spec to override building gnat for
40# those targets wanting to support ada.
41
42# default to not building gnat
43%define _gnat   %{?gnat:%gnat}%{!?gnat:0}
44
45# Use rpm -ba --define 'gcj [0|1]' xxx.spec to override building gcj for
46# those targets wanting to support gcj.
47
48# default to not building gcj
49%define _gcj    %{?gcj:%gcj}%{!?gcj:0}
50
51%define build_cxx       %{?cxx:%cxx}%{!?cxx:1}
52%if "%{gcc_version}" >= "4.0.0"
53%define build_f95       %{?f95:%f95}%{!?f95:0}
54%define build_g77       0
55%else
56%define build_f95       0
57%define build_g77       %{?g77:%g77}%{!?g77:0}
58%endif
59%define build_objc      %{?objc:%objc}%{!?objc:0}
60%define build_gcj       0
61%define build_gnat      0
62
63%if "%{gcc_target}" == "arm-rtems@osversion@"
64%define build_gcj       %_gcj
65%endif
66
67%if "%{gcc_target}" == "avr-rtems@osversion@"
68%define build_cxx       0
69%endif
70
71%if "%{gcc_target}" == "tic4x-rtems@osversion@"
72%define build_cxx       0
73%endif
74
75# OBSOLETE: use tic4x instead
76%if "%{gcc_target}" == "c4x-rtems@osversion@"
77%define build_cxx       0
78%endif
79
80# OBSOLETE: use tic4x instead
81%if "%{gcc_target}" == "c4x-rtems@osversion@"
82%define build_cxx       0
83%endif
84
85%if "%{gcc_target}" == "i386-rtems@osversion@"
86%define build_gnat      %_gnat
87%define build_gcj       %_gcj
88%endif
89
90%if "%{gcc_target}" == "m68k-rtems@osversion@"
91%define build_gcj       %_gcj
92%endif
93
94%if "%{gcc_target}" == "mips-rtems@osversion@"
95%define build_gnat      %_gnat
96%define build_gcj       %_gcj
97%endif
98
99%if "%{gcc_target}" == "powerpc-rtems@osversion@"
100%define build_gnat      %_gnat
101%define build_gcj       %_gcj
102%endif
103
104# gcc 3.4.0 is broken for embedded sparc and gnat trips it.
105%if "%{gcc_target}" == "sparc-rtems@osversion@"
106%if "%{gcc_version}" >= "3.4"
107%define build_gnat      0
108%else
109%define build_gnat      %_gnat
110%endif
111%define build_gcj       %_gcj
112%endif
113
114%if %build_gcj
115# Building gcj requires bison and zlib
116BuildRequires:  bison
117%endif
118
119%if "%_vendor" == "redhat"
120%if %build_gcj
121BuildRequires:  zlib-devel
122%endif
123%if %build_gnat
124# Building gnat requires gnat
125# This really isn't available until RedHat 8.0.  How to conditionalize this?
126BuildRequires:  gcc-gnat
127%endif
128%if %build_f95
129BuildRequires: gmp-devel
130%endif
131%endif
132
133%if "%{gcc_version}" >= "3.4"
134%define gcclib %{_libdir}/gcc
135%define gccexec %{_libexecdir}/gcc
136%else
137%define gcclib %{_libdir}/gcc-lib
138%define gccexec %{_libdir}/gcc-lib
139%endif
140
141%description
142RTEMS is an open source operating system for embedded systems.
143
144This is gcc's and newlib C Library's sources with patches for RTEMS.
145
146 The original sources are not included in the source RPM.
147 If we included them, then the source RPMs for each target
148 would duplicate MBs of source unnecessarily.  This is
149 a duplication of over 30 MBs of source for each of
150 the more than 10 targets it is possible to build.
151
152 You can get them yourself from the Internet and copy them to
153 your /usr/src/[redhat|packages]/SOURCES directory ($RPM_SOURCE_DIR).
154 Or you can try the ftp options of rpm :-)
155
156%prep
157# untar the sources inside %{gcc_target}-gcc-newlib
158%setup -c -T -n %{name}-%{version} -a0 -a1
159
160cd gcc-%{gcc_version}
161%{?PATCH0:%patch0 -p1}
162cd ..
163cd newlib-%{newlib_version}
164%{?PATCH1:%patch1 -p1}
165cd ..
166
167  cd gcc-%{gcc_version}
168    sed -e 's/\(version_string.* = \"[^\"]*\)/\1 (RTEMS gcc-%{gcc_version}-@gcc_patch_version@\/newlib-%{newlib_version}-@newlib_patch_version@-@Release@)/' \
169    gcc/version.c > gcc/version.c~
170    mv gcc/version.c~  gcc/version.c
171
172  # Fix timestamps
173    contrib/gcc_update --touch
174  cd ..
175
176  # Copy the C library into gcc's source tree
177  ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version}
178  test -d build || mkdir build
179
180%build
181  cd build
182
183  languages="c"
184%if %build_cxx
185  languages="$languages,c++"
186%endif
187%if %build_g77
188  languages="$languages,g77"
189%endif
190%if %build_f95
191  languages="$languages,f95"
192%endif
193%if %build_gcj
194  languages="$languages,java"
195%endif
196%if %build_objc
197  languages="$languages,objc"
198%endif
199%if %build_gnat
200  languages="$languages,ada"
201%endif
202
203  export PATH="%{_bindir}:${PATH}"
204  ../gcc-%{gcc_version}/configure \
205    --prefix=%{_prefix} \
206    --bindir=%{_bindir} \
207    --includedir=%{_includedir} \
208    --libdir=%{_libdir} \
209    --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  rm -rf $RPM_BUILD_ROOT
269
270  cd build
271# Bug in gcc-2.95.1: It doesn't build this installation directory
272# If it doesn't find it, gcc doesn't install %{gcc_target}/bin/gcc
273%if "%{gcc_version}" < "3.0"
274  mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{gcc_target}/bin
275%endif
276
277  make prefix=$RPM_BUILD_ROOT%{_prefix} \
278    bindir=$RPM_BUILD_ROOT%{_bindir} \
279    libdir=$RPM_BUILD_ROOT%{_libdir} \
280    includedir=$RPM_BUILD_ROOT%{_includedir} \
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    libdir=$RPM_BUILD_ROOT%{_libdir} \
288    includedir=$RPM_BUILD_ROOT%{_includedir} \
289    mandir=$RPM_BUILD_ROOT%{_mandir} \
290    infodir=$RPM_BUILD_ROOT%{_infodir} \
291    install-info
292  # cd back to build/
293  cd ../..
294
295%if %build_gnat
296# Install a copy of gcc as gnatgcc
297# Enables us to mix different versions of gnat and gnatgcc
298  rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gnatgcc%{_exeext}
299  ln $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gcc%{_exeext} \
300    $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gnatgcc%{_exeext}
301%endif
302
303  # Bug in gcc-3.x: It puts the build dirs into *.la files
304
305  # host library
306  rm -f  ${RPM_BUILD_ROOT}%{_prefix}/lib/libiberty.a
307
308  # We use the version from binutils
309  rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-c++filt%{_exeext}
310
311  # We don't ship info/dir
312  rm -f $RPM_BUILD_ROOT%{_infodir}/dir
313
314%if %build_f95
315#  # Bug in gcc-4.0.0pre
316#  mv $RPM_BUILD_ROOT%{_bindir}/gfortran $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-gfortran
317%endif
318
319%if "%{gcc_version}" >= "3.4"
320  # Bug in gcc-3.4.0pre
321  rm -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-%{gcc_target}-gcjh%{_exeext}
322%endif
323
324%if "%{gcc_version}" >= "3.3"
325  # Bug in gcc-3.3.x/gcc-3.4.x: Despite we don't need fixincludes, it installs
326  # the fixinclude-install-tools
327  rm -rf ${RPM_BUILD_ROOT}%{gcclib}/%{gcc_target}/%{gcc_version}/install-tools
328  rm -rf ${RPM_BUILD_ROOT}%{gccexec}/%{gcc_target}/%{gcc_version}/install-tools
329%endif
330
331%if "%{gcc_version}" < "3.0"
332  # Bug in gcc-2.95.x: It bogusly tries to share cpp for all targets.
333  # Rename it to target_alias-cpp
334  if test -f $RPM_BUILD_ROOT%{_bindir}/cpp%{_exeext};
335  then
336    mv $RPM_BUILD_ROOT%{_bindir}/cpp%{_exeext} \
337      $RPM_BUILD_ROOT%{_bindir}/%{gcc_target}-cpp%{_exeext}
338  fi
339%endif
340
341  # gzip info files
342  ls $RPM_BUILD_ROOT%{_infodir}/*.info \
343    $RPM_BUILD_ROOT%{_infodir}/*.info-? \
344    $RPM_BUILD_ROOT%{_infodir}/*.info-?? \
345  | while read a; do \
346    gzip -9qf $a 2>/dev/null; \
347  done
348
349  # gzip man pages
350  gzip -9qf $RPM_BUILD_ROOT%{_mandir}/man?/*.? 2>/dev/null
351
352  rm -f dirs ;
353  echo "%defattr(-,root,root)" >> dirs
354  echo "%dir %{_prefix}/lib" >> dirs ;
355  echo "%dir %{gcclib}" >> dirs ;
356  echo "%dir %{gcclib}/%{gcc_target}" >> dirs ;
357
358  # Collect multilib subdirectories
359  f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'`
360
361  TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}"
362  for i in $f; do
363    case $i in
364    \.) echo "%dir ${TGTDIR}" >> dirs
365      ;;
366    *)  echo "%dir ${TGTDIR}/$i" >> dirs
367      ;;
368    esac
369  done
370
371  TGTDIR="%{_prefix}/%{gcc_target}/lib"
372  for i in $f; do
373    case $i in
374    \.) echo "%dir ${TGTDIR}" >> dirs
375      ;;
376    *)  echo "%dir ${TGTDIR}/$i" >> dirs
377      ;;
378    esac
379  done
380
381  # Collect files to go into different packages
382  cp dirs files.gcc
383  cp dirs files.g77
384  cp dirs files.gfortran
385  cp dirs files.objc
386  cp dirs files.gcj
387  cp dirs files.g++
388
389  TGTDIR="%{gcclib}/%{gcc_target}/%{gcc_version}"
390  f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
391  for i in $f; do
392    case $i in
393    *lib*.la) rm ${RPM_BUILD_ROOT}/$i ;; # ignore: gcc produces bogus libtool libs
394    *f771) ;;
395    *f951) ;;
396    *cc1) ;;
397    *cc1obj) ;;
398    *cc1plus) ;; # ignore: explicitly put into rpm elsewhere
399    *collect2) ;;
400    *libobjc*) echo "$i" >> files.objc ;;
401    *include/objc*) ;;
402    *include/g++*);;
403    *include/c++*);;
404    *adainclude*);;
405    *adalib*);;
406    *gnat1);;
407    *jc1) ;;
408    *jvgenmain) ;;
409    *libgfortran*.a) echo "$i" >> files.gfortran ;;
410    *libstdc++.a) echo "$i" >> files.g++ ;;
411    *libsupc++.a) echo "$i" >> files.g++ ;;
412    *) echo "$i" >> files.gcc ;;
413    esac
414  done
415
416  TGTDIR="%{_prefix}/%{gcc_target}/lib"
417  f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
418  for i in $f; do
419    case $i in
420    *lib*.la) rm ${RPM_BUILD_ROOT}/$i;; # ignore - gcc produces bogus libtool libs
421    *libiberty.a) rm ${RPM_BUILD_ROOT}/$i ;; # ignore - GPL'ed
422# all other files belong to gcc
423    *) echo "$i" >> files.gcc ;;
424    esac
425  done
426
Note: See TracBrowser for help on using the repository browser.