#!/bin/bash
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/crossdev/files/crossdev,v 1.86 2007/02/10 04:46:15 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/crossdev/files/crossdev,v 1.87 2007/02/17 13:50:04 vapier Exp $
cd /
umask 0022 #159111
STAGE_DISP=( "binutils" "C compiler only" "kernel headers" "C compiler & libc" "C/C++ compiler" )
parse_target() {
- [[ -z $1 ]] && usage 1
CTARGET=${1#cross-}
- local CPRE=${CTARGET%%-*} CPOST=${CTARGET#*-}
- # Did they give us just an ARCH or the full TARGET ?
- if [[ ${CTARGET/-} == ${CTARGET} || -z ${CPOST} ]] ; then
- case ${CPRE} in
- x86|i?86*|amd64|x86_64*) CPOST="pc-linux-gnu";;
- s390*) CPOST="ibm-linux-gnu";;
+ [[ -z ${CTARGET} ]] && usage 1
+
+ if [[ ${CTARGET} == "help" ]] ; then
+ cat <<-EOF
+ Supported Architectures:
+ - alpha - arm / armeb
+ - hppa (parisc) - ia64
+ - i386 / i486 / i586 / i686 (x86) - m68k
+ - mips / mipsel / mips64 / mips64el
+ - powerpc (ppc) / powerpc64 (ppc64)
+ - sparc / sparc64 - s390 / s390x
+ - sh / sh[1-5] / sh64 - x86_64 (amd64)
+ Supported C Libraries:
+ - glibc (gnu)
+ - klibc [prob wont work]
+ - newlib [bare metal/no operating system]
+ - uclibc [not all arches are ported]
+ Special Targets:
+ - avr http://www.nongnu.org/avr-libc/
+ - bfin http://blackfin.uclinux.org/
+ - h8300 http://h8300-hms.sourceforge.net/
+ - mingw32 http://www.mingw.org/
+ - msp430 http://mspgcc.sourceforge.net/
+ - nios2 http://www.altera.com/products/ip/processors/nios2/ni2-index.html
+ - xc16x http://www.infineon.com/
+ - ee / iop / dvp (ps2) [Playstation 2 targets]
+ - ppu / spu (cell) [Cell/Playstation 3 targets]
+ Softfloat toolchains:
+ Include 'softfloat' in the 'vendor' field
+ e.g. armeb-softfloat-linux-uclibc powerpc-booya_softfloat-linux-gnu
+ EOF
+ exit 0
+ fi
+
+ # Allow for laziness
+ if [[ ${CTARGET} != *-* ]] ; then
+ # First translate portage ARCH to actual tuple
+ case ${CTARGET} in
+ amd64) CTARGET="x86_64";;
+ parisc*) CTARGET=${CTARGET/parisc/hppa};;
+ ppc|ppc64) CTARGET=${CTARGET/ppc/powerpc};;
+ x86) CTARGET="i686";;
+ esac
+
+ # Then add common suffixes
+ case ${CTARGET} in
+ i?86|x86_64)
+ CTARGET="${CTARGET}-pc-linux-gnu";;
+ s390*)
+ CTARGET="${CTARGET}-ibm-linux-gnu";;
+ alpha*|arm*|cris*|hppa*|ia64*|m68*|mips*|powerpc*|sparc*|sh*)
+ CTARGET="${CTARGET}-unknown-linux-gnu";;
bfin*|h8300*|nios2*|spu*|xc16x*)
- CPOST="elf";;
- *) CPOST="unknown-linux-gnu";;
+ CTARGET="${CTARGET}-elf";;
esac
fi
- # Let's accept ARCH in both the portage and the standard forms ...
- # CTARGET is in the standard form while TARCH is in the portage form
- case ${CPRE} in
-
- #####################
- ### linux targets ###
+ # Figure out an acceptable portage ARCH for this target
+ case ${CTARGET} in
alpha*) TARCH=alpha;;
arm*) TARCH=arm;;
hppa*) TARCH=hppa;;
- parisc) TARCH=hppa; CPRE="hppa";;
ia64*) TARCH=ia64 WITH_DEF_HEADERS="yes";;
i?86*) TARCH=x86;;
- x86) TARCH=x86; CPRE="i386";;
m68*) TARCH=m68k;;
mips*) TARCH=mips ; KPKG="mips-headers";;
powerpc64*) TARCH=ppc64;;
- ppc64) TARCH=ppc64; CPRE="powerpc64";;
powerpc*) TARCH=ppc;;
- ppc) TARCH=ppc; CPRE="powerpc";;
sparc*) TARCH=sparc;;
s390*) TARCH=s390;;
sh*) TARCH=sh;;
x86_64*) TARCH=amd64;;
- amd64) TARCH=amd64; CPRE="x86_64";;
+ *) TARCH=${HARCH};;
+ esac
+ case ${CTARGET} in
+ *-freebsd*) TARCH="${TARCH}-fbsd";;
+ esac
- #####################
- ### other targets ###
- avr*) TARCH=${HARCH}; CPOST="";
- KPKG="[none]"; STAGE=${STAGE_LIBC};
+ # Now account for all the "special" architectures out there
+ case ${CTARGET} in
+ avr*) KPKG="[none]"; STAGE=${STAGE_LIBC};
LCAT="dev-embedded"; LPKG="avr-libc";
GVER="3.4.6"; BVER="2.16.1-r3";
GUSE=${GUSE_DISABLE};;
- bfin*)
- TARCH=${HARCH};
- LPKG="uclibc";;
-
- h8300*)
- TARCH=${HARCH};
- LPKG="uclibc";;
-
- cris*)
- TARCH=${HARCH};
- LPKG="uclibc";;
-
- mingw*)
- TARCH=${HARCH}; CPOST="";
+ mingw*|*-mingw*)
WITH_DEF_HEADERS="yes";
KCAT="dev-util"; KPKG="w32api";
LCAT="dev-util"; LPKG="mingw-runtime";;
msp430)
- TARCH=${HARCH}; CPOST="";
STAGE=${STAGE_BINUTILS};;
nios2*)
- TARCH=${HARCH};
BPKG="binutils-nios2";
- GPKG="gcc-nios2";
- LPKG="uclibc";;
-
- vax*) TARCH=${HARCH};
- LPKG="uclibc";;
-
- xc16x*)
- TARCH=${HARCH};
- LPKG="newlib";;
+ GPKG="gcc-nios2";;
- cell*)einfo "The cell target is really an alias for the spu/ppu targets"
+ cell) einfo "The cell target is really an alias for the spu/ppu targets"
${CROSSDEV} -t ppu || exit 1
${CROSSDEV} -t spu-elf || exit 1
exit 0;;
spu*) TARCH=ppc64;
KPKG="[none]";
LPKG="newlib";;
- ppu*) TARCH=ppc64;
- CPRE=powerpc64;;
+ ppu*) TARCH=ppc64;;
- ps2*) einfo "The ps2 target is really an alias for the ee/iop/dvp targets"
+ ps2) einfo "The ps2 target is really an alias for the ee/iop/dvp targets"
${CROSSDEV} -t ee || exit 1
${CROSSDEV} -t iop || exit 1
${CROSSDEV} -t dvp || exit 1
exit 0;;
- ee*) TARCH=${HARCH}; CPOST="";
+ ee*) TARCH="mips";
KPKG="[none]"
GVER="3.2.2"; BVER="2.14";
STAGE=${STAGE_C_ONLY};
GUSE=${GUSE_DISABLE};;
- iop*) TARCH=${HARCH}; CPOST="";
+ iop*) TARCH="mips";
GVER="3.2.2"; BVER="2.14";
STAGE=${STAGE_C_ONLY};
GUSE=${GUSE_DISABLE};;
- dvp*) TARCH=${HARCH}; CPOST="";
+ dvp*) TARCH="mips";
GVER="3.2.2"; BVER="2.14";
STAGE=${STAGE_BINUTILS};;
-
- ############
- ### help ###
- help)
- cat <<-EOF
- Supported Architectures:
- - alpha - arm / armeb
- - hppa (parisc) - ia64
- - i386 / i486 / i586 / i686 (x86) - m68k
- - mips / mipsel / mips64 / mips64el
- - powerpc (ppc) / powerpc64 (ppc64)
- - sparc / sparc64 - s390 / s390x
- - sh / sh[1-5] / sh64 - x86_64 (amd64)
- Supported C Libraries:
- - gnu (glibc)
- - klibc [prob wont work]
- - uclibc [not all arches are ported]
- Special Targets:
- - avr http://www.nongnu.org/avr-libc/
- - bfin http://blackfin.uclinux.org/
- - h8300 http://h8300-hms.sourceforge.net/
- - mingw32 http://www.mingw.org/
- - msp430 http://mspgcc.sourceforge.net/
- - nios2 http://www.altera.com/products/ip/processors/nios2/ni2-index.html
- - xc16x http://www.infineon.com/
- - ee / iop / dvp (ps2) [Playstation 2 targets]
- - ppu / spu (cell) [Cell/Playstation 3 targets]
- Softfloat toolchains:
- Include 'softfloat' in the 'vendor' field
- e.g. armeb-softfloat-linux-uclibc powerpc-booya_softfloat-linux-gnu
- EOF
- exit 0
- ;;
-
- #######################
- ### unknown targets ###
- *) usage 1 "Unknown target '$1'; bug vapier@gentoo.org to add it" ;;
esac
- CTARGET=${CPRE}
- [[ -n ${CPOST} ]] && CTARGET=${CTARGET}-${CPOST}
-
# Tweak packages based upon CTARGET
case ${CTARGET} in
# Normal Linux host, just diff libc
*-dietlibc) LPKG="dietlibc";;
- *-klibc) LPKG="klibc";;
- *-uclibc) LPKG="uclibc";;
+ *-elf) LPKG="newlib";;
*-gnu*) LPKG="glibc";;
+ *-klibc) LPKG="klibc";;
+ *-newlib) LPKG="newlib";;
+ *-uclibc*) LPKG="uclibc";;
+ *-uclinux) LPKG="uclibc";;
# Now for the BSDs ...
*-freebsd*)
- TARCH="${TARCH}-fbsd"
LCAT="sys-freebsd" LPKG="freebsd-lib"
KPKG="[none]"
;;
}
-EOPTS=${EOPTS_UP}
+EOPTS="${EOPTS_UP} --newuse"
ex_gcc && USE="${GUSE} ${USE}" doemerge ${GPKG} ${GPKG}-extra
ex_gdb && doemerge gdb