3 # 2009 (C) Copyright Industrie Dial Face S.p.A.
4 # Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
6 # Based on original idea from WindRiver
8 # Toolchain wrapper script.
10 # This script allows us to use a small number of GCC / binutils cross-tools
11 # (one toolchain per instruction set architecture) to implement a larger
12 # number of processor- or board-specific tools. The wrapper script is
13 # configured at install time with information covering basic CFLAGS,
14 # LD options and the toolchain triplet name.
18 REALNAME
=`readlink -f $0`
20 REALNAME_BASE
=`basename $REALNAME`
21 REALNAME_DIR
=`dirname $REALNAME`
23 TARGET_FUNDAMENTAL_ASFLAGS
=''
24 TARGET_FUNDAMENTAL_CFLAGS
=''
25 TARGET_ROOTFS_CFLAGS
=''
26 TARGET_FUNDAMENTAL_LDFLAGS
=''
27 TARGET_TOOLCHAIN_TRIPLET
=${REALNAME_BASE%-*}
29 # Parse our tool name, splitting it at '-' characters.
30 BINARY
=${PROGNAME##*-}
32 # Parse our tool name, splitting it at '-' characters.
33 IFS
=- read TOOLCHAIN_ARCH TOOLCHAIN_BUILDROOT TOOLCHAIN_OS TOOLCHAIN_PLATFORM PROGNAME
<< EOF
38 # We add the directory this was executed from to the PATH
39 # The toolchains (links) should be in this directory or in the users
42 TOOLCHAIN_BIN_DIR
="$REALNAME_DIR/"
44 # Set the PATH so that our run-time location is first
45 # (get_feature is run from the path, so this has to be set)
46 export PATH
="$TOOLCHAIN_BIN_DIR":$PATH
47 export GCC_HONOUR_COPTS
49 TOOLCHAIN_SYSROOT
="$TOOLCHAIN_BIN_DIR/../.."
50 if [ ! -d "$TOOLCHAIN_SYSROOT" ]; then
51 echo "Error: Unable to determine sysroot (looking for $TOOLCHAIN_SYSROOT)!" >&2
55 # -Wl,--dynamic-linker=$TOOLCHAIN_SYSROOT/lib/ld-uClibc.so.0
56 # --dynamic-linker=$TOOLCHAIN_SYSROOT/lib/ld-uClibc.so.0
58 case $TOOLCHAIN_PLATFORM in
60 GCC_SYSROOT_FLAGS
="--sysroot=$TOOLCHAIN_SYSROOT -Wl,-rpath=$TOOLCHAIN_SYSROOT/lib:$TOOLCHAIN_SYSROOT/usr/lib"
61 LD_SYSROOT_FLAGS
="-rpath=$TOOLCHAIN_SYSROOT/lib:$TOOLCHAIN_SYSROOT/usr/lib"
64 GCC_SYSROOT_FLAGS
="--sysroot=$TOOLCHAIN_SYSROOT -Wl,-rpath=$TOOLCHAIN_SYSROOT/lib:$TOOLCHAIN_SYSROOT/usr/lib"
65 LD_SYSROOT_FLAGS
="-rpath=$TOOLCHAIN_SYSROOT/lib:$TOOLCHAIN_SYSROOT/usr/lib"
78 exec $TARGET_TOOLCHAIN_TRIPLET-$BINARY.bin
$GCC_SYSROOT_FLAGS $TARGET_FUNDAMENTAL_CFLAGS $TARGET_ROOTFS_CFLAGS "$@"
81 exec $TARGET_TOOLCHAIN_TRIPLET-$BINARY.bin
$LD_SYSROOT_FLAGS $TARGET_FUNDAMENTAL_LDFLAGS "$@"
84 exec $TARGET_TOOLCHAIN_TRIPLET-$BINARY.bin
$TARGET_FUNDAMENTAL_ASFLAGS "$@"
87 exec $TARGET_TOOLCHAIN_TRIPLET-$BINARY.bin
"$@"