Thu, 24 Mar 2011 19:04:49 +0100
Try to correct dependency compatability logic leading to build problems.
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.5.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: 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 %if "%{with_binutils}" == "yes"
66 BuildPreReq: binutils >= 2.14
67 PreReq: binutils >= 2.14
68 %endif
69 BuildPreReq: mpc, mpfr, gmp
70 PreReq: mpc, mpfr, gmp
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 -v -s \
112 -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
113 gcc/configure
114 if [ ".%{V_comp}" != . ]; then
115 %{l_shtool} subst -v -s \
116 -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
117 `find . -name Makefile.in -type f -print`
118 fi
119 case "%{l_platform -t}" in
120 amd64*-linux* )
121 %{l_shtool} subst \
122 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
123 -e 's/test x.gcc_no_link = xyes/false/g' \
124 libstdc++-v3/configure
125 ;;
126 esac
127 %{l_shtool} subst \
128 -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
129 libstdc++-v3/include/ext/codecvt_specializations.h
131 %build
132 # create build sub-directory
133 %{l_shtool} mkdir -p obj
134 cd obj
136 # solve strange compatability problems
137 case "%{l_platform -t}" in
138 *-sunos* )
139 %if "%{with_binutils}" == "no"
140 ( echo "Building GCC on Solaris OS requires GNU as, however"
141 echo "the OS native linker will be used in place of GNU ld."
142 echo ""
143 echo "To solve this problem, install the binutils package"
144 echo "and build GCC again using the option 'with_binutils'."
145 echo "OpenPKG will ignore GNU ld but use GNU as to build GCC."
146 echo ""
147 echo "Please note that this condition applies to OpenPKG"
148 echo "building of the GCC package on Solaris only!"
149 ) | %{l_rpmtool} msg -b -t warn
150 exit 1;
151 ;;
152 %else
153 # locate ld(1) and as(1), using the GNU assembler
154 # but ignoring the presence of any OpenPKG linker
155 LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin \
156 which ld`
157 ;;
158 %endif
159 *-* )
160 # determine ld(1) and as(1) usage, allowing either
161 # one to be from the GNU distribution of binutils
162 LD=%{l_tool_locate ld ld}
163 ;;
164 esac
165 l_with_gnu_ld_as=""
166 AS=%{l_tool_locate as as}
167 echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="--with-ld=$LD"
168 echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
169 $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"
170 $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"
172 # determine threads usage
173 %if "%{with_threads}" == "yes"
174 l_enable_threads="posix"
175 %else
176 l_enable_threads="single"
177 %endif
179 # determine language usage
180 l_enable_languages="c"
181 %if "%{with_cxx}" == "yes"
182 l_enable_languages="${l_enable_languages},c++"
183 %endif
184 %if "%{with_objc}" == "yes"
185 l_enable_languages="${l_enable_languages},objc"
186 %endif
187 %if "%{with_java}" == "yes"
188 l_enable_languages="${l_enable_languages},java"
189 %endif
190 %if "%{with_fortran}" == "yes"
191 l_enable_languages="${l_enable_languages},f95"
192 %endif
194 # disable GNU iconv usage
195 ( echo "am_cv_func_iconv=no"
196 echo "am_cv_lib_iconv=no"
197 ) >config.cache
199 # configure the package
200 LD="$LD" \
201 AS="$AS" \
202 CC="%{l_cc}" \
203 CFLAGS="%{l_cflags}" \
204 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
205 CPPFLAGS="%{l_cppflags}" \
206 LDFLAGS="%{l_ldflags}" \
207 %endif
208 CONFIG_SHELL="%{l_bash}" \
209 ../configure \
210 --with-bugurl="http://openpkg.org/" \
211 --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
212 --cache-file=./config.cache \
213 --srcdir=`pwd`/.. \
214 --prefix=%{l_prefix} \
215 --exec-prefix=%{l_prefix} \
216 --mandir=%{l_prefix}/man \
217 --infodir=%{l_prefix}/info \
218 --includedir=%{l_prefix}/include/gcc%{V_comp} \
219 --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
220 --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
221 --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
222 --enable-languages="${l_enable_languages}" \
223 --enable-threads="${l_enable_threads}" \
224 --disable-maintainer-mode \
225 --disable-shared \
226 --disable-nls \
227 %if "%{with_java}" == "yes"
228 --with-system-zlib \
229 %endif
230 %if "%{with_multilib}" == "yes"
231 --enable-multilib \
232 %else
233 --disable-multilib \
234 %endif
235 %if "%{with_cxx}" == "yes"
236 --with-libiconv-prefix=%{l_prefix} \
237 %endif
238 --with-gmp=%{l_prefix} \
239 --with-mpfr=%{l_prefix} \
240 --with-mpc=%{l_prefix} \
241 ${l_with_gnu_ld_as}
243 # determine build flags
244 l_ccisgcc=no
245 if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
246 l_ccisgcc=yes
247 fi
248 l_cflags=""
249 l_cxxflags=""
250 l_boot_cflags=""
251 l_libcflags="-g"
252 l_libcxxflags="-g"
253 # at least GNU as from GNU binutils supports -pipe always
254 "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && {
255 l_boot_cflags="$l_boot_cflags -pipe"
256 l_libcxxflags="$l_libcxxflags -pipe"
257 }
258 %if "%{with_optimize}" == "yes"
259 # conservatively optimize the generated program code
260 # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
261 l_cflags="$l_cflags -O"
262 l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
263 case "%{l_platform -t}" in
264 *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
265 *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
266 esac
267 l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
268 %else
269 # else do no optimizations at all to reduce problems to minimum in advance
270 l_boot_cflags="$l_boot_cflags -O0"
271 l_libcxxflags="$l_libcxxflags -O0"
272 %endif
273 maketarget="bootstrap2-lean"
274 %if "%{with_profile}" == "yes"
275 # GCC >= 3.4 supports a "profiledbootstrap" target to build an
276 # optimized version of itself through profiling. Because this
277 # requires a (bootstrapping) C compiler with 64-bit arithmetic,
278 # the whole approach is currently supported only if already
279 # building with GCC as the bootstrapping C compiler.
280 if [ ".$l_ccisgcc" = .yes ]; then
281 maketarget="profiledbootstrap"
282 fi
283 %endif
284 case "%{l_platform -t}" in
285 amd64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
286 ia64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
287 sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
288 esac
289 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
290 l_cflags="$l_cflags %{l_cppflags}"
291 l_cxxflags="$l_cxxflags %{l_cppflags}"
292 l_libcflags="$l_libcflags %{l_cppflags}"
293 l_libcxxflags="$l_libcxxflags %{l_cppflags}"
294 %endif
296 # build the package
297 MAKE="%{l_make} %{l_mflags}" \
298 %{l_make} %{l_mflags} \
299 MAKE="%{l_make} %{l_mflags}" \
300 BOOT_CFLAGS="${l_boot_cflags}" \
301 CFLAGS="${l_cflags}" \
302 CXXFLAGS="${l_cxxflags}" \
303 LIBCFLAGS="${l_libcflags}" \
304 LIBCXXFLAGS="${l_libcxxflags}" \
305 $maketarget
307 %install
308 rm -rf $RPM_BUILD_ROOT
310 # fetch GNU platform triple
311 triple=`./config.guess`
313 # perform the standard installation procedure
314 ( cd obj
315 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
316 ) || exit $?
318 # cleanup installation tree
319 mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
320 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
321 >/dev/null 2>&1 || true
322 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
323 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
324 >/dev/null 2>&1 || true
325 dirs=""
326 for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
327 subdir=`echo "$multilib" | sed -e 's/;.*$//'`
328 [ ".$subdir" = .. ] && continue
329 mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
330 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
331 >/dev/null 2>&1 || true
332 mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
333 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
334 >/dev/null 2>&1 || true
335 dirs="$dirs $subdir"
336 done
337 for subdir in $dirs; do
338 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
339 done
340 mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
341 $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
342 >/dev/null 2>&1 || true
344 # strip installation tree
345 rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
346 rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
347 rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
348 rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
349 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64 >/dev/null 2>&1 || true
350 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
351 %if "%{with_cxx}" == "yes"
352 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
353 rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
354 %endif
355 strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
356 for prog in cc1 cc1plus collect2 cpp; do
357 strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
358 >/dev/null 2>&1 || true
359 done
361 # bump up installation tree
362 ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
363 $RPM_BUILD_ROOT%{l_prefix}/bin/cc
364 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
365 $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
366 %if "%{with_cxx}" == "yes"
367 ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
368 $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
369 %endif
371 # determine installation file list
372 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
374 %files -f files
376 %clean
377 rm -rf $RPM_BUILD_ROOT