Thu, 22 Mar 2012 20:51:00 +0100
Complete build configuration corrections and update to new vendor version.
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 ##
24 # package version
25 %define V_full 4.6.2
26 %define V_comp %nil
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: 20120208
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
52 # fix intermodule dependencies implicitly
53 %if "%{with_java}" == "yes"
54 %define with_cxx yes
55 %define with_threads yes
56 %endif
58 # list of sources
59 Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-core-%{V_full}.tar.bz2
60 Source1: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-g++-%{V_full}.tar.bz2
61 Source2: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-objc-%{V_full}.tar.bz2
62 Source3: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-java-%{V_full}.tar.bz2
63 Source4: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-fortran-%{V_full}.tar.bz2
64 Patch0: gcc.patch
66 # build information
67 Prefix: %{l_prefix}
68 BuildRoot: %{l_buildroot}
69 BuildPreReq: OpenPKG, openpkg >= 20060823, make
70 PreReq: OpenPKG, openpkg >= 20060823
71 BuildPreReq: mpc, mpfr, gmp
72 PreReq: mpc, mpfr, gmp
73 %if "%{with_binutils}" == "yes"
74 BuildPreReq: binutils >= 2.14
75 PreReq: binutils >= 2.14
76 %endif
77 %if "%{with_cxx}" == "yes"
78 BuildPreReq: libiconv
79 PreReq: libiconv
80 %endif
81 %if "%{with_java}" == "yes"
82 BuildPreReq: zlib, infozip
83 PreReq: zlib
84 %endif
85 AutoReq: no
86 AutoReqProv: no
88 %description
89 The GNU Compiler Collection (GCC) provides standard conforming and
90 highly portable compilers for the ISO C, ISO C++, Objective-C,
91 Fortran and Java languages.
93 %track
94 prog gcc = {
95 version = %{V_full}
96 url = ftp://gcc.gnu.org/pub/gcc/releases/
97 regex = gcc-(4\.\d+\.\d+)
98 url = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/
99 regex = gcc-core-(\d+\.\d+\.\d+)\.tar\.bz2
100 }
102 %prep
103 %setup -q
104 %if "%{with_cxx}" == "yes"
105 %setup -q -T -D -b 1
106 %endif
107 %if "%{with_objc}" == "yes"
108 %setup -q -T -D -b 2
109 %endif
110 %if "%{with_java}" == "yes"
111 %setup -q -T -D -b 3
112 %endif
113 %if "%{with_fortran}" == "yes"
114 %setup -q -T -D -b 4
115 %endif
116 %patch -p0
117 %{l_shtool} subst \
118 -e 's;\(instname="\$dir/\$name"\)i;\1;' \
119 ltmain.sh
120 %{l_shtool} subst -v -s \
121 -e 's;\(gmplibs="-lmpc\) \(-lmpfr -lgmp\);\1 -lm \2;' \
122 configure
123 %{l_shtool} subst -v -s \
124 -e 's;\(LDEXP_LIB=\)"$LIBS";\1"$LDFLAGS";' \
125 -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
126 gcc/configure
127 %{l_shtool} subst \
128 -e 's;[ \t]*-W[a-zA-Z0-9_\-][a-zA-Z0-9_\-]*,*;;g' \
129 lto-plugin/Makefile.in
130 %{l_shtool} subst \
131 -e 's;-rpath *[^ \t][^ \t]*;;g' \
132 -e 's;--tag=disable-static;--tag=disable-shared;g' \
133 -e 's;\.\./libiberty/libiberty\.a;-L../libiberty -liberty;g' \
134 -e 's;\.\./libiberty/pic/libiberty\.a;-L../libiberty/pic -liberty;g' \
135 lto-plugin/Makefile.in
136 %if "%{with_cxx}" == "yes"
137 %{l_shtool} subst \
138 -e 's;\(pythondir *= *\$(datadir)\)/gcc-\$(gcc_version);\1/gcc;' \
139 libstdc++-v3/python/Makefile.in
140 %endif
141 %if "%{with_java}" == "yes"
142 %{l_shtool} subst \
143 -e 's;\(default_python_dir\) *=.*;\1=/share/gcc/python/libjava;' \
144 libjava/configure
145 %{l_shtool} subst \
146 -e 's;JAR *= *@JAR@;JAR = $(here)/scripts/jar;' \
147 libjava/Makefile.in
148 %endif
149 if [ ".%{V_comp}" != . ]; then
150 %{l_shtool} subst -v -s \
151 -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
152 -e 's;(libexecdir)/gcc/;(libexecdir)/gcc%{V_comp}/;' \
153 `find . -name Makefile.in -type f -print`
154 fi
155 %{l_shtool} subst \
156 -e 's;^\(do-compare\) *\(=.*\);#\1-shouldnt-be-defined-here \2;' \
157 config/*.mk
158 case "%{l_platform -t}" in
159 amd64-linux* )
160 %{l_shtool} subst \
161 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
162 -e 's/test x.gcc_no_link = xyes/false/g' \
163 libstdc++-v3/configure
164 ;;
165 esac
166 %{l_shtool} subst \
167 -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
168 libstdc++-v3/include/ext/codecvt_specializations.h
169 %{l_shtool} subst \
170 -e 's;.*with_arch_32=\${with_arch_32:-pentium4}.*;;' \
171 -e 's;with_arch_32=\${with_arch_32:-pentiumpro};arch_without_sse2=yes;' \
172 gcc/config.gcc
173 #-e 's;\(with_arch_32=\${with_arch_32:-\)pentium4};\1pentium3};' \
175 %if "%{with_cxx}" == "yes"
176 # sad hack to correct split gettext in libc and libintl each
177 # providing locale-intl.cc disparate libintl.h with externs,
178 # see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11074
179 [ -f %{l_prefix}/include/libintl.h -a -f /usr/include/libintl.h ] && \
180 cp /usr/include/libintl.h libstdc++-v3/libsupc++/ || \
181 [ -f /usr/include/libintl.h ] || \
182 ( echo "A system native gettext installation is not detected. Because GCC"
183 echo "C++ components require gettext problems may arise. These problems"
184 echo "can appear at build time causing the build to stop with errors"
185 echo "containing the words NLS, intl, or locale, or at run time should"
186 echo "undefined external symbols libintl_* in libstdc++.a interfere with"
187 echo "building other C++ sources."
188 echo ""
189 echo "To solve such problems, contact the GCC package maintainer and inform"
190 echo "of the location of libintl.h header on the system in question."
191 ) | %{l_rpmtool} msg -b -t warn
192 %endif
194 %build
195 # create build subdirectory
196 %{l_shtool} mkdir -p objbld
197 cd objbld
199 # locate ld(1) and as(1) accordingly
200 %if "%{with_binutils}" == "yes"
201 # allow OpenPKG binutils
202 LD=%{l_tool_locate ld ld}
203 AS=%{l_tool_locate as as}
204 %else
205 # ignore OpenPKG binutils
206 LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin which ld`
207 AS=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin which as`
208 %endif
209 l_with_gnu_ld_as=""
210 echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="--with-ld=$LD"
211 echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
212 $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" || l_with_gnu_ld_as="${l_with_gnu_ld_as} --without-gnu-ld"
213 $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" || l_with_gnu_ld_as="${l_with_gnu_ld_as} --without-gnu-as"
215 # determine threads use
216 %if "%{with_threads}" == "yes"
217 l_enable_threads="posix"
218 %else
219 l_enable_threads="single"
220 %endif
222 # determine language use
223 l_enable_languages="c"
224 %if "%{with_cxx}" == "yes"
225 l_enable_languages="${l_enable_languages},c++"
226 %endif
227 %if "%{with_objc}" == "yes"
228 l_enable_languages="${l_enable_languages},objc"
229 %endif
230 %if "%{with_java}" == "yes"
231 l_enable_languages="${l_enable_languages},java"
232 %endif
233 %if "%{with_fortran}" == "yes"
234 l_enable_languages="${l_enable_languages},f95"
235 %endif
237 # disable GNU iconv use
238 ( echo "am_cv_func_iconv=no"
239 echo "am_cv_lib_iconv=no"
240 ) >config.cache
241 # platforms failing 'compare' make target (see prep as well)
242 case "%{l_platform -t}" in
243 *i?86-sunos* ) echo "gcc_cv_prog_cmp_skip=true" >>config.cache ;;
244 *amd64-linux* ) echo "gcc_cv_prog_cmp_skip=true" >>config.cache ;;
245 esac
247 # configure the package
248 LD="$LD" \
249 AS="$AS" \
250 CC="%{l_cc}" \
251 CFLAGS="%{l_cflags}" \
252 %if "%{with_cxx}" == "yes"
253 CPPFLAGS="%{l_cppflags}" \
254 LDFLAGS="%{l_ldflags}" \
255 %endif
256 CONFIG_SHELL="%{l_bash}" \
257 GREP="%{l_bash}" \
258 ../configure \
259 --cache-file=./config.cache \
260 --with-bugurl="http://openpkg.org/" \
261 --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
262 --srcdir=`pwd`/.. \
263 --prefix=%{l_prefix} \
264 --exec-prefix=%{l_prefix} \
265 --mandir=%{l_prefix}/man \
266 --infodir=%{l_prefix}/info \
267 --includedir=%{l_prefix}/include/gcc%{V_comp} \
268 --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
269 --enable-languages="${l_enable_languages}" \
270 --enable-threads="${l_enable_threads}" \
271 --disable-maintainer-mode \
272 --disable-shared \
273 --disable-nls \
274 %if "%{with_java}" == "yes"
275 --with-system-zlib \
276 %endif
277 %if "%{with_multilib}" == "yes"
278 --enable-multilib \
279 %else
280 --disable-multilib \
281 %endif
282 %if "%{with_cxx}" == "yes"
283 --with-libiconv-prefix=%{l_prefix} \
284 %endif
285 --with-gmp=%{l_prefix} \
286 --with-mpfr=%{l_prefix} \
287 --with-mpc=%{l_prefix} \
288 ${l_with_gnu_ld_as}
290 # determine build flags
291 l_ccisgcc=no
292 if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
293 l_ccisgcc=yes
294 fi
295 l_cflags=""
296 l_cxxflags=""
297 l_boot_cflags=""
298 l_libcflags="-g"
299 l_libcxxflags="-g"
300 # at least GNU as from GNU binutils supports -pipe always
301 "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler" >/dev/null && {
302 l_boot_cflags="$l_boot_cflags -pipe"
303 l_libcxxflags="$l_libcxxflags -pipe"
304 }
305 %if "%{with_optimize}" == "yes"
306 # GCC authors are not keeping up with optimized portability expectations
307 ( echo "As GCC advances its optimization logic becomes increasingly complex (and"
308 echo "buggy?) Since at least GCC 4.5, problems have been reported using arguments"
309 echo "-O, -mtune, or -march implicitly or explicitly during different bootstrap"
310 echo "stages as well as stage comparison and even the final installation."
311 echo ""
312 echo "Pay attention when building on one computer and installing on another as"
313 echo "problems may be platform specific. If in doubt, disable optimization."
314 ) | %{l_rpmtool} msg -b -t warn
315 if [ ".$l_ccisgcc" != .yes ]; then
316 # CPU native detection only works with GCC (see driver-i386.c)
317 ( echo "Platform specific optimization is enabled, but detection of appropriate"
318 echo "native architecture is only possible when bootstrapping GCC using a pre-"
319 echo "installed GCC. The current build is using a different compiler, so such"
320 echo "optimization is generically built while deferring native architecture"
321 echo "detection to the final GCC binary."
322 echo ""
323 echo "To achieve native architecture detection while bootstrapping please"
324 echo "install GCC first and then build GCC a second time."
325 ) | %{l_rpmtool} msg -b -t notice
326 fi
327 # tuning without specifying '-march' is portable and in theory
328 # allows the resulting GCC binaries to execute on other hosts!
329 case "%{l_platform -t}" in
330 *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
331 *sun*-* ) l_boot_cflags="$l_boot_cflags -mtune=v8" ;;
332 *i?86-* | *amd64-* | *ia64-* ) l_boot_cflags="$l_boot_cflags -mtune=native" ;;
333 * ) l_boot_cflags="$l_boot_cflags -mtune=generic" ;;
334 esac
335 l_cflags="$l_cflags -O"
336 l_boot_cflags="$l_boot_cflags -O3 -fomit-frame-pointer"
337 l_libcxxflags="$l_libcxxflags -O3 -fno-implicit-templates"
338 %else
339 # don't optimize at all to avoid problems
340 l_boot_cflags="$l_boot_cflags -O0"
341 l_libcxxflags="$l_libcxxflags -O0"
342 %endif
343 %if "%{with_profile}" == "yes"
344 # generate profile feedback
345 maketarget="profiledbootstrap"
346 loc_makeflags="%{l_mflags}"
348 # warn about exceptional build duration for profile feedback
349 ( echo "Building profile feedback on some hosts can take many days to complete!"
350 echo "Now continuing to build a profiled bootstrap with parallel make logic"
351 echo "disabled according to profiling requirements..."
352 ) | %{l_rpmtool} msg -b -t warn
354 # warn about profiled bootstrap requirement of 64-bit arithmetic
355 if [ ".$l_ccisgcc" != .yes ]; then
356 ( echo "A preinstalled GCC was not detected although one is recommended for"
357 echo "building a profiled bootstrap. Buildtime or runtime errors can occur if"
358 echo "the compiler used to build profile feedback doesn't support 64-bit math."
359 echo ""
360 echo "If in doubt, stop now and start the build again with profiling disabled."
361 ) | %{l_rpmtool} msg -b -t warn
362 fi
363 %else
364 # build in three stages
365 maketarget="bootstrap"
366 loc_makeflags="%{l_mflags -O}"
367 %endif
368 case "%{l_platform -t}" in
369 *64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
370 esac
371 %if "%{with_cxx}" == "yes"
372 l_cflags="$l_cflags %{l_cppflags}"
373 l_cxxflags="$l_cxxflags %{l_cppflags}"
374 l_libcflags="$l_libcflags %{l_cppflags}"
375 l_libcxxflags="$l_libcxxflags %{l_cppflags}"
376 %endif
378 # build the package
379 MAKE="%{l_make} ${loc_makeflags}" \
380 %{l_make} ${loc_makeflags} \
381 GREP="grep" \
382 MAKE="%{l_make} ${loc_makeflags}" \
383 BOOT_CFLAGS="${l_boot_cflags}" \
384 CFLAGS="${l_cflags}" \
385 CXXFLAGS="${l_cxxflags}" \
386 %if "%{with_cxx}" == "yes"
387 CPPFLAGS="%{l_cppflags}" \
388 LDFLAGS="%{l_ldflags}" \
389 BOOT_LDFLAGS="%{l_ldflags}" \
390 %endif
391 LIBCFLAGS="${l_libcflags}" \
392 LIBCXXFLAGS="${l_libcxxflags}" \
393 $maketarget
395 %install
396 rm -rf $RPM_BUILD_ROOT
398 # fetch GNU platform triple
399 triple=`./config.guess`
401 # perform standard installation procedure
402 ( cd objbld
403 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
404 ) || exit $?
406 # cleanup installation tree
407 mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
408 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
409 >/dev/null 2>&1 || true
410 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
411 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
412 >/dev/null 2>&1 || true
413 dirs=""
414 for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
415 subdir=`echo "$multilib" | sed -e 's/;.*$//'`
416 [ ".$subdir" = .. ] && continue
417 mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
418 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
419 >/dev/null 2>&1 || true
420 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
421 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
422 >/dev/null 2>&1 || true
423 dirs="$dirs $subdir"
424 done
425 for subdir in $dirs; do
426 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
427 done
428 mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
429 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
430 >/dev/null 2>&1 || true
432 # correct hardcoded paths
433 %{l_shtool} subst \
434 -e "s;\(dependency_libs\) *=.*;\1='-L%{l_prefix}/lib\ -L%{l_prefix}/lib/gcc%{V_comp}/${triple}/%{V_full}\ -liberty';" \
435 $RPM_BUILD_ROOT%{l_prefix}/libexec/gcc%{V_comp}/${triple}/[0-9]*/liblto_plugin.la
437 # strip installation tree
438 rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
439 rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
440 rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
441 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
442 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64 >/dev/null 2>&1 || true
443 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
444 %if "%{with_cxx}" == "yes"
445 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
446 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
447 %endif
448 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
449 for prog in cc1 cc1plus collect2 cpp; do
450 strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
451 >/dev/null 2>&1 || true
452 done
454 # bump up installation tree
455 ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
456 $RPM_BUILD_ROOT%{l_prefix}/bin/cc
457 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
458 $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
459 %if "%{with_cxx}" == "yes"
460 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
461 $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
462 %endif
464 # determine installation file list
465 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
467 %files -f files
469 %clean
470 rm -rf $RPM_BUILD_ROOT