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