LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File cross-obs.spec.in of Package orig-gcc44 (Project Ports:ARM:Base:build:cross)

#! /bin/sh

#
# call this via pre_checkin.sh
#
# 2005-05-09, jw@suse.de

test -z "$cross_arch" && echo 1>&2 "Error: $0 needs environment variable 'cross_arch'"
test -z "$outfile" && echo 1>&2 "Error: $0 needs environment variable 'outfile'"
cross_arch_cpu=`echo $cross_arch | sed -e 's/\([^-]*\)-\?.*/\1/'`
cross_short=`echo $cross_arch_cpu | sed -e 's/armv5tel/armv5/' -e 's/armv7l/armv7/'`

cat << EOF
#
# spec file for package gcc (Version 4.0.1)
#
# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://www.suse.de/feedback/
#

# norootforbuild

%define build_cp 1
%define build_ada 0
%define build_java 0
%define build_libjava 0
%define build_fortran 0
%define build_objc 0
%define build_objcp 0
%define build_nof 0
%define gcc_for_opt 0
%define gcc_target_arch $cross_arch

Name:         cross-$cross_arch-gcc44-obs
BuildRequires: cross-$cross_arch_cpu-linux-kernel-headers
BuildRequires: cross-$cross_arch_cpu-gcc
BuildRequires: cross-$cross_arch_cpu-binutils
BuildRequires: glibc-cross_$cross_short
BuildRequires: glibc-devel-cross_$cross_short
BuildRequires: bison flex gettext-devel glibc-devel texinfo zlib-devel
BuildRequires: dejagnu expect perl mpfr-devel gmp-devel libstdc++44 
ExclusiveArch: i586
AutoReqProv:   off
# cloog-devel ppl-devel ppl-devel-static
Source990:    cross-gcc.rpmlintrc
EOF
sed -n -e '/COMMON-BEGIN/,/COMMON-END/p' $outfile | sed -n -e '1,/%description/p' | sed -e 's/Autoreqprov:.*on/Autoreqprov:    off/'
cat << EOF
This compiler supports the C language on $cross_arch microprocessors.
Also install cross-$cross_arch-binutils and $cross_arch-libc.


EOF
sed -n -e '/%description/,$p' $outfile | sed -n -e '/COMMON-BEGIN/,/COMMON-END/p' | \
sed -n -e '/prep/,/cat gcc\/FULL-VER/p' |sed -e 's/%patch51//'

cat << EOF

%define HOST %(echo %{_target_cpu}|sed -e "s/parisc/hppa/" -e "s/i.86/i586/" -e "s/ppc/powerpc/")-suse-linux
%if "%{name}" != "gcc"
%define TARGET %(echo %{name} | sed -e "s/cross-\\\\(.*\\\\)-gcc44-obs/\\\\1/;s/-/_/g;s/parisc/hppa/;s/i.86/i586/;s/ppc/powerpc/")
%else
%define TARGET %{_target_cpu}
%endif

#
# TARGET-TUPLE
#
%if "%{TARGET}" == "avr" || "%{TARGET}" == "spu"
%define TARGET_OS %{TARGET}
%else
%define TARGET_OS %{TARGET}-suse-linux-gnu
%endif
%if "%{TARGET}" == "armv5tel"
%define TARGET_OS %{TARGET}-suse-linux-gnueabi
%endif
%if "%{TARGET}" == "armv7l"
%define TARGET_OS %{TARGET}-suse-linux-gnueabi
%endif
%if "%{TARGET}" == "mips"
%define TARGET_OS %{TARGET}-suse-linux-gnueabi
%endif

#
# HOST TUPLE
#
%define HOST_OS %{HOST}-gnu

%if "%{HOST}" == "arm-suse-linux"
%define HOST_OS %{HOST}-gnueabi
%endif
%if "%{HOST}" == "mips-suse-linux"
%define HOST_OS %{HOST}-gnueabi
%endif


%define TARGET_SYSROOT /opt/cross/%{TARGET_OS}/sys-root
%define TARGET_HEADERS /opt/cross/%{TARGET_OS}/sys-root/usr/include
%define _prefix /usr

export PATH=/opt/cross/%{TARGET_OS}/bin:\$PATH

J=%{?jobs:%jobs}
if test -z "\$J"; then
  J=$(getconf _NPROCESSORS_CONF)
  JL=\$((\$J * 2))
else
  test 1 -gt "\$J" && J=1
  JL=\$((\$(getconf _NPROCESSORS_CONF)*2))
fi
if test "\$J" == "0"; then
  J=1
fi
if test "\$JL" == "0"; then
  JL=1
fi
PARALLEL="-j\$J -l\$JL"


#%#if "%{TARGET}" == "i586"
# force cross-compilation even on i586 host/target !
#for i in \`find . -type f -executable -name configure\` ; do sed -i \$i -e 's/cross_compiling=no/cross_compiling=yes/' ; sed -i \$i -e 's/is_cross_compiler=no/is_cross_compiler=yes/'; done
#sed -i libgcc/configure -e 's/gcc_no_link=no/gcc_no_link=yes/'
#%#define HOST i686-suse-linux
#%#endif

mkdir gcc-build
export CFLAGS="-O2 -g -static -Wl,-static"
# -Wl,-rpath -Wl,/emul/ia32-linux/usr/lib:/emul/ia32-linux/lib -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables  -fPIC -DPIC"
#export BOOT_CFLAGS="-Wl,-rpath -Wl,/emul/ia32-linux/usr/lib:/emul/ia32-linux/lib -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fPIC -DPIC"
#export CFLAGS_FOR_TARGET="-Wl,-rpath -Wl,/emul/ia32-linux/usr/lib:/emul/ia32-linux/lib -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables  -fPIC -DPIC"
export AS_FOR_TARGET="/opt/cross/%{TARGET_OS}/bin/%{TARGET_OS}-as"
export LD_FOR_TARGET="/opt/cross/%{TARGET_OS}/bin/%{TARGET_OS}-ld"
export NM_FOR_TARGET="/opt/cross/%{TARGET_OS}/bin/%{TARGET_OS}-nm"
export AR_FOR_TARGET="/opt/cross/%{TARGET_OS}/bin/%{TARGET_OS}-ar"
export RANLIB_FOR_TARGET="/opt/cross/%{TARGET_OS}/bin/%{TARGET_OS}-ranlib"

cd gcc-build

    CC="gcc" \\
    ../configure \\
        --prefix=%{_prefix} \\
        --infodir=%{_infodir} \\
        --mandir=%{_mandir} \\
        --libdir=%{_prefix}/lib \\
        --libexecdir=%{_prefix}/lib \\
        --build=%{HOST} \\
        --host=%{HOST} \\
        --target=%{TARGET_OS} \\
        --enable-languages=c,c++ \\
        --enable-checking=release \\
        --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \\
        --enable-ssp \\
        --disable-libssp \\
        --with-bugurl=http://bugs.opensuse.org/ \\
        --with-pkgversion='SUSE Linux' \\
        --disable-libgcj \\
        --disable-libmudflap \\
        --with-slibdir=/lib \\
        --enable-__cxa_atexit \\
        --disable-libstdcxx-pch \\
        --enable-libstdcxx-allocator=new \\
        --enable-version-specific-runtime-libs \\
        --enable-threads=posix \\
        --without-system-libunwind \\
        --enable-linux-futex \\
        --program-transform-name='s/%{TARGET_OS}-//' \\
        --program-suffix=-4.4 \\
        --enable-c99 \\
        --enable-long-long \\
        --with-sysroot=/ \\
        --with-build-sysroot=%{TARGET_SYSROOT}

################ BIG FIXME !! ###########################
# * either something is broken in gcc makefiles or ?
# * something is broken in libtool ?
# * PEBCAK ?
# * underlying toolchain error ?
#
# Problem: although --with-build-sysroot is set, the libraries
#          aren't picked up by the linker in final stage
#          (the files are in /{/lib,/usr/lib}
# Workaround: copy in searchpath ...
#########################################################
mkdir gcc
cp %{TARGET_SYSROOT}/usr/lib/crt*.o gcc/
cp %{TARGET_SYSROOT}/usr/lib/libdl.* gcc/
cp %{TARGET_SYSROOT}/usr/lib/libc* gcc/
cp %{TARGET_SYSROOT}/lib/libc.* gcc/
cp %{TARGET_SYSROOT}/lib/ld-* gcc/
cp %{TARGET_SYSROOT}/usr/lib/librt* gcc/
cp %{TARGET_SYSROOT}/usr/lib/libpthr* gcc/
cp %{TARGET_SYSROOT}/lib/libpthr* gcc/


make \$PARALLEL





%install
export PATH=/opt/cross/%{TARGET_OS}/bin:\$PATH

cd gcc-build
make DESTDIR=%buildroot install

rm -rRf %buildroot/%{_libdir}/libiberty.a || true
rm -rRf %buildroot/%{_prefix}/share || true
rm -rRf %buildroot/%{_prefix}/bin/gccbug* || true
rm -rRf %buildroot/%{_prefix}/bin/c++-* || true
rm -rRf %buildroot/%{_prefix}/%{TARGET_OS} || true
rm -rRf %buildroot/lib/libgcc_s.so || true
ln -sf /lib/libgcc_s.so.1 %buildroot/%{_prefix}/lib/gcc/%{TARGET_OS}/%{gcc_dir_version}/libgcc_s.so
ln -s ../../../libgomp.so.1 %buildroot/%{_prefix}/lib/gcc/%{TARGET_OS}/%{gcc_dir_version}/libgomp.so
cp %buildroot/%{_prefix}/lib/gcc/%{TARGET_OS}/%{gcc_dir_version}/libstdc++.s* %buildroot/%{_prefix}/lib/

cat << MYEOF > remove
/usr/include
/lib/libgcc_s.so.1
/usr/bin/%{TARGET_OS}-gcc-4.4
/usr/lib/gcc/%{TARGET_OS}/4.4/include-fixed/linux
/usr/lib/gcc/%{TARGET_OS}/4.4/include-fixed/linux/a.out.h
/usr/lib/gcc/%{TARGET_OS}/4.4/include/mf-runtime.h
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/fixincl
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/fixinc_list
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/fixinc.sh
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/gsyslimits.h
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/include
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/include/limits.h
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/include/README
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/macro_list
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/mkheaders
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/mkheaders.conf
/usr/lib/gcc/%{TARGET_OS}/4.4/install-tools/mkinstalldirs
/usr/lib/gcc/%{TARGET_OS}/4.4/libgomp.la
/usr/lib/gcc/%{TARGET_OS}/4.4/libmudflap.a
/usr/lib/gcc/%{TARGET_OS}/4.4/libmudflap.la
/usr/lib/gcc/%{TARGET_OS}/4.4/libmudflapth.a
/usr/lib/gcc/%{TARGET_OS}/4.4/libmudflapth.la
/usr/lib/gcc/%{TARGET_OS}/4.4/libstdc++.a
/usr/lib/gcc/%{TARGET_OS}/4.4/libstdc++.la
/usr/lib/gcc/%{TARGET_OS}/4.4/libstdc++.so
/usr/lib/gcc/%{TARGET_OS}/4.4/libstdc++.so.6
/usr/lib/gcc/%{TARGET_OS}/4.4/libstdc++.so.6.0.12
/usr/lib/gcc/%{TARGET_OS}/4.4/libsupc++.a
/usr/lib/gcc/%{TARGET_OS}/4.4/libsupc++.la
/usr/lib/libstdc++.so
/usr/lib/libstdc++.so.6
/usr/lib/libstdc++.so.6.0.12
MYEOF

for i in \$(cat remove) ; do
echo "removing: %buildroot/\$i" ; rm -rRf %buildroot/\$i || true ; done



%clean
rm -rf \$RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%{_bindir}/*
%{_prefix}/lib/*


%changelog -n cross-$cross_arch-gcc44-obs

EOF