summaryrefslogtreecommitdiffstats
path: root/scripts/gcc3newlib/gccnewlib.add
blob: 0116502ca28b34fd02c1531a7d6562fbda25fc86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#
# spec file for building gcc for rtems
# 
# Copyright  (c) 1999,2000,2001,2002,2003 OARCorp, Huntsville, AL
#
# please send bugfixes or comments to joel@OARcorp.com
#

%define	_prefix	@prefix@
%define _defaultbuildroot %{_tmppath}/%{name}-%{version}

Vendor:       OAR Corporation
Distribution: Linux
Name:         @target_alias@-gcc-newlib
Summary:      gcc and newlib C Library for @target_alias@.
Group:	      rtems
Release:      @Release@
License:      gcc is GPL/LGPL ; newlib no has restrictions on run-time usage

Autoreqprov:  	on
Packager:     	corsepiu@faw.uni-ulm.de and joel@OARcorp.com

Version:      	gcc@gcc_version@newlib@newlib_version@
# gcc 3.x and gcc 2.9
Source0:      ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.gz
# Source0:      ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.bz2
# gcc 2.95.x
# Source0:	ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.bz2
Source1:	ftp://sources.redhat.com/pub/newlib/newlib-@newlib_version@.tar.gz
@PATCH1@
@PATCH3@
Buildroot:	%{_defaultbuildroot}
BuildPreReq:	texinfo >= 4.2
BuildPreReq:	@target_alias@-binutils
#
# The original sources are not included in the source RPM.
# If we included them, then the source RPMs for each target
# would duplicate MBs of source unnecessarily.  This is 
# a duplication of over 30 MBs of source for each of
# the more than 10 targets it is possible to build.
#
# You can get them yourself from the Internet and copy them to
# your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR).
# Or you can try the ftp options of rpm :-)
#
NoSource:	0
NoSource:	1

# Use rpm -ba --define 'gnat [0|1]' xxx.spec to override building gnat for 
# those targets wanting to support ada.

%if "@gcc_version@" >= "3.2"
# default to building gnat
%define _gnat	%{?gnat:%gnat}%{!?gnat:1}
%else
# default to not building gnat
%define _gnat	%{?gnat:%gnat}%{!?gnat:0}
%endif

%define build_cxx 	1
%define build_g77 	0
%define build_objc	0
%define build_gcj	0
%define build_gnat	0

%if "@target_alias@" == "arm-rtems"
%define build_gcj 	1
%endif

%if "@target_alias@" == "c4x-rtems"
%define build_cxx	0
%endif

%if "@target_alias@" == "i386-rtems"
%define build_gnat      %_gnat
%define build_gcj 	1
%endif

%if "@target_alias@" == "i960-rtems"
%define build_cxx	0
%endif

%if "@target_alias@" == "m68k-rtems"
%define build_gcj 	1
%endif

%if "@target_alias@" == "mips-rtems"
%define build_gnat      %_gnat
%define build_gcj 	1
%endif

%if "@target_alias@" == "powerpc-rtems"
%define build_gnat      %_gnat
%define build_gcj 	1
%endif

%if "@target_alias@" == "sparc-rtems"
%define build_gnat      %_gnat
%define build_gcj 	1
%endif

%if %build_gcj
# Building gcj requires bison and zlib
BuildPreReq:	bison
%if "%_vendor" == "redhat"
BuildPreReq:	zlib-devel
%endif
%endif

%if %build_gnat
# Building gnat requires gnat
%if "%_vendor" == "redhat"
BuildPreReq:	gcc-gnat
%endif
%endif

%description
RTEMS is an open source operating system for embedded systems.

This is gcc's and newlib C Library's sources with patches for RTEMS.

 The original sources are not included in the source RPM.
 If we included them, then the source RPMs for each target
 would duplicate MBs of source unnecessarily.  This is 
 a duplication of over 30 MBs of source for each of
 the more than 10 targets it is possible to build.

 You can get them yourself from the Internet and copy them to
 your /usr/src/[redhat|packages]/SOURCES directory ($RPM_SOURCE_DIR).
 Or you can try the ftp options of rpm :-)

%prep
# untar the sources inside @target_alias@-gcc-newlib
%setup -c -T -n %{name} -a0 -a1

@PATCH2@
@PATCH4@

  cd gcc-@gcc_version@
    sed -e 's/\(version_string = \"[^\"]*\)/\1 (OAR Corporation gcc-@gcc_version@-@gcc_patch_version@\/newlib-@newlib_version@-@newlib_patch_version@ @Release@)/' \
    gcc/version.c > gcc/version.c~
    mv gcc/version.c~  gcc/version.c 

  # Fix timestamps
    contrib/gcc_update --touch
  cd ..

  # Copy the C library into gcc's source tree
  ln -s ../newlib-@newlib_version@/newlib gcc-@gcc_version@
  test -d build || mkdir build

%build
  cd build

# HACK: This doesn't work
# %if "%{_target_os}" != "%{_build_os}"
#    CONFIGURE_ARGS="--build=%{_build} --host=%{_target}"
# %endif
#  ALERT: GCJ would be better if we could add this flag and build
#  it's libraries but this code isn't ready to be embedded.
#  libgcj_flag="--enable-libgcj"

  languages="c"
%if %build_cxx
  languages="$languages,c++"
%endif
%if %build_g77
  languages="$languages,g77"
%endif
%if %build_gcj
  languages="$languages,java"
%endif
%if %build_objc
  languages="$languages,objc"
%endif
%if %build_gnat
  languages="$languages,ada"
%endif
  ../gcc-@gcc_version@/configure $CONFIGURE_ARGS --target=@target_alias@ \
    --with-gnu-as --with-gnu-ld --with-newlib --verbose \
    --with-system-zlib --disable-nls \
    --enable-version-specific-runtime-libs \
    --enable-threads=rtems --prefix=%{_prefix} \
    --enable-languages=$languages ${libgcj_flag}
%if %build_gnat
  cd ../gcc-@gcc_version@/gcc/ada
  touch treeprs.ads [es]info.h nmake.ad[bs]
  cd ../../../build
%endif
  make all
%if %build_gnat
# This gnat configuration is crap :(

# This is what is documented, but it doesn't work for me (RC)
#  make gnatlib_and_tools
  make -C gcc cross-gnattools
  make -C gcc ada.all.cross

# This should work, but doesn't.
#  make -C gcc gnatlib 

# This is what gcc/ada/Makefile.in contains by default, 
# but what we override below
  GNATLIBCFLAGS="-g -O2"
# Let gnatlib building find newlib's headers
  GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/@target_alias@/newlib/targ-include"
  GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/../newlib-@newlib_version@/newlib/libc/include"
# Without this xgcc doesn't find the target's binutils.
  GNATLIBCFLAGS="$GNATLIBCFLAGS -B%{_prefix}/@target_alias@/bin/"
%if "@target_alias@" == "mips-rtems"
  GNATLIBCFLAGS="$GNATLIBCFLAGS -G0"
%endif
  make -C gcc GNATLIBCFLAGS="${GNATLIBCFLAGS}" gnatlib
%endif
  make info

%install
  cd build
# Bug in gcc-2.95.1: It doesn't build this installation directory
# If it doesn't find it, gcc doesn't install @target_alias@/bin/gcc
%if "@gcc_version@" < "3.0"
  ../gcc-@gcc_version@/mkinstalldirs \
    $RPM_BUILD_ROOT%{_prefix}/@target_alias@/bin
%endif

  make prefix=$RPM_BUILD_ROOT%{_prefix} \
    bindir=$RPM_BUILD_ROOT%{_bindir} install
  cd @target_alias@/newlib
  make prefix=$RPM_BUILD_ROOT%{_prefix} \
    bindir=$RPM_BUILD_ROOT%{_bindir} install-info
  # cd back to build/
  cd ../..

%if %build_gnat
# Install a copy of gcc as gnatgcc
# Enables us to mix different versions of gnat and gnatgcc
  rm -f $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gnatgcc@exe_ext@
  ln $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gcc@exe_ext@ \
    $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gnatgcc@exe_ext@
%endif

  # Bug in gcc-3.x: It puts the build dirs into *.la files

  # host library
  rm -f  ${RPM_BUILD_ROOT}%{_prefix}/lib/libiberty.a

%if "@gcc_version@" < "3.0"
  # Bug in gcc-2.95.x: It bogusly tries to share cpp for all targets.
  # Rename it to target_alias-cpp
  if test -f $RPM_BUILD_ROOT%{_prefix}/bin/cpp@exe_ext@;
  then
    mv $RPM_BUILD_ROOT%{_prefix}/bin/cpp@exe_ext@ \
      $RPM_BUILD_ROOT%{_prefix}/bin/@target_alias@-cpp@exe_ext@
  fi
%endif

  # gzip info files
  gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info 2>/dev/null
  gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info-? 2>/dev/null
  gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info-?? 2>/dev/null

  rm -f dirs ;
  echo "%defattr(-,root,root)" >> dirs
  echo "%dir %{_prefix}/lib" >> dirs ;
  echo "%dir %{_prefix}/lib/gcc-lib" >> dirs ;
  echo "%dir %{_prefix}/lib/gcc-lib/@target_alias@" >> dirs ;

  # Collect multilib subdirectories
  f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'`

  TGTDIR="%{_prefix}/lib/gcc-lib/@target_alias@/@gcc_version@"
  for i in $f; do
    case $i in
    \.) echo "%dir ${TGTDIR}" >> dirs
      ;;
    *)  echo "%dir ${TGTDIR}/$i" >> dirs
      ;;
    esac
  done

  TGTDIR="%{_prefix}/@target_alias@/lib"
  for i in $f; do
    case $i in
    \.) echo "%dir ${TGTDIR}" >> dirs
      ;;
    *)  echo "%dir ${TGTDIR}/$i" >> dirs
      ;;
    esac
  done

  # Collect files to go into different packages
  cp dirs files.gcc
  cp dirs files.g77
  cp dirs files.objc
  cp dirs files.gcj
  cp dirs files.g++

  TGTDIR="%{_prefix}/lib/gcc-lib/@target_alias@/@gcc_version@"
  f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
  for i in $f; do
    case $i in
    *lib*.la) rm ${RPM_BUILD_ROOT}/$i ;; # ignore: gcc produces bogus libtool libs
    *f771) ;;
    *cc1obj) ;;
    *libobjc*) echo "$i" >> files.objc ;;
    *include/objc*) ;;
    *include/g++*);;
    *include/c++*);;
    *adainclude*);;
    *adalib*);;
    *gnat1);;
    *jc1) ;;
    *jvgenmain) ;;
    *cc1plus) ;; # ignore: explicitly put into rpm elsewhere
    *libstdc++.a) echo "$i" >> files.g++ ;;
    *libsupc++.a) echo "$i" >> files.g++ ;;
    *) echo "$i" >> files.gcc ;;
    esac
  done

  TGTDIR="%{_prefix}/@target_alias@/lib"
  f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
  for i in $f; do
    case $i in
    *lib*.la) rm ${RPM_BUILD_ROOT}/$i;; # ignore - gcc produces bogus libtool libs
    *libiberty.a) rm ${RPM_BUILD_ROOT}/$i ;; # ignore - GPL'ed
# all other files belong to gcc
    *) echo "$i" >> files.gcc ;; 
    esac
  done

%clean
# let rpm --clean remove BuildRoot iif using the default BuildRoot
  test "$RPM_BUILD_ROOT" = "%{_defaultbuildroot}" && \
    rm -rf $RPM_BUILD_ROOT