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