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