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