packaging: add packaging files
[platform/upstream/gcc49.git] / packaging / cross.spec.in
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 %if %{cross_arch} == "aarch64"
45 %define binutils_target arm
46 %endif
47 %define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
48 %if %{binutils_target} == "arm"
49 %define canonical_target_abi -gnueabi
50 %endif
51
52 %if 0%{?gcc_icecream:1}
53 %define build_sysroot /
54 %endif
55
56
57 Name:         %{pkgname}
58 BuildRequires: cross-%{binutils_target}-binutils
59 BuildRequires: gcc-c++
60 BuildRequires: bison
61 BuildRequires: flex
62 BuildRequires: gettext-devel
63 BuildRequires: glibc-devel-32bit
64 BuildRequires: mpc-devel
65 BuildRequires: mpfr-devel
66 BuildRequires: perl
67 BuildRequires: makeinfo
68 BuildRequires: zlib-devel
69 %ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm
70 BuildRequires: cloog-devel
71 BuildRequires: ppl-devel
72 %endif
73 BuildRequires: cross-$cross_arch_cpu-binutils
74 %ifarch ia64
75 BuildRequires: libunwind-devel
76 %endif
77 %if 0%{!?gcc_icecream:1}
78 BuildRequires: cross-%cross_arch-glibc-devel
79 %endif
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 %define _prefix /opt/cross
91
92 %package -n cross-%cross_arch-gcc@base_ver@-icecream-backend
93 Summary: Icecream backend for the GNU C Compiler
94 Group:  Development/Languages/C and C++
95
96 %description -n cross-%cross_arch-gcc@base_ver@-icecream-backend
97 This package contains the icecream environment for the GNU C Compiler
98
99
100 %define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
101
102 %install
103 cd obj-%{GCCDIST}
104
105 # install and fixup host parts
106 make DESTDIR=$RPM_BUILD_ROOT install-host
107 # with the present setup fixincludes are for the build includes which
108 # is wrong - get rid of them
109 rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/include-fixed
110 rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
111 # common fixup
112 rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
113 # remove docs
114 rm -rf $RPM_BUILD_ROOT%{_mandir}
115 rm -rf $RPM_BUILD_ROOT%{_infodir}
116
117
118 # install and fixup target parts
119 # ???  don't do this - debugedit is not prepared for this and crashes
120 # so expect the sysroot to be populated from natively built binaries
121 #%if 0%{?sysroot:1}
122 #make DESTDIR=$RPM_BUILD_ROOT/%{sysroot} install-target
123 #%else
124 #make DESTDIR=$RPM_BUILD_ROOT/%{_prefix}/%{gcc_target_arch} install-target
125 #%endif
126
127
128 # Build an icecream environment
129 # The assembler comes from the cross-binutils, and hence is _not_
130 # named funnily, not even on ppc, so there we need the original target
131 install -s -D %{_prefix}/bin/%{canonical_target}-tizen-linux%{?canonical_target_abi:%canonical_target_abi}-as \
132         $RPM_BUILD_ROOT/env/usr/bin/as
133 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
134         $RPM_BUILD_ROOT/env/usr/bin/g++
135 install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
136         $RPM_BUILD_ROOT/env/usr/bin/gcc
137
138 for back in cc1 cc1plus; do 
139         install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
140                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
141 done
142 if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
143   install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
144                 $RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
145 fi
146
147 # Make sure to also pull in all shared library requirements for the
148 # binaries we put into the environment which is operated by chrooting
149 # into it and execing the compiler
150 libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
151   ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }'  ;\
152 done | sort -u `
153 for lib in $libs; do
154   # Check wether the same library also exists in the parent directory,
155   # and prefer that on the assumption that it is a more generic one.
156   baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
157   test -f "$baselib" && lib=$baselib
158   install -s -D $lib $RPM_BUILD_ROOT/env$lib
159 done
160
161 cd $RPM_BUILD_ROOT/env
162 tar cvzf ../%{name}_%{_arch}.tar.gz *
163 cd ..
164 mkdir -p usr/share/icecream-envs
165 mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
166 rpm -q --changelog glibc >  usr/share/icecream-envs/%{name}_%{_arch}.glibc
167 rpm -q --changelog binutils >  usr/share/icecream-envs/%{name}_%{_arch}.binutils
168 rm -r env
169
170 %files
171 %defattr(-,root,root)
172 %{_prefix}/bin
173 %dir %{targetlibsubdir}
174 %dir %{_libdir}/gcc/%{gcc_target_arch}
175 %{targetlibsubdir}
176
177 %files -n cross-%cross_arch-gcc@base_ver@-icecream-backend
178 %defattr(-,root,root)
179 /usr/share/icecream-envs
180
181 EOF