Enable LTO builds using this toolchain
[platform/upstream/gcc49.git] / packaging / cross.spec.sh
1 #! /bin/sh
2
3 #
4 # call this via pre_checkin.sh
5 #
6 # 2005-05-09, jw@suse.de
7
8 test -z "$cross_arch" && echo 1>&2 "Error: $0 needs environment variable 'cross_arch'"
9 test -z "$outfile" && echo 1>&2 "Error: $0 needs environment variable 'outfile'"
10 cross_arch_cpu=`echo $cross_arch | sed -e 's/\([^-]*\)-\?.*/\1/'`
11
12 cat << EOF
13 #
14 # spec file for package gcc (Version 4.8.2)
15 #
16 # Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany.
17 # This file and all modifications and additions to the pristine
18 # package are under the same license as the package itself.
19 #
20 # Please submit bugfixes or comments via http://www.suse.de/feedback/
21 #
22
23 %define build_cp 1
24 %define build_ada 0
25 %define build_libjava 0
26 %define build_java 0
27
28 %define build_fortran 0
29 %define build_objc 0
30 %define build_objcp 0
31 %define build_go 0
32 %define gcc_target_arch $cross_arch
33
34 %define binutils_target %{cross_arch}
35 %if %{cross_arch} == "armv7l" || %{cross_arch} == "armv7hl"
36 %define binutils_target arm
37 %endif
38 %if %{cross_arch} == "armv6l" || %{cross_arch} == "armv6hl"
39 %define binutils_target arm
40 %endif
41 %if %{cross_arch} == "armv5tel"
42 %define binutils_target arm
43 %endif
44 %define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
45 %if %{binutils_target} == "arm"
46 %define canonical_target_abi -gnueabi
47 %endif
48
49 %if 0%{?gcc_icecream:1}
50 %define build_sysroot /
51 %endif
52
53
54 Name:         %{pkgname}
55 ExclusiveArch: %{ix86} x86_64
56 BuildRequires: cross-%{binutils_target}-binutils
57 BuildRequires: gcc-c++
58 BuildRequires: bison
59 BuildRequires: flex
60 BuildRequires: gettext-devel
61 BuildRequires: glibc-devel-32bit
62 BuildRequires: mpc-devel
63 BuildRequires: mpfr-devel
64 BuildRequires: perl
65 BuildRequires: makeinfo
66 BuildRequires: zlib-devel
67 %ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm
68 BuildRequires: cloog-devel
69 BuildRequires: ppl-devel
70 %endif
71 %ifarch ia64
72 BuildRequires: libunwind-devel
73 %endif
74 %if 0%{!?gcc_icecream:1}
75 BuildRequires: cross-%cross_arch-glibc-devel
76 %endif
77
78 Requires(post):    update-alternatives
79 Requires(postun):  update-alternatives
80
81 # COMMON-BEGIN
82 # COMMON-END
83
84 %if 0%{!?gcc_icecream:1}
85 make %{?jobs:-j%jobs}
86 %else
87 make %{?jobs:-j%jobs} all-host
88 %endif
89
90 %package -n cross-%cross_arch-gcc@base_ver@-icecream-backend
91 Summary: Icecream backend for the GNU C Compiler
92 Group:  Development/Languages/C and C++
93
94 %description -n cross-%cross_arch-gcc@base_ver@-icecream-backend
95 This package contains the icecream environment for the GNU C Compiler
96
97
98 %define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
99
100 %install
101 cd obj-%{GCCDIST}
102
103 # install and fixup host parts
104 make DESTDIR=\$RPM_BUILD_ROOT install-host
105 # with the present setup fixincludes are for the build includes which
106 # is wrong - get rid of them
107 rm -rf \$RPM_BUILD_ROOT/%{targetlibsubdir}/include-fixed
108 rm -f \$RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
109 # common fixup
110 rm -f \$RPM_BUILD_ROOT%{_libdir}/libiberty.a
111
112 # remove docs and disable automated generation
113 %remove_docs
114 %define disable_docs_package 1
115
116 # install and fixup target parts
117 # ???  don't do this - debugedit is not prepared for this and crashes
118 # so expect the sysroot to be populated from natively built binaries
119 #%if 0%{?sysroot:1}
120 #make DESTDIR=\$RPM_BUILD_ROOT/%{sysroot} install-target
121 #%else
122 #make DESTDIR=\$RPM_BUILD_ROOT/%{_prefix}/%{gcc_target_arch} install-target
123 #%endif
124
125
126 # Build an icecream environment
127 # The assembler comes from the cross-binutils, and hence is _not_
128 # named funnily, not even on ppc, so there we need the original target
129 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
130         \$RPM_BUILD_ROOT/env/usr/bin/as
131 install -s \$RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
132         \$RPM_BUILD_ROOT/env/usr/bin/g++
133 install -s \$RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
134         \$RPM_BUILD_ROOT/env/usr/bin/gcc
135
136 for back in cc1 cc1plus collect2 lto1 lto-wrapper; do
137         install -s -D \$RPM_BUILD_ROOT/%{targetlibsubdir}/\$back \
138                 \$RPM_BUILD_ROOT/env%{targetlibsubdir}/\$back
139 done
140 if test -f \$RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
141   install -s -D \$RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
142                 \$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
143 fi
144
145 # Make sure to also pull in all shared library requirements for the
146 # binaries we put into the environment which is operated by chrooting
147 # into it and execing the compiler
148 libs=\`for bin in \$RPM_BUILD_ROOT/env/usr/bin/* \$RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
149   ldd \$bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }'  ;\
150 done | sort -u\`
151 for lib in \$libs; do
152   # Check wether the same library also exists in the parent directory,
153   # and prefer that on the assumption that it is a more generic one.
154   baselib=\`echo "\$lib" | sed 's,/[^/]*\(/[^/]*\)\$,\1,'\`
155   test -f "\$baselib" && lib=\$baselib
156   install -s -D \$lib \$RPM_BUILD_ROOT/env\$lib
157 done
158
159 cd \$RPM_BUILD_ROOT/env
160 %if 0%{?gcc_icecream:1}
161 tar cvzf ../%{name}-icecream-backend_%{_arch}.tar.gz *
162 %else
163 tar cvzf ../%{name}_%{_arch}.tar.gz *
164 %endif
165 cd ..
166 mkdir -p usr/share/icecream-envs
167 %if 0%{?gcc_icecream:1}
168 mv %{name}-icecream-backend_%{_arch}.tar.gz usr/share/icecream-envs
169 %else
170 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
171 %endif
172 rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
173 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
174 rm -r env
175
176 # liblto_plugin alternatives
177 mkdir -p "\$RPM_BUILD_ROOT%{bfd_plugin_dir}"
178 touch "\$RPM_BUILD_ROOT%{bfd_plugin_lto}"
179
180 %post
181 "%_sbindir/update-alternatives" --install \\
182     "%{bfd_plugin_lto}" "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}" 5
183
184 %preun
185 "%_sbindir/update-alternatives" --remove "%{bfd_plugin_lto_name}" "%{gcc_plugin_lto}"
186
187
188 %files
189 %defattr(-,root,root)
190 %{_prefix}/bin/*
191 %dir %{targetlibsubdir}
192 %dir %{_libdir}/gcc/%{gcc_target_arch}
193 %{targetlibsubdir}
194 %ghost %{bfd_plugin_lto}
195
196 %files -n cross-%cross_arch-gcc@base_ver@-icecream-backend
197 %defattr(-,root,root)
198 /usr/share/icecream-envs
199
200 EOF