Mon, 28 Mar 2011 19:41:02 +0200
Completely rework package including...
Simpify 64-bit -fPIC logic, instruct make to build in parallel,
force error condition on failed profile dependency, build the
standard 'bootstrap' target as suggested, correct grammar, wording,
and punctuation in general, upgrade to latest upstream vendor version,
rearrange package dependencies mpc, mpfr, and gmp, correct buildconf
thanks to new lto-plugin forced, avoid failed platform specific stage
comparison, adjust patch code to reflect new version update, and most
importantly adjust optimization flags to platform. Please note that
block 'correct hardcoded paths' is likely no yet complete.
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.0
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: 20110320
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 # 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
60 # build information
61 Prefix: %{l_prefix}
62 BuildRoot: %{l_buildroot}
63 BuildPreReq: OpenPKG, openpkg >= 20060823, make
64 PreReq: OpenPKG, openpkg >= 20060823
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
77 PreReq: zlib
78 %endif
79 AutoReq: no
80 AutoReqProv: no
82 %description
83 The GNU Compiler Collection (GCC) provides standard conforming and
84 highly portable compilers for the ISO C, ISO C++, Objective-C,
85 Fortran and Java languages.
87 %track
88 prog gcc = {
89 version = %{V_full}
90 url = ftp://gcc.gnu.org/pub/gcc/releases/
91 regex = gcc-(4\.\d+\.\d+)
92 url = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/
93 regex = gcc-core-(\d+\.\d+\.\d+)\.tar\.bz2
94 }
96 %prep
97 %setup -q
98 %if "%{with_cxx}" == "yes"
99 %setup -q -T -D -b 1
100 %endif
101 %if "%{with_objc}" == "yes"
102 %setup -q -T -D -b 2
103 %endif
104 %if "%{with_java}" == "yes"
105 %setup -q -T -D -b 3
106 %endif
107 %if "%{with_fortran}" == "yes"
108 %setup -q -T -D -b 4
109 %endif
110 %patch -p0
111 %{l_shtool} subst \
112 -e 's;\(instname="\$dir/\$name"\)i;\1;' \
113 ltmain.sh
114 %{l_shtool} subst -v -s \
115 -e 's;\(gmplibs="-lmpc\) \(-lmpfr -lgmp\);\1 -lm \2;' \
116 configure
117 %{l_shtool} subst -v -s \
118 -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
119 gcc/configure
120 %{l_shtool} subst \
121 -e 's;[ \t]*-W[a-zA-Z0-9_\-][a-zA-Z0-9_\-]*,*;;g' \
122 lto-plugin/Makefile.in
123 %{l_shtool} subst \
124 -e 's;-rpath *[^ \t][^ \t]*;;g' \
125 -e 's;--tag=disable-static;--tag=disable-shared;g' \
126 -e 's;\.\./libiberty/libiberty\.a;-L../libiberty -liberty;g' \
127 -e 's;\.\./libiberty/pic/libiberty\.a;-L../libiberty/pic -liberty;g' \
128 lto-plugin/Makefile.in
129 if [ ".%{V_comp}" != . ]; then
130 %{l_shtool} subst -v -s \
131 -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
132 `find . -name Makefile.in -type f -print`
133 fi
134 case "%{l_platform -t}" in
135 amd64*-linux* )
136 %{l_shtool} subst \
137 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
138 -e 's/test x.gcc_no_link = xyes/false/g' \
139 libstdc++-v3/configure
140 ;;
141 esac
142 %{l_shtool} subst \
143 -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
144 libstdc++-v3/include/ext/codecvt_specializations.h
146 %build
147 # create build sub-directory
148 %{l_shtool} mkdir -p obj
149 cd obj
151 # solve strange compatability problems
152 %if "%{with_binutils}" == "yes"
153 # determine ld(1) and as(1) usage, allowing either
154 # one to be from the GNU distribution of binutils
155 LD=%{l_tool_locate ld ld}
156 AS=%{l_tool_locate as as}
157 %else
158 # locate ld(1) and as(1), using the GNU assembler
159 # but ignoring the presence of any OpenPKG linker
160 LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin which ld`
161 AS=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin which as`
162 %endif
163 l_with_gnu_ld_as=""
164 echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="--with-ld=$LD"
165 echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
166 $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"
167 $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"
169 # determine threads usage
170 %if "%{with_threads}" == "yes"
171 l_enable_threads="posix"
172 %else
173 l_enable_threads="single"
174 %endif
176 # determine language usage
177 l_enable_languages="c"
178 %if "%{with_cxx}" == "yes"
179 l_enable_languages="${l_enable_languages},c++"
180 %endif
181 %if "%{with_objc}" == "yes"
182 l_enable_languages="${l_enable_languages},objc"
183 %endif
184 %if "%{with_java}" == "yes"
185 l_enable_languages="${l_enable_languages},java"
186 %endif
187 %if "%{with_fortran}" == "yes"
188 l_enable_languages="${l_enable_languages},f95"
189 %endif
191 # disable GNU iconv usage
192 ( echo "am_cv_func_iconv=no"
193 echo "am_cv_lib_iconv=no"
194 ) >config.cache
196 # platform specific config logic
197 case "%{l_platform -t}" in
198 *i?86-sunos* ) echo "gcc_cv_prog_cmp_skip=true" >>config.cache;;
199 esac
201 # configure the package
202 LD="$LD" \
203 AS="$AS" \
204 CC="%{l_cc}" \
205 CFLAGS="%{l_cflags}" \
206 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
207 CPPFLAGS="%{l_cppflags}" \
208 LDFLAGS="%{l_ldflags}" \
209 %endif
210 CONFIG_SHELL="%{l_bash}" \
211 GREP="%{l_bash}" \
212 ../configure \
213 --with-bugurl="http://openpkg.org/" \
214 --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
215 --cache-file=./config.cache \
216 --srcdir=`pwd`/.. \
217 --prefix=%{l_prefix} \
218 --exec-prefix=%{l_prefix} \
219 --mandir=%{l_prefix}/man \
220 --infodir=%{l_prefix}/info \
221 --includedir=%{l_prefix}/include/gcc%{V_comp} \
222 --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
223 --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
224 --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
225 --enable-languages="${l_enable_languages}" \
226 --enable-threads="${l_enable_threads}" \
227 --disable-maintainer-mode \
228 --disable-shared \
229 --disable-nls \
230 %if "%{with_java}" == "yes"
231 --with-system-zlib \
232 %endif
233 %if "%{with_multilib}" == "yes"
234 --enable-multilib \
235 %else
236 --disable-multilib \
237 %endif
238 %if "%{with_cxx}" == "yes"
239 --with-libiconv-prefix=%{l_prefix} \
240 %endif
241 --with-gmp=%{l_prefix} \
242 --with-mpfr=%{l_prefix} \
243 --with-mpc=%{l_prefix} \
244 ${l_with_gnu_ld_as}
246 # determine build flags
247 l_ccisgcc=no
248 if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
249 l_ccisgcc=yes
250 fi
251 l_cflags=""
252 l_cxxflags=""
253 l_boot_cflags=""
254 l_libcflags="-g"
255 l_libcxxflags="-g"
256 # at least GNU as from GNU binutils supports -pipe always
257 "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler" >/dev/null && {
258 l_boot_cflags="$l_boot_cflags -pipe"
259 l_libcxxflags="$l_libcxxflags -pipe"
260 }
261 %if "%{with_optimize}" == "yes"
262 if [ ".$l_ccisgcc" = .yes ]; then
263 l_ia32=native
264 else
265 l_ia32=pentium3
266 fi
267 case "%{l_platform -t}" in
268 *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=$l_ia32" ;;
269 *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
270 esac
271 l_cflags="$l_cflags -O"
272 l_boot_cflags="$l_boot_cflags -O3 -fomit-frame-pointer"
273 l_libcxxflags="$l_libcxxflags -O3 -fno-implicit-templates"
274 %else
275 %if "%{with_optimize}" == "port"
276 # conservatively optimize the generated program code for portable use,
277 # also _tune_ for particular CPUs, but _without_ requiring these CPUs!
278 case "%{l_platform -t}" in
279 *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=generic" ;;
280 *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v8" ;;
281 esac
282 l_cflags="$l_cflags -O"
283 l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
284 l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
285 %else
286 # do not optimize at all to avoid problems
287 l_boot_cflags="$l_boot_cflags -O0"
288 l_libcxxflags="$l_libcxxflags -O0"
289 %endif
290 %endif
291 maketarget="bootstrap"
292 %if "%{with_profile}" == "yes"
293 # GCC >= 3.4 supports a "profiledbootstrap" target to build an
294 # optimized version of itself through profiling. Because this
295 # requires a (bootstrapping) C compiler with 64-bit arithmetic,
296 # the whole approach is currently supported only if already
297 # building with GCC as the bootstrapping C compiler.
298 if [ ".$l_ccisgcc" = .yes ]; then
299 maketarget="profiledbootstrap"
300 else
301 ( echo "Building a profiled GCC requires GCC. Please install GCC"
302 echo "first and then build again with the profile option enabled."
303 ) | %{l_rpmtool} msg -b -t error
304 exit 1
305 fi
306 %endif
307 case "%{l_platform -t}" in
308 *64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
309 esac
310 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
311 l_cflags="$l_cflags %{l_cppflags}"
312 l_cxxflags="$l_cxxflags %{l_cppflags}"
313 l_libcflags="$l_libcflags %{l_cppflags}"
314 l_libcxxflags="$l_libcxxflags %{l_cppflags}"
315 %endif
317 # build the package
318 MAKE="%{l_make} %{l_mflags -O}" \
319 %{l_make} %{l_mflags -O} \
320 GREP="grep" \
321 MAKE="%{l_make} %{l_mflags -O}" \
322 BOOT_CFLAGS="${l_boot_cflags}" \
323 CFLAGS="${l_cflags}" \
324 CXXFLAGS="${l_cxxflags}" \
325 LIBCFLAGS="${l_libcflags}" \
326 LIBCXXFLAGS="${l_libcxxflags}" \
327 $maketarget
329 %install
330 rm -rf $RPM_BUILD_ROOT
332 # fetch GNU platform triple
333 triple=`./config.guess`
335 # perform the standard installation procedure
336 ( cd obj
337 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
338 ) || exit $?
340 # cleanup installation tree
341 mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
342 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
343 >/dev/null 2>&1 || true
344 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
345 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
346 >/dev/null 2>&1 || true
347 dirs=""
348 for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
349 subdir=`echo "$multilib" | sed -e 's/;.*$//'`
350 [ ".$subdir" = .. ] && continue
351 mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
352 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
353 >/dev/null 2>&1 || true
354 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
355 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
356 >/dev/null 2>&1 || true
357 dirs="$dirs $subdir"
358 done
359 for subdir in $dirs; do
360 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
361 done
362 mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
363 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
364 >/dev/null 2>&1 || true
366 # correct hardcoded paths
367 %{l_shtool} subst \
368 -e "s;\(dependency_libs='[ \t]*-L\).*;\1%{l_prefix}/lib -L%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]* -liberty';" \
369 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/liblto_plugin.la
371 # strip installation tree
372 rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
373 rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
374 rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
375 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
376 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64 >/dev/null 2>&1 || true
377 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
378 %if "%{with_cxx}" == "yes"
379 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
380 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
381 %endif
382 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
383 for prog in cc1 cc1plus collect2 cpp; do
384 strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
385 >/dev/null 2>&1 || true
386 done
388 # bump up installation tree
389 ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
390 $RPM_BUILD_ROOT%{l_prefix}/bin/cc
391 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
392 $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
393 %if "%{with_cxx}" == "yes"
394 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
395 $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
396 %endif
398 # determine installation file list
399 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
401 %files -f files
403 %clean
404 rm -rf $RPM_BUILD_ROOT