81b4036ab36fa0539d45e69f982da0cd1c66633a
[platform/upstream/gcc48.git] / packaging / cross-armv7hl-gcc48-icecream-backend.spec
1 #
2 # spec file for package gcc (Version 4.0.1)
3 #
4 # Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany.
5 # This file and all modifications and additions to the pristine
6 # package are under the same license as the package itself.
7 #
8 # Please submit bugfixes or comments via http://www.suse.de/feedback/
9 #
10
11 %define build_cp 1
12 %define build_ada 0
13 %define build_libjava 0
14 %define build_java 0
15 %define build_fortran 0
16 %define build_objc 0
17 %define build_objcp 0
18 %define build_nof 0
19 %define build_with_mudflap 0
20 %define gcc_target_arch armv7hl-tizen-linux
21 %define gcc_icecream 1
22
23 %define binutils_target armv7hl
24 %if %{binutils_target} == "armv7l" || %{binutils_target} == "armv7hl" || %{binutils_target} == "armv7el"
25 %define binutils_target arm
26 %endif
27 %if %{binutils_target} == "armv5el"
28 %define binutils_target arm
29 %endif
30 %define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
31 %if %{binutils_target} == "arm"
32 %define canonical_target_abi -gnueabi
33 %endif
34
35 Name:         cross-armv7hl-gcc48-icecream-backend
36 BuildRequires: cross-%{binutils_target}-binutils
37 BuildRequires: bison
38 BuildRequires: flex
39 BuildRequires: gettext-devel
40 BuildRequires: glibc-devel-32bit
41 BuildRequires: mpc-devel
42 BuildRequires: mpfr-devel
43 BuildRequires: perl
44 BuildRequires: makeinfo
45 BuildRequires: zlib-devel
46 %ifarch %ix86 x86_64  %arm
47 BuildRequires: cloog-devel
48 BuildRequires: ppl-devel
49 %endif
50 %ifarch ia64
51 BuildRequires: libunwind-devel
52 %endif
53 ExclusiveArch: ppc ppc64 %ix86 x86_64 ia64 
54 %define _binary_payload w.ufdio
55
56 %define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
57
58 URL:          http://gcc.gnu.org/
59 Version: 4.8.1
60 Release:      1
61 %define gcc_version %(echo %version | sed 's/_.*//')
62 %define gcc_dir_version %(echo %gcc_version | cut -d '.' -f 1-2)
63 %define snapshot_date %(echo %version | sed 's/[34]\.[0-9]\.[0-6]//' | sed 's/_/-/')
64 %define binsuffix -4.8
65 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
66 Source:         gcc-%{version}.tar.bz2
67 Source1:        change_spec
68 Source3:        gcc48-rpmlintrc
69 Source4:        ecj.jar
70 Source6:        baselibs.conf
71
72
73 Group:          Development/Toolchain
74 Summary:        The GNU C Compiler and Support Files
75 License:        GPL-3.0+
76
77 %description
78 Core package for the GNU Compiler Collection, including the C language
79 frontend.
80
81 Language frontends other than C are split to different sub-packages,
82 namely gcc-ada, gcc-c++, gcc-fortran, gcc-java, gcc-objc and
83 gcc-obj-c++.
84
85
86
87
88 # Define the canonical target and host architecture
89 #   %gcc_target_arch  is supposed to be the full target triple
90 #   %TARGET_ARCH      is the canonicalized CPU part
91 #   %CONFIGURE_TARGET is the target triple used for --target=
92 %if 0%{?gcc_target_arch:1}
93 %define CONFIGURE_TARGET %{gcc_target_arch}
94 %define TARGET_ARCH %(echo %{gcc_target_arch} | cut -d - -f 1 | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
95 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc"
96 %define CONFIGURE_TARGET powerpc64-tizen-linux
97 %endif
98 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc64"
99 %define CONFIGURE_TARGET powerpc64-tizen-linux
100 %endif
101 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "i586"
102 %define CONFIGURE_TARGET i586-tizen-linux
103 %endif
104 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7l"
105 %define CONFIGURE_TARGET armv7l-tizen-linux-gnueabi
106 %endif
107 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7hl"
108 %define CONFIGURE_TARGET armv7hl-tizen-linux-gnueabi
109 %endif
110 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv5tel"
111 %define CONFIGURE_TARGET armv5tel-tizen-linux-gnueabi
112 %endif
113 %else
114 %define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
115 %endif
116 %define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
117
118 %define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
119
120 %ifarch ppc
121 %define GCCDIST powerpc64-tizen-linux
122 %else
123 %ifarch %sparc
124 %define GCCDIST sparc64-tizen-linux
125 %else
126 %ifarch %arm
127 %define GCCDIST %{HOST_ARCH}-tizen-linux-gnueabi
128 %else
129 %define GCCDIST %{HOST_ARCH}-tizen-linux
130 %endif
131 %endif
132 %endif
133
134 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
135 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
136
137
138 %prep
139 %setup -q -n gcc-%{version}
140
141
142 # We are configuring ppc as ppc64 but with switched multilibs.  Adjust
143 # the libstdc++ abi testsuite baseline files accordingly
144 %ifarch ppc
145 if [ -d libstdc++-v3/config/abi/post/powerpc64-linux-gnu ]; then
146   mkdir -p libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64
147   mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt \
148         libstdc++-v3/config/abi/post/powerpc64-linux-gnu/64/
149   mv libstdc++-v3/config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt \
150         libstdc++-v3/config/abi/post/powerpc64-linux-gnu/
151 fi
152 %endif
153
154 %build
155 # Avoid rebuilding of generated files
156 contrib/gcc_update --touch
157 # Avoid fucking up testsuite results with Java and indirect dispatch
158 export LD_AS_NEEDED=0
159 # Split version file into version used for directories (X.Y) and
160 # version to report with --version (X.Y.Z).
161 # See also gcc-dir-version.patch.
162 # Also decrement the patchlevel version by one
163 if test `cat gcc/DEV-PHASE` == "prerelease"; then
164   ( cat gcc/BASE-VER | cut -d '.' -f 1-2 | tr -d '\n'; echo -n .; cat gcc/BASE-VER | cut -d '.' -f 3 | tr '0123456789' '0012345678' ) > gcc/FULL-VER
165 else
166   mv gcc/BASE-VER gcc/FULL-VER
167 fi
168 cat gcc/FULL-VER | cut -d '.' -f 1-2 > gcc/BASE-VER
169
170 rm -rf obj-%{GCCDIST}
171 mkdir obj-%{GCCDIST}
172 cd obj-%{GCCDIST}
173 RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
174 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
175 %ifarch %ix86
176 # -mcpu is superceded by -mtune but -mtune is not supported by
177 # our bootstrap compiler.  -mcpu gives a warning that stops
178 # the build process, so remove it for now.  Also remove all other
179 # -march and -mtune flags.  They are superseeded by proper
180 # default compiler settings now.
181 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
182 %endif
183 %ifarch s390 s390x
184 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
185 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
186 %endif
187 %if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
188 # Kill all -march/tune/cpu because that screws building the target libs
189 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
190 %endif
191 # Replace 2 spaces by one finally
192 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/  / /g'`
193
194 languages=c
195 %if %{build_cp}
196 languages=$languages,c++
197 %endif
198 %if %{build_objc}
199 languages=$languages,objc
200 %endif
201 %if %{build_fortran}
202 languages=$languages,fortran
203 %endif
204 %if %{build_objcp}
205 languages=$languages,obj-c++
206 %endif
207 %if %{build_java}
208 languages=$languages,java
209 %endif
210 %if %{build_ada}
211 languages=$languages,ada
212 %endif
213
214 J=%{?jobs:%jobs}
215 if test -z "$J"; then
216   J=$(getconf _NPROCESSORS_CONF)
217   JL=$(($J * 2))
218 else
219   test 1 -gt "$J" && J=1
220   JL=$(($(getconf _NPROCESSORS_CONF)*2))
221 fi
222 if test "$J" == "0"; then
223   J=1
224 fi
225 if test "$JL" == "0"; then
226   JL=1
227 fi
228 PARALLEL="-j$J -l$JL"
229
230 # we don't want some miscompiles in the testsuite, or some fault in
231 # the compiler to kill the machine.  Hence we limit the amount of memory
232 # by the physical RAM plus half of swap
233 #MEM=$(free -m | awk '/^Mem:/ {print $2}')
234 #SWAP=$(free -m | awk '/^Swap:/ {print $2}')
235 #ulimit -v $(((MEM + SWAP/2)*1024))
236
237 # In general we want to ship release checking enabled compilers
238 # and run BETA with checking enabled.
239 #ENABLE_CHECKING="--enable-checking=yes"
240 ENABLE_CHECKING="--enable-checking=release"
241
242 # Work around tail/head -1 changes
243 export _POSIX2_VERSION=199209
244
245 # configure tries to parse include/features.h to detect
246 # if glibc supports SSP.  When cross compiling we would need
247 # to install a cross glibc, which we don't, or make the whole
248 # thing point to the native glibc, which is in /, hence the
249 # --with-build-sysroot=/
250
251 %if %{build_ada}
252 # Using the host gnatmake like
253 #   CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
254 #   GNATMAKE="gnatmake%{hostsuffix}"
255 # doesn't work due to PR33857, so an un-suffixed gnatmake has to be
256 # available
257 mkdir -p host-tools/bin
258 cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
259 cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
260 cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
261 cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
262 ln -sf /usr/%{_lib} host-tools/%{_lib}
263 export PATH="`pwd`/host-tools/bin:$PATH"
264 %endif
265 #%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
266 #%else
267 #       --enable-threads=posix \
268 #%endif
269 #       --enable-shared \
270 %if "%{TARGET_ARCH}" == "armv7l" || "%{TARGET_ARCH}" == "armv7hl"
271 # temporary workaround for a miscompilation of hash functions in java code
272 GCJ_EXTRA_FLAGS="-marm"
273 %endif
274 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
275 TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS $GCJ_EXTRA_FLAGS" \
276 ../configure \
277         --prefix=%{_prefix} \
278         --infodir=%{_infodir} \
279         --mandir=%{_mandir} \
280         --libdir=%{_libdir} \
281         --libexecdir=%{_libdir} \
282     --disable-bootstrap \
283         --enable-languages=$languages \
284         $ENABLE_CHECKING \
285         --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
286         --enable-ssp \
287         --disable-libssp \
288         --disable-plugin \
289         --with-bugurl="http://bugs.tizen.org/" \
290         --with-pkgversion="Tizen" \
291 %if !%{build_libjava}
292         --disable-libgcj \
293 %else
294         --with-java-home=%{_libdir}/jvm/java-1.5.0-gcj%{binsuffix}-1.5.0.0/jre \
295         --with-ecj-jar=%{libsubdir}/ecj.jar \
296         --disable-java-awt \
297 %if !%{biarch_libjava}
298         --disable-libjava-multilib \
299 %endif
300 %endif
301 %if !%{build_with_mudflap}
302         --disable-libmudflap \
303 %endif
304         --with-slibdir=/%{_lib} \
305         --with-system-zlib \
306         --enable-__cxa_atexit \
307         --enable-libstdcxx-allocator=new \
308         --disable-libstdcxx-pch \
309         --enable-version-specific-runtime-libs \
310         --enable-linker-build-id \
311 %if 0%{?gcc_target_arch:1}
312 %if 0%{?gcc_icecream:1}
313         --with-build-sysroot=/ \
314         --with-sysroot=%{_prefix}/%{gcc_target_arch}%{?canonical_target_abi:%canonical_target_abi} \
315         --with-gxx-include-dir=%{_prefix}/%{gcc_target_arch}%{?canonical_target_abi:%canonical_target_abi}/usr/include/c++/%{gcc_dir_version} \
316         --enable-linux-futex \
317 %endif
318 %if 0%{?canonical_target:1}
319         --with-build-time-tools=/usr/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}/bin \
320 %endif
321 %if 0%{?sysroot:1}
322         --with-sysroot=%sysroot \
323 %endif
324 %if 0%{?build_static:1}
325         --disable-shared \
326 %endif
327 %if "%{TARGET_ARCH}" == "spu"
328         --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
329         --with-newlib \
330 %endif
331         --disable-nls \
332         --target=%{CONFIGURE_TARGET} \
333 %else
334         --program-suffix=%{binsuffix} \
335         --enable-linux-futex \
336 %ifarch ia64
337         --with-system-libunwind \
338 %else
339         --without-system-libunwind \
340 %endif
341 %endif
342 %if "%{TARGET_ARCH}" == "armv5tel"
343         --with-arch=armv5te \
344         --with-float=soft \
345         --with-mode=arm \
346         --with-abi=aapcs-linux \
347         --disable-sjlj-exceptions \
348 %endif
349 %if "%{TARGET_ARCH}" == "armv7l" 
350         --with-arch=armv7-a \
351         --with-tune=cortex-a9 \
352     --with-float=soft \
353         --with-fpu=vfpv3-d16 \
354         --disable-sjlj-exceptions \
355 %endif
356 %if  "%{TARGET_ARCH}" == "armv7hl"
357         --with-arch=armv7-a \
358         --with-tune=cortex-a9 \
359         --with-float=hard \
360         --with-abi=aapcs-linux \
361         --with-fpu=vfpv3-d16 \
362         --disable-sjlj-exceptions \
363 %endif
364 %if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
365 %if "%{TARGET_ARCH}" == "powerpc"
366         --with-cpu=default32 \
367 %endif
368         --with-cpu-64=power4 \
369         --enable-secureplt \
370         --with-long-double-128 \
371 %endif
372 %if "%{TARGET_ARCH}" == "sparc64"
373         --with-cpu=ultrasparc \
374         --with-long-double-128 \
375 %endif
376 %if "%{TARGET_ARCH}" == "sparc"
377         --with-cpu=v8 \
378         --with-long-double-128 \
379 %endif
380 %if "%{TARGET_ARCH}" == "i586"
381         --with-arch-32=i586 \
382         --with-tune=generic \
383 %endif
384 %if "%{TARGET_ARCH}" == "x86_64"
385         --with-arch-32=i586 \
386         --with-tune=generic \
387 %endif
388 %if "%{TARGET_ARCH}" == "s390"
389         --with-tune=z196 --with-arch=z10 \
390         --with-long-double-128 \
391         --enable-decimal-float \
392 %endif
393 %if "%{TARGET_ARCH}" == "s390x"
394         --with-tune=z196 --with-arch=z10 \
395         --with-long-double-128 \
396         --enable-decimal-float \
397 %endif
398         --build=%{GCCDIST}
399
400
401 make %{?jobs:-j%jobs} all-gcc TARGET-gcc="cc1 cc1plus gcc-cross xg++ native"
402
403 %install
404 cd obj-%{GCCDIST}
405 rm -rf $RPM_BUILD_ROOT
406 make -C gcc DESTDIR=$RPM_BUILD_ROOT/inst install-driver install-common
407 make DESTDIR=$RPM_BUILD_ROOT/inst maybe-install-lto-plugin
408
409 # But the assembler comes from the cross-binutils, and hence is _not_
410 # named funnily, not even on ppc, so there we need the original target
411 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
412         $RPM_BUILD_ROOT/env/usr/bin/as
413 install -s $RPM_BUILD_ROOT/inst%{_prefix}/bin/%{CONFIGURE_TARGET}-g++ \
414         $RPM_BUILD_ROOT/env/usr/bin/g++
415 install -s $RPM_BUILD_ROOT/inst%{_prefix}/bin/%{CONFIGURE_TARGET}-gcc \
416         $RPM_BUILD_ROOT/env/usr/bin/gcc
417
418 %define targetlibsubdir %{_libdir}/gcc/%{CONFIGURE_TARGET}/%{gcc_dir_version}
419 for back in cc1 cc1plus; do 
420         install -s -D $RPM_BUILD_ROOT/inst%{targetlibsubdir}/$back \
421                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
422 done
423 if test -f $RPM_BUILD_ROOT/inst%{targetlibsubdir}/liblto_plugin.so; then
424   install -s -D $RPM_BUILD_ROOT/inst%{targetlibsubdir}/liblto_plugin.so \
425                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
426 fi
427
428 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
429   ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }'  ;\
430 done | sort -u `
431 for lib in $libs; do
432    # Check wether the same library also exists in the parent directory,
433    # and prefer that on the assumption that it is a more generic one.
434    baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
435    test -f "$baselib" && lib=$baselib
436    install -s -D $lib $RPM_BUILD_ROOT/env$lib
437 done
438 rm -rf $RPM_BUILD_ROOT/inst
439 cd $RPM_BUILD_ROOT/env
440 tar cvzf ../%{name}_%{_arch}.tar.gz *
441 cd ..
442 mkdir -p usr/share/icecream-envs
443 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
444 rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
445 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
446 rm -r env
447 cd $RPM_BUILD_DIR
448
449 %clean
450 rm -rf $RPM_BUILD_ROOT
451
452 %files
453 %defattr(-,root,root)
454 /usr/share/icecream-envs
455
456 %changelog -n cross-armv7hl-gcc48-icecream-backend