1 | # |
---|
2 | # spec file for building gcc for rtems |
---|
3 | # |
---|
4 | # Copyright (c) 1999,2000,2001 OARCorp, Huntsville, AL |
---|
5 | # |
---|
6 | # please send bugfixes or comments to joel@OARcorp.com |
---|
7 | # |
---|
8 | |
---|
9 | %define _prefix @prefix@ |
---|
10 | |
---|
11 | Vendor: OAR Corporation |
---|
12 | Distribution: Linux |
---|
13 | Name: @target_alias@-gcc-newlib |
---|
14 | Summary: gcc and newlib C Library for @target_alias@. |
---|
15 | Group: rtems |
---|
16 | Release: @Release@ |
---|
17 | License: gcc is GPL/LGPL ; newlib no has restrictions on run-time usage |
---|
18 | |
---|
19 | Autoreqprov: on |
---|
20 | Packager: corsepiu@faw.uni-ulm.de and joel@OARcorp.com |
---|
21 | |
---|
22 | Version: gcc@gcc_version@newlib@newlib_version@ |
---|
23 | # gcc 3.x and gcc 2.9 |
---|
24 | Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.gz |
---|
25 | # Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.bz2 |
---|
26 | # gcc 2.95.x |
---|
27 | # Source0: ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.bz2 |
---|
28 | Source1: ftp://sources.redhat.com/pub/newlib/newlib-@newlib_version@.tar.gz |
---|
29 | @PATCH1@ |
---|
30 | @PATCH3@ |
---|
31 | Buildroot: %{_tmppath}/%{name} |
---|
32 | |
---|
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 | NoSource: 0 |
---|
45 | 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 | %if "@gcc_version@" >= "3.2" |
---|
51 | # default to building gnat |
---|
52 | %define _gnat %{?gnat:%gnat}%{!?gnat:1} |
---|
53 | %else |
---|
54 | # default to not building gnat |
---|
55 | %define _gnat %{?gnat:%gnat}%{!?gnat:0} |
---|
56 | %endif |
---|
57 | |
---|
58 | %define build_cxx 1 |
---|
59 | %define build_g77 0 |
---|
60 | %define build_objc 0 |
---|
61 | %define build_gcj 0 |
---|
62 | %define build_gnat 0 |
---|
63 | |
---|
64 | %if "@target_alias@" == "arm-rtems" |
---|
65 | %define build_gcj 1 |
---|
66 | %endif |
---|
67 | |
---|
68 | %if "@target_alias@" == "c4x-rtems" |
---|
69 | %define build_cxx 0 |
---|
70 | %endif |
---|
71 | |
---|
72 | %if "@target_alias@" == "i386-rtems" |
---|
73 | %define build_gnat %_gnat |
---|
74 | %define build_gcj 1 |
---|
75 | %endif |
---|
76 | |
---|
77 | %if "@target_alias@" == "i960-rtems" |
---|
78 | %define build_cxx 0 |
---|
79 | %endif |
---|
80 | |
---|
81 | %if "@target_alias@" == "m68k-rtems" |
---|
82 | %define build_gcj 1 |
---|
83 | %endif |
---|
84 | |
---|
85 | %if "@target_alias@" == "mips-rtems" |
---|
86 | %define build_gcj 1 |
---|
87 | %endif |
---|
88 | |
---|
89 | %if "@target_alias@" == "powerpc-rtems" |
---|
90 | %define build_gnat %_gnat |
---|
91 | %define build_gcj 1 |
---|
92 | %endif |
---|
93 | |
---|
94 | %if "@target_alias@" == "sparc-rtems" |
---|
95 | %define build_gnat %_gnat |
---|
96 | %define build_gcj 1 |
---|
97 | %endif |
---|
98 | |
---|
99 | %description |
---|
100 | RTEMS is an open source operating system for embedded systems. |
---|
101 | |
---|
102 | This is gcc's and newlib C Library's sources with patches for RTEMS. |
---|
103 | |
---|
104 | The original sources are not included in the source RPM. |
---|
105 | If we included them, then the source RPMs for each target |
---|
106 | would duplicate MBs of source unnecessarily. This is |
---|
107 | a duplication of over 30 MBs of source for each of |
---|
108 | the more than 10 targets it is possible to build. |
---|
109 | |
---|
110 | You can get them yourself from the Internet and copy them to |
---|
111 | your /usr/src/[redhat|packages]/SOURCES directory ($RPM_SOURCE_DIR). |
---|
112 | Or you can try the ftp options of rpm :-) |
---|
113 | |
---|
114 | %prep |
---|
115 | # untar the sources inside @target_alias@-gcc-newlib |
---|
116 | %setup -c -T -n %{name} -a0 -a1 |
---|
117 | |
---|
118 | @PATCH2@ |
---|
119 | @PATCH4@ |
---|
120 | |
---|
121 | # Fix timestamps |
---|
122 | cd gcc-@gcc_version@ |
---|
123 | contrib/gcc_update --touch |
---|
124 | cd .. |
---|
125 | |
---|
126 | # Copy the C library into gcc's source tree |
---|
127 | ln -s ../newlib-@newlib_version@/newlib gcc-@gcc_version@ |
---|
128 | test -d build || mkdir build |
---|
129 | |
---|
130 | %build |
---|
131 | cd build |
---|
132 | |
---|
133 | # HACK: This doesn't work |
---|
134 | # %if "%{_target_os}" != "%{_build_os}" |
---|
135 | # CONFIGURE_ARGS="--build=%{_build} --host=%{_target}" |
---|
136 | # %endif |
---|
137 | # ALERT: GCJ would be better if we could add this flag and build |
---|
138 | # it's libraries but this code isn't ready to be embedded. |
---|
139 | # libgcj_flag="--enable-libgcj" |
---|
140 | |
---|
141 | languages="c" |
---|
142 | %if %build_cxx |
---|
143 | languages="$languages,c++" |
---|
144 | %endif |
---|
145 | %if %build_g77 |
---|
146 | languages="$languages,g77" |
---|
147 | %endif |
---|
148 | %if %build_gcj |
---|
149 | languages="$languages,java" |
---|
150 | %endif |
---|
151 | %if %build_objc |
---|
152 | languages="$languages,objc" |
---|
153 | %endif |
---|
154 | %if %build_gnat |
---|
155 | languages="$languages,ada" |
---|
156 | %endif |
---|
157 | ../gcc-@gcc_version@/configure $CONFIGURE_ARGS --target=@target_alias@ \ |
---|
158 | --with-gnu-as --with-gnu-ld --with-newlib --verbose \ |
---|
159 | --with-system-zlib --disable-nls \ |
---|
160 | --enable-version-specific-runtime-libs \ |
---|
161 | --enable-threads=rtems --prefix=%{_prefix} \ |
---|
162 | --enable-languages=$languages ${libgcj_flag} |
---|
163 | %if %build_gnat |
---|
164 | cd ../gcc-@gcc_version@/gcc/ada |
---|
165 | touch treeprs.ads [es]info.h nmake.ad[bs] |
---|
166 | cd ../../../build |
---|
167 | %endif |
---|
168 | make all |
---|
169 | %if %build_gnat |
---|
170 | # This gnat configuration is crap :( |
---|
171 | |
---|
172 | # This is what is documented, but it doesn't work for me (RC) |
---|
173 | # make gnatlib_and_tools |
---|
174 | make -C gcc cross-gnattools |
---|
175 | make -C gcc ada.all.cross |
---|
176 | |
---|
177 | # This should work, but doesn't. |
---|
178 | # make -C gcc gnatlib |
---|
179 | |
---|
180 | # This is what gcc/ada/Makefile.in contains by default, |
---|
181 | # but what we override below |
---|
182 | GNATLIBCFLAGS="-g -O2" |
---|
183 | # Let gnatlib building find newlib's headers |
---|
184 | GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/@target_alias@/newlib/targ-include" |
---|
185 | GNATLIBCFLAGS="$GNATLIBCFLAGS -isystem `pwd`/../newlib-@newlib_version@/newlib/libc/include" |
---|
186 | # Without this xgcc doesn't find the target's binutils. |
---|
187 | GNATLIBCFLAGS="$GNATLIBCFLAGS -B%{_prefix}/@target_alias@/bin/" |
---|
188 | make -C gcc GNATLIBCFLAGS="${GNATLIBCFLAGS}" gnatlib |
---|
189 | %endif |
---|
190 | make info |
---|
191 | |
---|
192 | %install |
---|
193 | cd build |
---|
194 | # Bug in gcc-2.95.1: It doesn't build this installation directory |
---|
195 | # If it doesn't find it, gcc doesn't install @target_alias@/bin/gcc |
---|
196 | %if "@gcc_version@" < "3.0" |
---|
197 | ../gcc-@gcc_version@/mkinstalldirs \ |
---|
198 | $RPM_BUILD_ROOT%{_prefix}/@target_alias@/bin |
---|
199 | %endif |
---|
200 | |
---|
201 | make prefix=$RPM_BUILD_ROOT%{_prefix} \ |
---|
202 | bindir=$RPM_BUILD_ROOT%{_bindir} install |
---|
203 | cd @target_alias@/newlib |
---|
204 | make prefix=$RPM_BUILD_ROOT%{_prefix} \ |
---|
205 | bindir=$RPM_BUILD_ROOT%{_bindir} install-info |
---|
206 | # cd back to build/ |
---|
207 | cd ../.. |
---|
208 | |
---|
209 | %if %build_gnat |
---|
210 | # Install a copy of gcc as gnatgcc |
---|
211 | # Enables us to mix different versions of gnat and gnatgcc |
---|
212 | rm -f $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gnatgcc@exe_ext@ |
---|
213 | ln $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gcc@exe_ext@ \ |
---|
214 | $RPM_BUILD_ROOT%{_bindir}/@target_alias@-gnatgcc@exe_ext@ |
---|
215 | %endif |
---|
216 | |
---|
217 | # Bug in gcc-3.x: It puts the build dirs into *.la files |
---|
218 | files=`find ${RPM_BUILD_ROOT}%{_prefix}/@target_alias@/lib -name '*.la'` |
---|
219 | test -n "$files" && for i in $files; do |
---|
220 | rm -f $i |
---|
221 | done |
---|
222 | |
---|
223 | %if "@gcc_version@" < "3.0" |
---|
224 | # Bug in gcc-2.95.x: It bogusly tries to share cpp for all targets. |
---|
225 | # Rename it to target_alias-cpp |
---|
226 | if test -f $RPM_BUILD_ROOT%{_prefix}/bin/cpp@exe_ext@; |
---|
227 | then |
---|
228 | mv $RPM_BUILD_ROOT%{_prefix}/bin/cpp@exe_ext@ \ |
---|
229 | $RPM_BUILD_ROOT%{_prefix}/bin/@target_alias@-cpp@exe_ext@ |
---|
230 | fi |
---|
231 | %endif |
---|
232 | |
---|
233 | # gzip info files |
---|
234 | gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info 2>/dev/null |
---|
235 | gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info-? 2>/dev/null |
---|
236 | gzip -f $RPM_BUILD_ROOT%{_prefix}/info/*.info-?? 2>/dev/null |
---|
237 | |
---|
238 | rm -f dirs ; |
---|
239 | echo "%dir %{_prefix}/lib" >> dirs ; |
---|
240 | echo "%dir %{_prefix}/lib/gcc-lib" >> dirs ; |
---|
241 | echo "%dir %{_prefix}/lib/gcc-lib/@target_alias@" >> dirs ; |
---|
242 | |
---|
243 | # Collect multilib subdirectories |
---|
244 | f=`gcc/xgcc -Bgcc/ --print-multi-lib | sed -e 's,;.*$,,'` |
---|
245 | |
---|
246 | TGTDIR="%{_prefix}/lib/gcc-lib/@target_alias@/@gcc_version@" |
---|
247 | for i in $f; do |
---|
248 | case $i in |
---|
249 | \.) echo "%dir ${TGTDIR}" >> dirs |
---|
250 | ;; |
---|
251 | *) echo "%dir ${TGTDIR}/$i" >> dirs |
---|
252 | ;; |
---|
253 | esac |
---|
254 | done |
---|
255 | |
---|
256 | TGTDIR="%{_prefix}/@target_alias@/lib" |
---|
257 | for i in $f; do |
---|
258 | case $i in |
---|
259 | \.) echo "%dir ${TGTDIR}" >> dirs |
---|
260 | ;; |
---|
261 | *) echo "%dir ${TGTDIR}/$i" >> dirs |
---|
262 | ;; |
---|
263 | esac |
---|
264 | done |
---|
265 | |
---|
266 | # Collect files to go into different packages |
---|
267 | cp dirs files.gcc |
---|
268 | cp dirs files.g77 |
---|
269 | cp dirs files.objc |
---|
270 | cp dirs files.gcj |
---|
271 | cp dirs files.g++ |
---|
272 | |
---|
273 | TGTDIR="%{_prefix}/lib/gcc-lib/@target_alias@/@gcc_version@" |
---|
274 | f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`; |
---|
275 | for i in $f; do |
---|
276 | case $i in |
---|
277 | *lib*.la);; # ignore: gcc produces bogus libtool libs |
---|
278 | *f771) ;; |
---|
279 | *cc1obj) ;; |
---|
280 | *libobjc*) echo "$i" >> files.objc ;; |
---|
281 | *include/objc*) ;; |
---|
282 | *include/g++*);; |
---|
283 | *include/c++*);; |
---|
284 | *adainclude*);; |
---|
285 | *adalib*);; |
---|
286 | *gnat1);; |
---|
287 | *jc1) ;; |
---|
288 | *jvgenmain) ;; |
---|
289 | *cc1plus) ;; # ignore: explicitly put into rpm elsewhere |
---|
290 | *libstdc++.a) echo "$i" >> files.g++ ;; |
---|
291 | *libsupc++.a) echo "$i" >> files.g++ ;; |
---|
292 | *) echo "$i" >> files.gcc ;; |
---|
293 | esac |
---|
294 | done |
---|
295 | |
---|
296 | TGTDIR="%{_prefix}/@target_alias@/lib" |
---|
297 | f=`find ${RPM_BUILD_ROOT}${TGTDIR} ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`; |
---|
298 | for i in $f; do |
---|
299 | case $i in |
---|
300 | *lib*.la);; # ignore - gcc produces bogus libtool libs |
---|
301 | *libiberty.a) ;; # ignore - GPL'ed |
---|
302 | # all other files belong to gcc |
---|
303 | *) echo "$i" >> files.gcc ;; |
---|
304 | esac |
---|
305 | done |
---|
306 | |
---|
307 | %clean |
---|
308 | # let rpm --clean remove BuildRoot iif using the default BuildRoot |
---|
309 | test "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}" && \ |
---|
310 | rm -rf $RPM_BUILD_ROOT |
---|