source: rtems/scripts/gccnewlib/gccnewlib.add @ 664d8b71

4.104.114.84.95
Last change on this file since 664d8b71 was 664d8b71, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 12, 2005 at 3:17:39 PM

New.

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