|
1 ## |
|
2 ## gcc.spec -- OpenPKG RPM Package Specification |
|
3 ## Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/> |
|
4 ## |
|
5 ## Permission to use, copy, modify, and distribute this software for |
|
6 ## any purpose with or without fee is hereby granted, provided that |
|
7 ## the above copyright notice and this permission notice appear in all |
|
8 ## copies. |
|
9 ## |
|
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
|
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
|
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
21 ## SUCH DAMAGE. |
|
22 ## |
|
23 |
|
24 # package version |
|
25 %define V_full 4.5.2 |
|
26 %define V_comp %nil |
|
27 |
|
28 # package information |
|
29 Name: gcc |
|
30 Summary: GNU Compiler Collection |
|
31 URL: http://gcc.gnu.org/ |
|
32 Vendor: Free Software Foundation |
|
33 Packager: OpenPKG Foundation e.V. |
|
34 Distribution: OpenPKG Community |
|
35 Class: CORE |
|
36 Group: Compiler |
|
37 License: GPL |
|
38 Version: %{V_full} |
|
39 Release: 20101221 |
|
40 |
|
41 # package options |
|
42 %option with_binutils yes |
|
43 %option with_cxx yes |
|
44 %option with_objc no |
|
45 %option with_java no |
|
46 %option with_fortran no |
|
47 %option with_optimize yes |
|
48 %option with_profile no |
|
49 %option with_threads yes |
|
50 %option with_multilib no |
|
51 |
|
52 # list of sources |
|
53 Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-core-%{V_full}.tar.bz2 |
|
54 Source1: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-g++-%{V_full}.tar.bz2 |
|
55 Source2: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-objc-%{V_full}.tar.bz2 |
|
56 Source3: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-java-%{V_full}.tar.bz2 |
|
57 Source4: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-fortran-%{V_full}.tar.bz2 |
|
58 Patch0: gcc.patch |
|
59 |
|
60 # build information |
|
61 BuildPreReq: OpenPKG, openpkg >= 20100101, make |
|
62 PreReq: OpenPKG, openpkg >= 20100101 |
|
63 %if "%{with_binutils}" == "yes" |
|
64 BuildPreReq: binutils >= 2.14 |
|
65 PreReq: binutils >= 2.14 |
|
66 %endif |
|
67 BuildPreReq: mpc, mpfr, gmp |
|
68 PreReq: mpc, mpfr, gmp |
|
69 %if "%{with_cxx}" == "yes" |
|
70 BuildPreReq: libiconv |
|
71 PreReq: libiconv |
|
72 %endif |
|
73 %if "%{with_java}" == "yes" |
|
74 BuildPreReq: zlib |
|
75 PreReq: zlib |
|
76 %endif |
|
77 |
|
78 %description |
|
79 The GNU Compiler Collection (GCC) provides standard conforming and |
|
80 highly portable compilers for the ISO C, ISO C++, Objective-C, |
|
81 Fortran and Java languages. |
|
82 |
|
83 %track |
|
84 prog gcc = { |
|
85 version = %{V_full} |
|
86 url = ftp://gcc.gnu.org/pub/gcc/releases/ |
|
87 regex = gcc-(4\.\d+\.\d+) |
|
88 url = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/ |
|
89 regex = gcc-core-(\d+\.\d+\.\d+)\.tar\.bz2 |
|
90 } |
|
91 |
|
92 %prep |
|
93 %setup -q |
|
94 %if "%{with_cxx}" == "yes" |
|
95 %setup -q -T -D -b 1 |
|
96 %endif |
|
97 %if "%{with_objc}" == "yes" |
|
98 %setup -q -T -D -b 2 |
|
99 %endif |
|
100 %if "%{with_java}" == "yes" |
|
101 %setup -q -T -D -b 3 |
|
102 %endif |
|
103 %if "%{with_fortran}" == "yes" |
|
104 %setup -q -T -D -b 4 |
|
105 %endif |
|
106 %patch -p0 |
|
107 %{l_shtool} subst -v -s \ |
|
108 -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \ |
|
109 gcc/configure |
|
110 if [ ".%{V_comp}" != . ]; then |
|
111 %{l_shtool} subst -v -s \ |
|
112 -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \ |
|
113 `find . -name Makefile.in -type f -print` |
|
114 fi |
|
115 case "%{l_platform -t}" in |
|
116 amd64*-linux* ) |
|
117 %{l_shtool} subst \ |
|
118 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \ |
|
119 -e 's/test x.gcc_no_link = xyes/false/g' \ |
|
120 libstdc++-v3/configure |
|
121 ;; |
|
122 esac |
|
123 %{l_shtool} subst \ |
|
124 -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \ |
|
125 libstdc++-v3/include/ext/codecvt_specializations.h |
|
126 |
|
127 %build |
|
128 # create build sub-directory |
|
129 %{l_shtool} mkdir -p obj |
|
130 cd obj |
|
131 |
|
132 # determine ld(1) and as(1) usage |
|
133 l_with_gnu_ld_as="" |
|
134 LD=%{l_tool_locate ld ld} |
|
135 AS=%{l_tool_locate as as} |
|
136 echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-ld=$LD" |
|
137 echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS" |
|
138 $LD --version </dev/null 2>/dev/null | grep "^GNU ld " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld" |
|
139 $AS --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as" |
|
140 unset LD |
|
141 unset AS |
|
142 |
|
143 # determine threads usage |
|
144 %if "%{with_threads}" == "yes" |
|
145 l_enable_threads="posix" |
|
146 %else |
|
147 l_enable_threads="single" |
|
148 %endif |
|
149 |
|
150 # determine language usage |
|
151 l_enable_languages="c" |
|
152 %if "%{with_cxx}" == "yes" |
|
153 l_enable_languages="${l_enable_languages},c++" |
|
154 %endif |
|
155 %if "%{with_objc}" == "yes" |
|
156 l_enable_languages="${l_enable_languages},objc" |
|
157 %endif |
|
158 %if "%{with_java}" == "yes" |
|
159 l_enable_languages="${l_enable_languages},java" |
|
160 %endif |
|
161 %if "%{with_fortran}" == "yes" |
|
162 l_enable_languages="${l_enable_languages},f95" |
|
163 %endif |
|
164 |
|
165 # disable GNU iconv usage |
|
166 ( echo "am_cv_func_iconv=no" |
|
167 echo "am_cv_lib_iconv=no" |
|
168 ) >config.cache |
|
169 |
|
170 # configure the package |
|
171 CC="%{l_cc}" \ |
|
172 CFLAGS="%{l_cflags}" \ |
|
173 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes" |
|
174 CPPFLAGS="%{l_cppflags}" \ |
|
175 LDFLAGS="%{l_ldflags}" \ |
|
176 %endif |
|
177 CONFIG_SHELL="%{l_bash}" \ |
|
178 ../configure \ |
|
179 --with-bugurl="http://openpkg.org/" \ |
|
180 --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \ |
|
181 --cache-file=./config.cache \ |
|
182 --srcdir=`pwd`/.. \ |
|
183 --prefix=%{l_prefix} \ |
|
184 --exec-prefix=%{l_prefix} \ |
|
185 --mandir=%{l_prefix}/man \ |
|
186 --infodir=%{l_prefix}/info \ |
|
187 --includedir=%{l_prefix}/include/gcc%{V_comp} \ |
|
188 --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \ |
|
189 --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \ |
|
190 --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \ |
|
191 --enable-languages="${l_enable_languages}" \ |
|
192 --enable-threads="${l_enable_threads}" \ |
|
193 --disable-maintainer-mode \ |
|
194 --disable-shared \ |
|
195 --disable-nls \ |
|
196 %if "%{with_java}" == "yes" |
|
197 --with-system-zlib \ |
|
198 %endif |
|
199 %if "%{with_multilib}" == "yes" |
|
200 --enable-multilib \ |
|
201 %else |
|
202 --disable-multilib \ |
|
203 %endif |
|
204 %if "%{with_cxx}" == "yes" |
|
205 --with-libiconv-prefix=%{l_prefix} \ |
|
206 %endif |
|
207 --with-gmp=%{l_prefix} \ |
|
208 --with-mpfr=%{l_prefix} \ |
|
209 --with-mpc=%{l_prefix} \ |
|
210 ${l_with_gnu_ld_as} |
|
211 |
|
212 # determine build flags |
|
213 l_ccisgcc=no |
|
214 if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then |
|
215 l_ccisgcc=yes |
|
216 fi |
|
217 l_cflags="" |
|
218 l_cxxflags="" |
|
219 l_boot_cflags="" |
|
220 l_libcflags="-g" |
|
221 l_libcxxflags="-g" |
|
222 # at least GNU as from GNU binutils supports -pipe always |
|
223 AS="%{l_tool_locate as as}" |
|
224 "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && { |
|
225 l_boot_cflags="$l_boot_cflags -pipe" |
|
226 l_libcxxflags="$l_libcxxflags -pipe" |
|
227 } |
|
228 %if "%{with_optimize}" == "yes" |
|
229 # conservatively optimize the generated program code |
|
230 # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!) |
|
231 l_cflags="$l_cflags -O" |
|
232 l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer" |
|
233 case "%{l_platform -t}" in |
|
234 *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;; |
|
235 *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;; |
|
236 esac |
|
237 l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates" |
|
238 %else |
|
239 # else do no optimizations at all to reduce problems to minimum in advance |
|
240 l_boot_cflags="$l_boot_cflags -O0" |
|
241 l_libcxxflags="$l_libcxxflags -O0" |
|
242 %endif |
|
243 maketarget="bootstrap2-lean" |
|
244 %if "%{with_profile}" == "yes" |
|
245 # GCC >= 3.4 supports a "profiledbootstrap" target to build an |
|
246 # optimized version of itself through profiling. Because this |
|
247 # requires a (bootstrapping) C compiler with 64-bit arithmetic, |
|
248 # the whole approach is currently supported only if already |
|
249 # building with GCC as the bootstrapping C compiler. |
|
250 if [ ".$l_ccisgcc" = .yes ]; then |
|
251 maketarget="profiledbootstrap" |
|
252 fi |
|
253 %endif |
|
254 case "%{l_platform -t}" in |
|
255 amd64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;; |
|
256 ia64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;; |
|
257 sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;; |
|
258 esac |
|
259 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes" |
|
260 l_cflags="$l_cflags %{l_cppflags}" |
|
261 l_cxxflags="$l_cxxflags %{l_cppflags}" |
|
262 l_libcflags="$l_libcflags %{l_cppflags}" |
|
263 l_libcxxflags="$l_libcxxflags %{l_cppflags}" |
|
264 %endif |
|
265 |
|
266 # build the package |
|
267 MAKE="%{l_make} %{l_mflags}" \ |
|
268 %{l_make} %{l_mflags} \ |
|
269 MAKE="%{l_make} %{l_mflags}" \ |
|
270 BOOT_CFLAGS="${l_boot_cflags}" \ |
|
271 CFLAGS="${l_cflags}" \ |
|
272 CXXFLAGS="${l_cxxflags}" \ |
|
273 LIBCFLAGS="${l_libcflags}" \ |
|
274 LIBCXXFLAGS="${l_libcxxflags}" \ |
|
275 $maketarget |
|
276 |
|
277 %install |
|
278 |
|
279 # fetch GNU platform triple |
|
280 triple=`./config.guess` |
|
281 |
|
282 # perform the standard installation procedure |
|
283 ( cd obj |
|
284 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT |
|
285 ) || exit $? |
|
286 |
|
287 # cleanup installation tree |
|
288 mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \ |
|
289 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \ |
|
290 >/dev/null 2>&1 || true |
|
291 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \ |
|
292 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \ |
|
293 >/dev/null 2>&1 || true |
|
294 dirs="" |
|
295 for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do |
|
296 subdir=`echo "$multilib" | sed -e 's/;.*$//'` |
|
297 [ ".$subdir" = .. ] && continue |
|
298 mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \ |
|
299 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \ |
|
300 >/dev/null 2>&1 || true |
|
301 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \ |
|
302 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \ |
|
303 >/dev/null 2>&1 || true |
|
304 dirs="$dirs $subdir" |
|
305 done |
|
306 for subdir in $dirs; do |
|
307 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true |
|
308 done |
|
309 mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \ |
|
310 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \ |
|
311 >/dev/null 2>&1 || true |
|
312 |
|
313 # strip installation tree |
|
314 rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple} |
|
315 rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir |
|
316 rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true |
|
317 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true |
|
318 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64 >/dev/null 2>&1 || true |
|
319 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true |
|
320 %if "%{with_cxx}" == "yes" |
|
321 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true |
|
322 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true |
|
323 %endif |
|
324 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true |
|
325 for prog in cc1 cc1plus collect2 cpp; do |
|
326 strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \ |
|
327 >/dev/null 2>&1 || true |
|
328 done |
|
329 |
|
330 # bump up installation tree |
|
331 ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \ |
|
332 $RPM_BUILD_ROOT%{l_prefix}/bin/cc |
|
333 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \ |
|
334 $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1 |
|
335 %if "%{with_cxx}" == "yes" |
|
336 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \ |
|
337 $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1 |
|
338 %endif |
|
339 |
|
340 # determine installation file list |
|
341 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} |
|
342 |
|
343 %files -f files |
|
344 |
|
345 %clean |
|
346 |