diff options
author | Lauri Aarnio <lauri.aarnio@iki.fi> | 2008-02-03 23:16:50 +0200 |
---|---|---|
committer | Lauri Leukkunen <lle@rahina.org> | 2008-02-12 20:56:27 +0200 |
commit | f9782d1e445b622c89e32bf1dd18104b15e1d8b6 (patch) | |
tree | 6192d493f3c377a3b2f47d73108372644154146a /utils | |
parent | 48d73faa108d72a496fcdd6cd6a28281a3acf41a (diff) |
sb2-init improvements
- there is a new option "-C options" for sb2-init, for spefifying extra
options for the cross compiler. This can be used for example to give
"-fgnu89-inline" option to gcc 4.2.1.
- "sb2-init" now prints out existing configuration information (in addition
to usage, when started without any parameters).
- sb2.config has been modified (and config file version number has been
incremented): Added information about how, when & who executed sb2-init,
and things that were in SBOX_EXTRA_CROSS_COMPILER_ARGS have
been split to two variables.
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/sb2 | 2 | ||||
-rwxr-xr-x | utils/sb2-init | 65 |
2 files changed, 61 insertions, 6 deletions
@@ -78,7 +78,7 @@ function sboxify_environment() . ~/.scratchbox2/$SBOX_TARGET/sb2.config - if [ "$SBOX_CONFIG_VERSION" != "4" ]; then + if [ "$SBOX_CONFIG_VERSION" != "5" ]; then echo "Please run sb2-init for your target:" echo "name: $SBOX_TARGET" echo "dir: $SBOX_TARGET_ROOT" diff --git a/utils/sb2-init b/utils/sb2-init index 8f51c27..d0e96dc 100755 --- a/utils/sb2-init +++ b/utils/sb2-init @@ -2,6 +2,37 @@ # sb2-init - Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org> # Licensed under GPL version 2 +function show_existing_config_info() +{ + has_targets="no" + echo "Already initialized targets:" + echo + for f in $HOME/.scratchbox2/*/sb2.config + do + if [ -f $f ] + then + SBOX_CONFIG_VERSION=0 + . $f + has_targets="yes" + targetdir=`dirname $f` + targetname=`basename $targetdir` + echo "Target $targetname:" + if [ "$SBOX_CONFIG_VERSION" -lt 5 ] + then + echo "(configuration file version too old)" + else + echo "configured at $SBOX_INIT_TIME by $SBOX_INIT_ID, with command" + echo "( cd $SBOX_TARGET_ROOT;" + echo "sb2-init $SBOX_INIT_ORIG_ARGS )" + fi + echo + fi + done + if [ has_targets = "no" ] + then + echo "none." + fi +} function usage() { @@ -28,13 +59,17 @@ Options: -n don't build libtool for the target -s skip checks for target root's /usr/include etc. -t [tools_dir] set directory containing the build tools distribution + -C "options" add extra options for the compiler, for example: + "-fgnu89-inline" -v display version Examples: sb2-init ARM arm-linux-gcc sb2-init -m maemo ARM arm-linux-gcc sb2-init -sn -c sbrsh armel-debian /path/to/arm-linux-gcc + EOF + show_existing_config_info exit 2 } @@ -50,7 +85,11 @@ function write_target_config() cat - > $HOME/.scratchbox2/$TARGET/sb2.config <<EOF # Scratchbox2 configuration file generated by sb2-init. -export SBOX_CONFIG_VERSION=4 +SBOX_INIT_ORIG_ARGS="$SBOX_INIT_ORIG_ARGS" +SBOX_INIT_TIME=$SBOX_INIT_TIME +SBOX_INIT_ID="$SBOX_INIT_ID" + +export SBOX_CONFIG_VERSION=5 export SBOX_TARGET_ROOT=$SBOX_TARGET_ROOT export SBOX_CPU=$ARCH export SBOX_GCC_TARGET=$GCC_TARGET @@ -66,6 +105,7 @@ export SBOX_CROSS_GCC_SPECS_FILE= export SBOX_CROSS_GCC_DIR=$GCC_PATH export SBOX_CROSS_GCC_LD_ARGS= export SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS" +export SBOX_EXTRA_CROSS_COMPILER_STDINC="$SBOX_EXTRA_CROSS_COMPILER_STDINC" export SBOX_EXTRA_CROSS_LD_ARGS="-rpath-link $SBOX_TARGET_ROOT/usr/lib:$SBOX_TARGET_ROOT/lib" export DEB_BUILD_ARCH_CPU=$DEBIAN_CPU @@ -151,6 +191,17 @@ you can re-run this script." export SBOX_DIR=$(readlink -f $(dirname $_)/..) +# SBOX_INIT_* variables are used to record who initialized, and when and +# how sb2 was initialized. +# It is possible to set SBOX_INIT_ID externally (for example, if +# another program is used to initialize the system) +SBOX_INIT_ORIG_ARGS="$*" +SBOX_INIT_TIME=`date +%Y-%m-%d_%H:%M:%S` +if [ -z "$SBOX_INIT_ID" ] +then + SBOX_INIT_ID="user '$USER'" +fi + REMOTEHOST= LOCALHOST= @@ -158,11 +209,13 @@ set_as_default=0 with_libtool=1 skip_checks=false +SBOX_EXTRA_CROSS_COMPILER_ARGS="" + if [ -z "$*" ]; then usage fi -while getopts c:r:l:m:dhnst:v foo +while getopts c:C:r:l:m:dhnst:v foo do case $foo in (c) CPUTRANSP=$OPTARG ;; @@ -175,6 +228,7 @@ do (s) skip_checks=true ;; (t) TOOLS_ROOT=$OPTARG ;; (v) version ;; + (C) SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS $OPTARG " ;; (*) usage ;; esac done @@ -274,13 +328,14 @@ if [ -n "$TOOLS_ROOT" ]; then fi fi +SBOX_EXTRA_CROSS_COMPILER_STDINC="-I/usr/include" +SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS -L$SBOX_TARGET_ROOT/usr/lib -L$SBOX_TARGET_ROOT/lib" + # test if the cross compiler needs to be silenced about /usr/include # usage echo "" | $GCC_FULLPATH -E - -Wno-poison-system-directories > /dev/null 2>&1 if [ $? = 0 ] ; then - SBOX_EXTRA_CROSS_COMPILER_ARGS="-I/usr/include -L$SBOX_TARGET_ROOT/usr/lib -L$SBOX_TARGET_ROOT/lib -Wno-poison-system-directories" -else - SBOX_EXTRA_CROSS_COMPILER_ARGS="-I/usr/include -L$SBOX_TARGET_ROOT/usr/lib -L$SBOX_TARGET_ROOT/lib" + SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS -Wno-poison-system-directories" fi HOST_GCC_INC=$(echo "#include <stdio.h>" | gcc -M -E - | perl -e 'while(<STDIN>) { $foo{$1} = 1 if m/\/usr([^[:space:]]*\/include)/;}; foreach my $k (keys %foo) {print " -isystem $ENV{SBOX_DIR}/share/scratchbox2/host_usr$k"};') |