Add armv7l support.
[platform/upstream/gcc47.git] / packaging / cross-i386-gcc47-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 i386-tizen-linux
21 %define gcc_icecream 1
22
23 %define binutils_target i386
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-i386-gcc47-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 x86_64 ia64 
54 %define _binary_payload w.ufdio
55
56 # COMMON-BEGIN
57 # COMMON-BEGIN
58 %define biarch_targets x86_64 
59
60 URL:          http://gcc.gnu.org/
61 Version: 4.7.2
62 Release:      1
63 %define gcc_version %(echo %version | sed 's/_.*//')
64 %define gcc_dir_version %(echo %gcc_version | cut -d '.' -f 1-2)
65 %define snapshot_date %(echo %version | sed 's/[34]\.[0-9]\.[0-6]//' | sed 's/_/-/')
66 %define binsuffix -4.7
67 # COMMON-END
68 # COMMON-BEGIN
69 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
70 #Source:                gcc-%{gcc_version}%{snapshot_date}.tar.bz2
71 Source:     gcc-%{version}.tar.bz2
72
73 Source1:        change_spec
74 Source2:        libgcj47-rpmlintrc
75 Source3:        gcc47-rpmlintrc
76 Source4:        ecj.jar
77 Source6:        baselibs.conf
78 # Patches auto-generated by git-buildpackage:
79 Patch0:     0001-dir-version.patch
80 Patch1:     0002-textdomain.patch
81 Patch2:     0003-rename-info-files.patch
82 Patch3:     0004-ARM-linker.patch
83
84 # GCC-TESTSUITE-DELETE-BEGIN
85 # LIBFFI-DELETE-BEGIN
86 # LIBJAVA-DELETE-BEGIN
87 Group:          Development/Toolchain
88 Summary:        The GNU C Compiler and Support Files
89 License:        GPL-3.0+
90
91 %description
92 Core package for the GNU Compiler Collection, including the C language
93 frontend.
94
95 Language frontends other than C are split to different sub-packages,
96 namely gcc-ada, gcc-c++, gcc-fortran, gcc-java, gcc-objc and
97 gcc-obj-c++.
98
99
100
101 # COMMON-END
102 # COMMON-BEGIN
103
104 # Define the canonical target and host architecture
105 #   %gcc_target_arch  is supposed to be the full target triple
106 #   %TARGET_ARCH      is the canonicalized CPU part
107 #   %CONFIGURE_TARGET is the target triple used for --target=
108 %if 0%{?gcc_target_arch:1}
109 %define CONFIGURE_TARGET %{gcc_target_arch}
110 %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/;")
111 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "i586"
112 %define CONFIGURE_TARGET i586-tizen-linux
113 %endif
114 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7l"
115 %define CONFIGURE_TARGET armv7l-tizen-linux-gnueabi
116 %endif
117 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7hl"
118 %define CONFIGURE_TARGET armv7hl-tizen-linux-gnueabi
119 %endif
120 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv7el"
121 %define CONFIGURE_TARGET armv7el-tizen-linux-gnueabi
122 %endif
123 %if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "armv5el"
124 %define CONFIGURE_TARGET armv5el-tizen-linux-gnueabi
125 %endif
126 %else
127 %define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
128 %endif
129 %define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
130
131 %define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
132
133 %ifarch %arm
134 %define GCCDIST %{HOST_ARCH}-tizen-linux-gnueabi
135 %else
136 %define GCCDIST %{HOST_ARCH}-tizen-linux
137 %endif
138
139 %define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
140 %define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
141
142 # COMMON-END
143 # COMMON-BEGIN
144
145 %prep
146 #%setup -q -n gcc-%{gcc_version}%{snapshot_date}
147 %setup -q -n gcc-%{version}
148 # 0001-dir-version.patch
149 %patch0 -p1
150 %patch1 -p1
151 %patch2 -p1
152 %patch3 -p1
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 %if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
184 # Kill all -march/tune/cpu because that screws building the target libs
185 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
186 %endif
187 # Replace 2 spaces by one finally
188 RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/  / /g'`
189
190 languages=c
191 %if %{build_cp}
192 languages=$languages,c++
193 %endif
194 %if %{build_objc}
195 languages=$languages,objc
196 %endif
197 %if %{build_fortran}
198 languages=$languages,fortran
199 %endif
200 %if %{build_objcp}
201 languages=$languages,obj-c++
202 %endif
203 %if %{build_java}
204 languages=$languages,java
205 %endif
206 %if %{build_ada}
207 languages=$languages,ada
208 %endif
209
210 J=%{?jobs:%jobs}
211 if test -z "$J"; then
212   J=$(getconf _NPROCESSORS_CONF)
213   JL=$(($J * 2))
214 else
215   test 1 -gt "$J" && J=1
216   JL=$(($(getconf _NPROCESSORS_CONF)*2))
217 fi
218 if test "$J" == "0"; then
219   J=1
220 fi
221 if test "$JL" == "0"; then
222   JL=1
223 fi
224 PARALLEL="-j$J -l$JL"
225
226 # we don't want some miscompiles in the testsuite, or some fault in
227 # the compiler to kill the machine.  Hence we limit the amount of memory
228 # by the physical RAM plus half of swap
229 #MEM=$(free -m | awk '/^Mem:/ {print $2}')
230 #SWAP=$(free -m | awk '/^Swap:/ {print $2}')
231 #ulimit -v $(((MEM + SWAP/2)*1024))
232
233 # In general we want to ship release checking enabled compilers
234 # and run BETA with checking enabled.
235 #ENABLE_CHECKING="--enable-checking=yes"
236 ENABLE_CHECKING="--enable-checking=release"
237
238 # Work around tail/head -1 changes
239 export _POSIX2_VERSION=199209
240
241 # configure tries to parse include/features.h to detect
242 # if glibc supports SSP.  When cross compiling we would need
243 # to install a cross glibc, which we don't, or make the whole
244 # thing point to the native glibc, which is in /, hence the
245 # --with-sysroot=/
246
247 %if %{build_ada}
248 # Using the host gnatmake like
249 #   CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
250 #   GNATMAKE="gnatmake%{hostsuffix}"
251 # doesn't work due to PR33857, so an un-suffixed gnatmake has to be
252 # available
253 mkdir -p host-tools/bin
254 cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
255 cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
256 cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
257 cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
258 ln -sf /usr/%{_lib} host-tools/%{_lib}
259 export PATH="`pwd`/host-tools/bin:$PATH"
260 %endif
261 #%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
262 #%else
263 #       --enable-threads=posix \
264 #%endif
265 #       --enable-shared \
266 CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
267 TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \
268 ../configure \
269         --prefix=%{_prefix} \
270         --infodir=%{_infodir} \
271         --mandir=%{_mandir} \
272         --libdir=%{_libdir} \
273         --libexecdir=%{_libdir} \
274         --enable-languages=$languages \
275         $ENABLE_CHECKING \
276         --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
277         --enable-ssp \
278         --disable-libssp \
279         --disable-libitm \
280 %if 0%{?fast_build}
281         --disable-bootstrap \
282 %endif
283         --disable-plugin \
284         --with-bugurl="http://bugs.tizen.org/" \
285         --with-pkgversion="Tizen Linux" \
286 %if !%{build_libjava}
287         --disable-libgcj \
288 %else
289         --with-java-home=%{_libdir}/jvm/java-1.5.0-gcj%{binsuffix}-1.5.0.0/jre \
290         --with-ecj-jar=%{libsubdir}/ecj.jar \
291         --disable-java-awt \
292 %if !%{biarch_libjava}
293         --disable-libjava-multilib \
294 %endif
295 %endif
296 %if !%{build_with_mudflap}
297         --disable-libmudflap \
298 %endif
299         --with-slibdir=/%{_lib} \
300         --with-system-zlib \
301         --enable-__cxa_atexit \
302         --enable-libstdcxx-allocator=new \
303         --disable-libstdcxx-pch \
304         --enable-version-specific-runtime-libs \
305         --enable-linker-build-id \
306 %if 0%{?gcc_target_arch:1}
307 %if 0%{?gcc_icecream:1}
308         --with-build-sysroot=/ \
309         --with-sysroot=%{_prefix}/%{gcc_target_arch}%{?canonical_target_abi:%canonical_target_abi} \
310         --with-gxx-include-dir=%{_prefix}/%{gcc_target_arch}%{?canonical_target_abi:%canonical_target_abi}/usr/include/c++/%{gcc_dir_version} \
311         --enable-linux-futex \
312 %endif
313 %if 0%{?canonical_target:1}
314         --with-build-time-tools=/usr/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}/bin \
315 %endif
316 %if 0%{?build_static:1}
317         --disable-shared \
318 %endif
319 %if "%{TARGET_ARCH}" == "spu"
320         --with-sysroot=/usr/spu \
321         --with-gxx-include-dir=%{_prefix}/spu/include/c++/%{gcc_dir_version} \
322         --with-newlib \
323 %endif
324         --disable-nls \
325         --target=%{CONFIGURE_TARGET} \
326 %else
327         --program-suffix=%{binsuffix} \
328         --enable-linux-futex \
329         --without-system-libunwind \
330 %endif
331 %if "%{TARGET_ARCH}" == "armv5tel"
332         --with-arch=armv5te \
333         --with-float=soft \
334         --with-mode=arm \
335         --with-abi=aapcs-linux \
336         --disable-sjlj-exceptions \
337 %endif
338 %if "%{TARGET_ARCH}" == "armv7el" 
339         --with-arch=armv7-a \
340         --with-tune=cortex-a9 \
341         --with-float=soft \
342         --with-abi=softfp \
343         --with-fpu=vfpv3 \
344         --disable-sjlj-exceptions \
345 %endif
346 %if "%{TARGET_ARCH}" == "armv7l"
347         --with-arch=armv7-a \
348         --with-tune=cortex-a8 \
349         --with-float=softfp \
350         --with-fpu=vfpv3 \
351         --disable-sjlj-exceptions \
352 %endif
353 %if "%{TARGET_ARCH}" == "armv7hl"
354         --with-arch=armv7-a \
355         --with-tune=cortex-a9 \
356         --with-float=hard \
357         --with-abi=aapcs-linux \
358         --with-fpu=vfpv3-d16 \
359         --disable-sjlj-exceptions \
360 %endif
361 %if "%{TARGET_ARCH}" == "i586"
362         --with-arch-32=i586 \
363         --with-tune=generic \
364 %endif
365 %if "%{TARGET_ARCH}" == "x86_64"
366         --with-arch-32=i586 \
367         --with-tune=generic \
368 %endif
369         --build=%{GCCDIST}
370
371 # COMMON-END
372 # COMMON-END
373
374 make %{?jobs:-j%jobs} all-gcc TARGET-gcc="cc1 cc1plus gcc-cross g++ native"
375
376 %install
377 cd obj-%{GCCDIST}
378 rm -rf $RPM_BUILD_ROOT
379 make -C gcc DESTDIR=$RPM_BUILD_ROOT/inst install-driver install-common
380 make DESTDIR=$RPM_BUILD_ROOT/inst maybe-install-lto-plugin
381
382 # But the assembler comes from the cross-binutils, and hence is _not_
383 # named funnily, not even on ppc, so there we need the original target
384 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
385         $RPM_BUILD_ROOT/env/usr/bin/as
386 install -s $RPM_BUILD_ROOT/inst%{_prefix}/bin/%{CONFIGURE_TARGET}-g++ \
387         $RPM_BUILD_ROOT/env/usr/bin/g++
388 install -s $RPM_BUILD_ROOT/inst%{_prefix}/bin/%{CONFIGURE_TARGET}-gcc \
389         $RPM_BUILD_ROOT/env/usr/bin/gcc
390
391 %define targetlibsubdir %{_libdir}/gcc/%{CONFIGURE_TARGET}/%{gcc_dir_version}
392 for back in cc1 cc1plus; do 
393         install -s -D $RPM_BUILD_ROOT/inst%{targetlibsubdir}/$back \
394                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
395 done
396 if test -f $RPM_BUILD_ROOT/inst%{targetlibsubdir}/liblto_plugin.so; then
397   install -s -D $RPM_BUILD_ROOT/inst%{targetlibsubdir}/liblto_plugin.so \
398                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
399 fi
400
401 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
402   ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }'  ;\
403 done | sort -u `
404 for lib in $libs; do
405    # Check wether the same library also exists in the parent directory,
406    # and prefer that on the assumption that it is a more generic one.
407    baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
408    test -f "$baselib" && lib=$baselib
409    install -s -D $lib $RPM_BUILD_ROOT/env$lib
410 done
411 rm -rf $RPM_BUILD_ROOT/inst
412 cd $RPM_BUILD_ROOT/env
413 tar cvzf ../%{name}_%{_arch}.tar.gz *
414 cd ..
415 mkdir -p usr/share/icecream-envs
416 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
417 rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
418 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
419 rm -r env
420 cd $RPM_BUILD_DIR
421
422 %clean
423 rm -rf $RPM_BUILD_ROOT
424
425 %files
426 %license COPYING
427 %defattr(-,root,root)
428 /usr/share/icecream-envs
429
430 %changelog -n cross-i386-gcc47-icecream-backend