LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File cross-final.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-gcc
BuildRequires: cross-$cross_arch_cpu-linux-kernel-headers
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 x86_64
Provides:     cross-$cross_arch-8-gcc
# cloog-devel ppl-devel ppl-devel-static
Requires:     cross-$cross_arch_cpu-binutils
Requires:     glibc-cross_$cross_short
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'

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-\\\\(.*\\\\)-gcc/\\\\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


%if "%{name}" != "gcc"
%define _prefix /opt/cross/%{TARGET_OS}
%define TARGET_SYSROOT %{_prefix}/sys-root
%define TARGET_HEADERS %{_prefix}/sys-root/usr/include
%else
%define _prefix /usr
%endif

export PATH=%{_prefix}/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 -fPIC -DPIC"
export CFLAGS_FOR_TARGET="$RPM_OPT_FLAGS -fPIC -DPIC -isystem %{TARGET_SYSROOT} -isystem %{TARGET_HEADERS}"
cd gcc-build
    CC="gcc" \\
    ../configure \\
        --prefix=%{_prefix} \\
        --libdir=%{_prefix}/lib \\
        --libexecdir=%{_prefix}/lib \\
        --build=%{HOST} \\
        --host=%{HOST} \\
        --target=%{TARGET_OS} \\
        --disable-bootstrap \\
        --disable-newlib \\
        --disable-multilib \\
        --disable-libssp \\
        --disable-nls \\
        --enable-shared \\
        --enable-static \\
        --enable-__cxa_atexit \\
        --enable-c99 \\
        --enable-long-long \\
        --enable-threads=posix \\
        --enable-languages=c,c++ \\
        --with-sysroot=%{TARGET_SYSROOT}

export LDFLAGS_FOR_TARGET="--sysroot=%{TARGET_SYSROOT}"
export CPPFLAGS_FOR_TARGET="--sysroot=%{TARGET_SYSROOT}"

make RANLIB_FOR_TARGET="%{_prefix}/bin/%{TARGET_OS}-ranlib" AS_FOR_TARGET="%{_prefix}/bin/%{TARGET_OS}-as" LD_FOR_TARGET="%{_prefix}/bin/%{TARGET_OS}-ld" \$PARALLEL

%install
export PATH=%{_prefix}/bin:\$PATH
cd gcc-build
export LDFLAGS_FOR_TARGET="--sysroot=%{TARGET_SYSROOT}"
export CPPFLAGS_FOR_TARGET="--sysroot=%{TARGET_SYSROOT}"
make DESTDIR=%buildroot install
rm -f \$RPM_BUILD_ROOT%{_libdir}/libiberty.a || true


%clean
rm -rf \$RPM_BUILD_ROOT


%files
%defattr(-,root,root)
%{_prefix}

%changelog -n cross-$cross_arch-gcc

EOF

#cat << EOF
#
#make %{?jobs:-j%jobs} 
#
#%install
#cd obj-%{GCCDIST}
#make install DESTDIR=\$RPM_BUILD_ROOT
## ln -s $cross_arch-elf-gcc \$RPM_BUILD_ROOT/%{_prefix}/bin/$cross_arch-gcc
#rm -rf \$RPM_BUILD_ROOT/%{_prefix}/share
#rm \$RPM_BUILD_ROOT/%{_libdir}/libiberty.a
## The libgcc.a that is not inside an avr* subdirectory is for avr2. 
## rm \$RPM_BUILD_ROOT/%{_libdir}/gcc/*/*/{libgcc.a,libgcov.a}
#rmdir \$RPM_BUILD_ROOT/%{_prefix}/include
#
#%clean
#rm -rf \$RPM_BUILD_ROOT
#
#%files
#%defattr(-,root,root)
#%{_prefix}
#
#%changelog -n cross-$cross_arch-gcc
#EOF