diff options
author | Lauri Leukkunen <lle@rahina.org> | 2007-04-22 14:58:26 +0300 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2007-04-22 14:58:26 +0300 |
commit | 265d3b33950a942c53698b54696b13d5da7a0ef9 (patch) | |
tree | 6768e807b0bf9295c75d4c98839a42dab9b88c63 | |
parent | 8c932755fc9407cb6b87c73cb3aa957bf073eea5 (diff) |
sb2-init completed
It generates a correct sb2.config automatically for the gcc
passed to it on the command line.
Signed-off-by: Lauri Leukkunen <lle@rahina.org>
-rw-r--r-- | Makefile | 1 | ||||
-rwxr-xr-x | utils/sb2-init | 51 |
2 files changed, 40 insertions, 12 deletions
@@ -32,6 +32,7 @@ install: $(targets) install -d -m 755 $(prefix)/share/scratchbox2/redir_scripts/preload/emulate install -c -m 755 preload/libsb2.so $(prefix)/lib/libsb2.so install -c -m 755 utils/sb2 $(prefix)/bin/sb2 + install -c -m 755 utils/sb2-init $(prefix)/bin/sb2-init install -c -m 755 utils/sb2-build-libtool $(prefix)/bin/sb2-build-libtool install -c -m 755 utils/sb_gcc_wrapper $(prefix)/bin/sb_gcc_wrapper install -c -m 755 scripts/sb2rc $(prefix)/share/scratchbox2/sb2rc diff --git a/utils/sb2-init b/utils/sb2-init index 343d679..d4c0066 100755 --- a/utils/sb2-init +++ b/utils/sb2-init @@ -1,25 +1,52 @@ #!/bin/bash - +# sb2-init - Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org> +# Licensed under GPL version 2 + + +if [ $1 = "--help" ]; then + echo "Usage: sb2-init [compiler]" + echo "example: sb2-init arm-linux-gcc" + exit 0 +fi + +GCC=$1 + +GCC_FULLPATH=$(which $GCC) +# test that gcc exists and can be executed +if [ $? != 0 ]; then + echo "$GCC doesn't exist" + exit 1 +fi +GCC_PATH=$(dirname $(which $GCC)) +if [ $GCC -v > /dev/null 2>&1 != 0 ]; then + echo "Invalid compiler specified: $GCC" + exit 1 +fi + +GCC_PREFIX=$(basename $GCC | sed 's/-gcc$/-/') +ARCH=$($GCC -dumpmachine | awk -F- '{ print $1 }') +QEMU=$(which qemu-$ARCH) +if [ $? != 0 ]; then + echo "You don't have qemu-$ARCH installed." + exit 1 +fi function write_sb2config() { - cat - > sb2.config <<< EOF + cat - > sb2.config <<EOF # Scratchbox2 configuration file generated by sb2-init. -# This file works with Code Sourcery 2006q3 arm linux gnueabi toolchain. -# Modify SBOX_CPUTRANSPARENY_METHOD and SBOX_CROSS_GCC_DIR to suit your -# paths. -SBOX_CPU=arm +SBOX_CPU=$ARCH SBOX_OS=none-linux-gnueabi -SBOX_CPUTRANSPARENCY_METHOD=/home/lleukkun/scratchbox/bin/qemu-arm +SBOX_CPUTRANSPARENCY_METHOD=$QEMU -SBOX_DEFAULT_GCC_PREFIX=arm-none-linux-gnueabi- +SBOX_DEFAULT_GCC_PREFIX=$GCC_PREFIX SBOX_CROSS_GCC_NAME=cross-gcc -SBOX_CROSS_GCC_PREFIX_LIST=arm-linux-gnueabi-:arm-linux-:arm-none-linux-gnueabi- -SBOX_CROSS_GCC_SUBST_PREFIX=arm-none-linux-gnueabi- +SBOX_CROSS_GCC_PREFIX_LIST=$ARCH-linux-gnueabi-:$ARCH-linux-:$GCC_PREFIX +SBOX_CROSS_GCC_SUBST_PREFIX=$GCC_PREFIX SBOX_CROSS_GCC_SPECS_FILE= -SBOX_CROSS_GCC_DIR=/home/lleukkun/compilers/arm-2006q3/bin +SBOX_CROSS_GCC_DIR=$GCC_PATH SBOX_CROSS_GCC_LD_ARGS= SBOX_HOST_GCC_NAME=host-gcc @@ -32,5 +59,5 @@ EOF echo "Finished writing sb2.config" } +write_sb2config -while getopts c:t:n: |