1 | |
---|
2 | %define gcc_pkgvers @GCC_VERS@ |
---|
3 | %define gcc_version %{expand:%%(echo "@GCC_VERS@" | sed -e 's,-.*,,')} |
---|
4 | %define gcc_rpmvers %{expand:%%(echo "@GCC_VERS@" | tr - _ )} |
---|
5 | |
---|
6 | %define build_newlib 1 |
---|
7 | |
---|
8 | %if %build_newlib |
---|
9 | %define newlib_version @newlib_version@ |
---|
10 | %define gccnewlib_version gcc%{gcc_version}newlib%{newlib_version} |
---|
11 | %endif |
---|
12 | |
---|
13 | Name: @rpmprefix@@tool_target@-gcc |
---|
14 | Summary: @tool_target@ gcc |
---|
15 | |
---|
16 | Group: Development/Tools |
---|
17 | Version: %gcc_rpmvers |
---|
18 | Release: @GCC_RPMREL@%{?dist} |
---|
19 | License: GPL |
---|
20 | URL: http://gcc.gnu.org |
---|
21 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) |
---|
22 | |
---|
23 | %define _use_internal_dependency_generator 0 |
---|
24 | |
---|
25 | # default languages to build |
---|
26 | %define _cxx 1 |
---|
27 | %define _fortran 0 |
---|
28 | %define _gcj 0 |
---|
29 | %define _gnat 0 |
---|
30 | %define _objc 0 |
---|
31 | %define _libgcj 0 |
---|
32 | |
---|
33 | |
---|
34 | # custom defaults for specific targets |
---|
35 | %if "@tool_target@" == "arm-rtems@osversion@" |
---|
36 | # Gnat lacks arm support |
---|
37 | %define _gnat 0 |
---|
38 | %endif |
---|
39 | |
---|
40 | %if "@tool_target@" == "avr-rtems@osversion@" |
---|
41 | %define _cxx 0 |
---|
42 | %define _fortran 0 |
---|
43 | %define _gcj 0 |
---|
44 | %define _gnat 0 |
---|
45 | %endif |
---|
46 | |
---|
47 | %if "@tool_target@" == "h8300-rtems@osversion@" |
---|
48 | %define _fortran 0 |
---|
49 | %define _gcj 0 |
---|
50 | %define _gnat 0 |
---|
51 | %endif |
---|
52 | |
---|
53 | %if "@tool_target@" == "sh-rtems@osversion@" |
---|
54 | # Triggers an ICE in GCC-4.0.0 |
---|
55 | %define _gnat 0 |
---|
56 | %endif |
---|
57 | |
---|
58 | %if "@tool_target@" == "tic4x-rtems@osversion@" |
---|
59 | %define _cxx 0 |
---|
60 | %define _gnat 0 |
---|
61 | %define _gcj 0 |
---|
62 | %define _fortran 0 |
---|
63 | %endif |
---|
64 | |
---|
65 | %if "@tool_target@" == "i686-pc-mingw32" |
---|
66 | %define _cxx 0 |
---|
67 | %endif |
---|
68 | |
---|
69 | # Allow the user to build arbitrary languages |
---|
70 | %{?_with_cxx:%define _cxx 1} |
---|
71 | %{?_with_fortran:%define _fortran 1} |
---|
72 | %{?_with_gcj:%define _gcj 1} |
---|
73 | %{?_with_gnat:%define _gnat 1} |
---|
74 | %{?_with_objc:%define _objc 1} |
---|
75 | %{?_with_libgcj:%define _libgcj 1} |
---|
76 | |
---|
77 | # Allow the user to suppress building languages |
---|
78 | %{?_without_cxx:%define _cxx 0} |
---|
79 | %{?_without_fortran:%define _fortran 0} |
---|
80 | %{?_without_gcj:%define _gcj 0} |
---|
81 | %{?_without_gnat:%define _gnat 0} |
---|
82 | %{?_without_objc:%define _objc 0} |
---|
83 | %{?_without_libgcj:%define _libgcj 0} |
---|
84 | |
---|
85 | %define build_cxx %_cxx |
---|
86 | %if "%{gcc_version}" >= "4.0.0" |
---|
87 | %define build_f95 %_fortran |
---|
88 | %define build_g77 0 |
---|
89 | %else |
---|
90 | %define build_f95 0 |
---|
91 | %define build_g77 %_fortran |
---|
92 | %endif |
---|
93 | %define build_gnat %_gnat |
---|
94 | %define build_gcj %_gcj |
---|
95 | %define build_objc %_objc |
---|
96 | %define build_libgcj %_libgcj |
---|
97 | |
---|
98 | |
---|
99 | %if %build_gcj |
---|
100 | # Building gcj requires bison and zlib |
---|
101 | BuildRequires: bison |
---|
102 | %endif |
---|
103 | |
---|
104 | BuildRequires: texinfo >= 4.2 |
---|
105 | BuildRequires: @rpmprefix@@tool_target@-binutils |
---|
106 | BuildRequires: @rpmprefix@@tool_target@-sys-root |
---|
107 | |
---|
108 | Requires: @rpmprefix@@tool_target@-binutils |
---|
109 | |
---|
110 | %if "%{_vendor}" == "redhat" |
---|
111 | %if %build_gcj |
---|
112 | BuildRequires: zlib-devel |
---|
113 | %endif |
---|
114 | %if %build_gnat |
---|
115 | # Building gnat requires gnat |
---|
116 | # This really isn't available until RedHat 8.0. How to conditionalize this? |
---|
117 | BuildRequires: gcc-gnat |
---|
118 | # Urgh, building gnat requires the target libc |
---|
119 | BuildRequires: @rpmprefix@@tool_target@-libc < %{newlib_version}-%{release} |
---|
120 | %endif |
---|
121 | %if %build_f95 |
---|
122 | BuildRequires: gmp-devel |
---|
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 | @SOURCES@ |
---|
135 | |
---|
136 | %description |
---|
137 | Cross gcc for @tool_target@. |
---|
138 | |
---|
139 | %prep |
---|
140 | %setup -c -T -n %{name}-%{version} |
---|
141 | |
---|
142 | %setup -q -T -D -n %{name}-%{version} -a0 |
---|
143 | %{?PATCH0:%patch0 -p0} |
---|
144 | |
---|
145 | %if %build_cxx |
---|
146 | %setup -q -T -D -n %{name}-%{version} -a1 |
---|
147 | %{?PATCH1:%patch1 -p0} |
---|
148 | %endif |
---|
149 | |
---|
150 | %if %build_f95 |
---|
151 | %setup -q -T -D -n %{name}-%{version} -a2 |
---|
152 | %{?PATCH2:%patch2 -p0} |
---|
153 | %endif |
---|
154 | |
---|
155 | %if %build_gcj |
---|
156 | %setup -q -T -D -n %{name}-%{version} -a3 |
---|
157 | %{?PATCH3:%patch3 -p0} |
---|
158 | %endif |
---|
159 | |
---|
160 | %if %build_gnat |
---|
161 | %setup -q -T -D -n %{name}-%{version} -a4 |
---|
162 | %{?PATCH4:%patch4 -p0} |
---|
163 | %endif |
---|
164 | |
---|
165 | %if %build_objc |
---|
166 | %setup -T -D -n %{name}-%{version} -a5 |
---|
167 | %{?PATCH5:%patch5 -p0} |
---|
168 | %endif |
---|
169 | |
---|
170 | %if %build_newlib |
---|
171 | %setup -q -T -D -n %{name}-%{version} -a50 |
---|
172 | cd newlib-%{newlib_version} |
---|
173 | %{?PATCH50:%patch50 -p1} |
---|
174 | cd .. |
---|
175 | # Copy the C library into gcc's source tree |
---|
176 | ln -s ../newlib-%{newlib_version}/newlib gcc-%{gcc_version} |
---|
177 | %endif |
---|
178 | |
---|
179 | cd gcc-%{gcc_pkgvers} |
---|
180 | |
---|
181 | case @tool_target@ in |
---|
182 | *rtems*) |
---|
183 | sed -e 's/\(version_string.* = \"[^\"]*\)/\1 (RTEMS gcc-%{gcc_version}-@gcc_patch_version@\/newlib-%{newlib_version}-@newlib_patch_version@-@Release@)/' \ |
---|
184 | gcc/version.c > gcc/version.c~ |
---|
185 | mv gcc/version.c~ gcc/version.c |
---|
186 | ;; |
---|
187 | esac |
---|
188 | |
---|
189 | # Fix timestamps |
---|
190 | contrib/gcc_update --touch |
---|
191 | cd .. |
---|
192 | |
---|
193 | |
---|
194 | %build |
---|
195 | mkdir -p build |
---|
196 | |
---|
197 | cd build |
---|
198 | |
---|
199 | languages="c" |
---|
200 | %if %build_cxx |
---|
201 | languages="$languages,c++" |
---|
202 | %endif |
---|
203 | %if %build_g77 |
---|
204 | languages="$languages,g77" |
---|
205 | %endif |
---|
206 | %if %build_f95 |
---|
207 | languages="$languages,f95" |
---|
208 | %endif |
---|
209 | %if %build_gcj |
---|
210 | languages="$languages,java" |
---|
211 | %endif |
---|
212 | %if %build_objc |
---|
213 | languages="$languages,objc" |
---|
214 | %endif |
---|
215 | %if %build_gnat |
---|
216 | languages="$languages,ada" |
---|
217 | %endif |
---|
218 | %if %build_libgcj |
---|
219 | optargs="--enable-libgcj" |
---|
220 | %endif |
---|
221 | %if "%{_prefix}" != "/usr" |
---|
222 | export PATH="%{_bindir}:${PATH}" |
---|
223 | %endif |
---|
224 | |
---|
225 | CC="%{__cc} ${RPM_OPT_FLAGS}" \ |
---|
226 | ../gcc-%{gcc_pkgvers}/configure \ |
---|
227 | --prefix=%{_prefix} \ |
---|
228 | --bindir=%{_bindir} \ |
---|
229 | --includedir=%{_includedir} \ |
---|
230 | --libdir=%{_libdir} \ |
---|
231 | --mandir=%{_mandir} \ |
---|
232 | --infodir=%{_infodir} \ |
---|
233 | --datadir=%{_datadir} \ |
---|
234 | --build=%_build --host=%_host \ |
---|
235 | --target=@tool_target@ \ |
---|
236 | --with-gnu-as --with-gnu-ld --verbose \ |
---|
237 | --with-newlib \ |
---|
238 | --with-system-zlib \ |
---|
239 | --disable-nls --without-included-gettext \ |
---|
240 | --disable-win32-registry \ |
---|
241 | --enable-version-specific-runtime-libs \ |
---|
242 | --with-sysroot=%{_prefix}/@tool_target@/sys-root \ |
---|
243 | --enable-languages="$languages" $optargs |
---|
244 | |
---|
245 | %if "%_host" != "%_build" |
---|
246 | # Bug in gcc-3.2.1: |
---|
247 | # Somehow, gcc doesn't get syslimits.h right for Cdn-Xs |
---|
248 | mkdir -p gcc/include |
---|
249 | cp ../gcc-%{gcc_pkgvers}/gcc/gsyslimits.h gcc/include/syslimits.h |
---|
250 | %endif |
---|
251 | |
---|
252 | make all |
---|
253 | %if "%{_prefix}" != "/usr" |
---|
254 | make info |
---|
255 | %endif |
---|
256 | cd .. |
---|
257 | |
---|