summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--lua_scripts/argvenvp.lua11
-rw-r--r--lua_scripts/argvenvp_gcc.lua155
-rwxr-xr-xutils/sb265
-rwxr-xr-xutils/sb2-build-qemuserver10
-rwxr-xr-xutils/sb2-config-gcc-toolchain266
-rwxr-xr-xutils/sb2-init109
-rwxr-xr-xutils/sb2-upgrade-config34
-rwxr-xr-xwrappers/dpkg-checkbuilddeps25
9 files changed, 491 insertions, 185 deletions
diff --git a/Makefile b/Makefile
index dd7b39e..f0a996a 100644
--- a/Makefile
+++ b/Makefile
@@ -151,6 +151,7 @@ install-noarch: regular
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-qemu-gdbserver-prepare $(prefix)/bin/sb2-qemu-gdbserver-prepare
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-upgrade-config $(prefix)/share/scratchbox2/scripts/sb2-upgrade-config
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-parse-sb2-init-args $(prefix)/share/scratchbox2/scripts/sb2-parse-sb2-init-args
+ $(Q)install -c -m 755 $(SRCDIR)/utils/sb2-config-gcc-toolchain $(prefix)/share/scratchbox2/scripts/sb2-config-gcc-toolchain
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-check-pkg-mappings $(prefix)/share/scratchbox2/scripts/sb2-check-pkg-mappings
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-exitreport $(prefix)/share/scratchbox2/scripts/sb2-exitreport
$(Q)install -c -m 755 $(SRCDIR)/utils/sb2-generate-locales $(prefix)/share/scratchbox2/scripts/sb2-generate-locales
diff --git a/lua_scripts/argvenvp.lua b/lua_scripts/argvenvp.lua
index 23caca2..e647e78 100644
--- a/lua_scripts/argvenvp.lua
+++ b/lua_scripts/argvenvp.lua
@@ -8,10 +8,13 @@ argvmods = {}
-- only map gcc & friends if a cross compiler has been defined,
-- and it has not been disabled by the mapping rules:
-if (sbox_cross_gcc_dir ~= nil and sbox_cross_gcc_dir ~= "" and
- enable_cross_gcc_toolchain == true) then
- -- this generates gcc related argv/envp manglings
- do_file(session_dir .. "/lua_scripts/argvenvp_gcc.lua")
+if (enable_cross_gcc_toolchain == true) then
+ local gcc_rule_file_path = session_dir .. "/gcc-conf.lua"
+
+ if (sb.path_exists(gcc_rule_file_path)) then
+ -- this generates gcc related argv/envp manglings
+ do_file(session_dir .. "/lua_scripts/argvenvp_gcc.lua")
+ end
end
-- regular mangling rules go here
diff --git a/lua_scripts/argvenvp_gcc.lua b/lua_scripts/argvenvp_gcc.lua
index 4ad6e9a..4603cac 100644
--- a/lua_scripts/argvenvp_gcc.lua
+++ b/lua_scripts/argvenvp_gcc.lua
@@ -14,7 +14,7 @@ gcc_compilers = {
"g77"
}
--- names, where sbox_cross_gcc_shortversion may be embedded to the name
+-- names, where cross_gcc_shortversion may be embedded to the name
-- (e.g. gcc-3.4, g++-3.4)
gcc_compilers_with_version = {
"gcc",
@@ -43,97 +43,117 @@ gcc_tools = {
"strip"
}
--- Path prefixes:
--- 1. currently all cross-gcc tools that we are going to replace
--- live in /usr/bin, but these tools may call other tools from
--- the same set (e.g. "gcc" calls "ld", etc). That is why
--- sbox_cross_gcc_dir is needed, too.
--- 2. note that sbox_cross_gcc_dir is not empty, this file
--- won't be loaded at all if it is (see argvenvp.lua),
--- 3. Wrappers for host-* tools live in /sb2/wrappers.
-gcc_tools_path_prefixes = {
+local generic_gcc_tools_path_prefixes = {
"/usr/bin/",
- sbox_cross_gcc_dir,
"/sb2/"
}
-function register_gcc_component_path(tmp)
- tmp.path_prefixes = gcc_tools_path_prefixes
+function register_gcc_component_path(tmp, gccrule)
+ -- Path prefixes:
+ -- 1. currently all cross-gcc tools that we are going to replace
+ -- live in /usr/bin, but these tools may call other tools from
+ -- the same set (e.g. "gcc" calls "ld", etc). That is why
+ -- cross_gcc_dir is needed, too.
+ -- 2. note that cross_gcc_dir is not empty, this file
+ -- won't be loaded at all if it is (see argvenvp.lua),
+ -- 3. Wrappers for host-* tools live in /sb2/wrappers.
+ if gccrule == nil or gccrule.cross_gcc_dir == nil then
+ tmp.path_prefixes = generic_gcc_tools_path_prefixes
+ else
+ local gcc_tools_path_prefixes = {
+ "/usr/bin/",
+ gccrule.cross_gcc_dir,
+ "/sb2/"
+ }
+ tmp.path_prefixes = gcc_tools_path_prefixes
+ end
argvmods[tmp.name] = tmp
end
-function gcc_compiler_arg_mods(tmp)
+function gcc_compiler_arg_mods(tmp, gccrule)
tmp.add_tail = {}
tmp.remove = {}
- if (sbox_cross_gcc_specs_file and sbox_cross_gcc_specs_file ~= "") then
- table.insert(tmp.add_tail, "-specs="..sbox_cross_gcc_specs_file)
+ if (gccrule.cross_gcc_specs_file and gccrule.cross_gcc_specs_file ~= "") then
+ table.insert(tmp.add_tail, "-specs="..gccrule.cross_gcc_specs_file)
end
- if (sbox_extra_cross_compiler_args and sbox_extra_cross_compiler_args ~= "") then
- for gcc_extra in string.gmatch(sbox_extra_cross_compiler_args, "[^ ]+") do
+ if (gccrule.extra_cross_compiler_args and gccrule.extra_cross_compiler_args ~= "") then
+ for gcc_extra in string.gmatch(gccrule.extra_cross_compiler_args, "[^ ]+") do
table.insert(tmp.add_tail, gcc_extra)
end
end
- if (sbox_extra_cross_compiler_stdinc and sbox_extra_cross_compiler_stdinc ~= "") then
- for gcc_stdinc in string.gmatch(sbox_extra_cross_compiler_stdinc, "[^ ]+") do
+ if (gccrule.extra_cross_compiler_stdinc and gccrule.extra_cross_compiler_stdinc ~= "") then
+ for gcc_stdinc in string.gmatch(gccrule.extra_cross_compiler_stdinc, "[^ ]+") do
table.insert(tmp.add_tail, gcc_stdinc)
end
end
- if (sbox_block_cross_compiler_args and sbox_block_cross_compiler_args ~= "") then
- for gcc_block in string.gmatch(sbox_block_cross_compiler_args, "[^ ]+") do
+ if (gccrule.block_cross_compiler_args and gccrule.block_cross_compiler_args ~= "") then
+ for gcc_block in string.gmatch(gccrule.block_cross_compiler_args, "[^ ]+") do
table.insert(tmp.remove, gcc_block)
end
end
end
--- The trick with ":" .. is to have a non-prefixed gcc call caught here
-for prefix in string.gmatch(":" .. sbox_cross_gcc_prefix_list, "[^:]*") do
+function add_cross_compiler(gccrule, version)
+ local require_version = true
- -- Compiler tools without version suffix
- for i = 1, table.maxn(gcc_compilers) do
- local tmp = {}
- tmp.name = prefix .. gcc_compilers[i]
- tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_compilers[i]
- gcc_compiler_arg_mods(tmp)
- register_gcc_component_path(tmp)
- end
- -- Compiler tools with version suffix
- for i = 1, table.maxn(gcc_compilers_with_version) do
- local tmp = {}
- tmp.name = prefix .. gcc_compilers_with_version[i] .. "-" ..
- sbox_cross_gcc_shortversion
- tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_compilers_with_version[i]
- gcc_compiler_arg_mods(tmp)
- register_gcc_component_path(tmp)
+ if version == "" then
+ require_version = false
end
- -- just map the filename for linkers and tools
- for i = 1, table.maxn(gcc_linkers) do
- local tmp = {}
- tmp.name = prefix .. gcc_linkers[i]
- tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_linkers[i]
- tmp.add_tail = {}
- tmp.remove = {}
- if (sbox_extra_cross_ld_args and sbox_extra_cross_ld_args ~= "") then
- for ld_extra in string.gmatch(sbox_extra_cross_ld_args, "[^ ]+") do
- table.insert(tmp.add_tail, ld_extra)
+ -- The trick with ":" .. is to have a non-prefixed gcc call caught here
+ for prefix in string.gmatch(":" .. gccrule.cross_gcc_prefix_list, "[^:]*") do
+
+ if require_version == false then
+ -- Compiler tools without version suffix
+ for i = 1, table.maxn(gcc_compilers) do
+ local tmp = {}
+ tmp.name = prefix .. gcc_compilers[i]
+ tmp.new_filename = gccrule.cross_gcc_dir .. "/" .. gccrule.cross_gcc_subst_prefix .. gcc_compilers[i]
+ gcc_compiler_arg_mods(tmp, gccrule)
+ register_gcc_component_path(tmp, gccrule)
end
end
- if (sbox_block_cross_ld_args and sbox_block_cross_ld_args ~= "") then
- for ld_block in string.gmatch(sbox_block_cross_ld_args, "[^ ]+") do
- table.insert(tmp.remove, ld_block)
+
+ -- Compiler tools with version suffix
+ for i = 1, table.maxn(gcc_compilers_with_version) do
+ local tmp = {}
+ tmp.name = prefix .. gcc_compilers_with_version[i] .. "-" ..
+ gccrule.cross_gcc_shortversion
+ tmp.new_filename = gccrule.cross_gcc_dir .. "/" .. gccrule.cross_gcc_subst_prefix .. gcc_compilers_with_version[i]
+ gcc_compiler_arg_mods(tmp, gccrule)
+ register_gcc_component_path(tmp, gccrule)
+ end
+
+ if require_version == false then
+ -- just map the filename for linkers and tools
+ for i = 1, table.maxn(gcc_linkers) do
+ local tmp = {}
+ tmp.name = prefix .. gcc_linkers[i]
+ tmp.new_filename = gccrule.cross_gcc_dir .. "/" .. gccrule.cross_gcc_subst_prefix .. gcc_linkers[i]
+ tmp.add_tail = {}
+ tmp.remove = {}
+ if (gccrule.extra_cross_ld_args and gccrule.extra_cross_ld_args ~= "") then
+ for ld_extra in string.gmatch(gccrule.extra_cross_ld_args, "[^ ]+") do
+ table.insert(tmp.add_tail, ld_extra)
+ end
+ end
+ if (gccrule.block_cross_ld_args and gccrule.block_cross_ld_args ~= "") then
+ for ld_block in string.gmatch(gccrule.block_cross_ld_args, "[^ ]+") do
+ table.insert(tmp.remove, ld_block)
+ end
+ end
+ register_gcc_component_path(tmp, gccrule)
+ end
+ for i = 1, table.maxn(gcc_tools) do
+ local tmp = {}
+ tmp.name = prefix .. gcc_tools[i]
+ tmp.new_filename = gccrule.cross_gcc_dir .. "/" .. gccrule.cross_gcc_subst_prefix .. gcc_tools[i]
+ register_gcc_component_path(tmp, gccrule)
end
end
- register_gcc_component_path(tmp)
- end
- for i = 1, table.maxn(gcc_tools) do
- local tmp = {}
- tmp.name = prefix .. gcc_tools[i]
- tmp.new_filename = sbox_cross_gcc_dir .. "/" .. sbox_cross_gcc_subst_prefix .. gcc_tools[i]
- register_gcc_component_path(tmp)
end
end
-
-- deal with host-gcc functionality, disables mapping
for prefix in string.gmatch(sbox_host_gcc_prefix_list, "[^:]+") do
for i = 1, table.maxn(gcc_compilers) do
@@ -153,7 +173,7 @@ for prefix in string.gmatch(sbox_host_gcc_prefix_list, "[^:]+") do
table.insert(tmp.remove, gcc_block)
end
end
- register_gcc_component_path(tmp)
+ register_gcc_component_path(tmp, nil)
end
-- just map the filename for linkers and tools
@@ -162,17 +182,24 @@ for prefix in string.gmatch(sbox_host_gcc_prefix_list, "[^:]+") do
tmp.name = prefix .. gcc_linkers[i]
tmp.new_filename = sbox_host_gcc_dir .. "/" .. sbox_host_gcc_subst_prefix .. gcc_linkers[i]
tmp.disable_mapping = 1
- register_gcc_component_path(tmp)
+ register_gcc_component_path(tmp, nil)
end
for i = 1, table.maxn(gcc_tools) do
local tmp = {}
tmp.name = prefix .. gcc_tools[i]
tmp.new_filename = sbox_host_gcc_dir .. "/" .. sbox_host_gcc_subst_prefix .. gcc_tools[i]
tmp.disable_mapping = 1
- register_gcc_component_path(tmp)
+ register_gcc_component_path(tmp, nil)
end
end
+gcc_rule_file_path = session_dir .. "/gcc-conf.lua"
+
+if (sb.path_exists(gcc_rule_file_path)) then
+ sb.log("debug", "Loading GCC rules")
+ do_file(gcc_rule_file_path)
+end
+
-- end of gcc related generation
diff --git a/utils/sb2 b/utils/sb2
index c13a694..b5a3864 100755
--- a/utils/sb2
+++ b/utils/sb2
@@ -144,7 +144,7 @@ function load_configuration()
# upgraded whenever needed:
# check if we need to upgrade configuration:
- if [ ! -f ~/.scratchbox2/$SBOX_TARGET/sb2.config.d/config-stamp.10 ]; then
+ if [ ! -f ~/.scratchbox2/$SBOX_TARGET/sb2.config.d/config-stamp.11 ]; then
$SBOX_DIR/share/scratchbox2/scripts/sb2-upgrade-config \
$SBOX_TARGET
if [ $? != 0 ]; then
@@ -152,6 +152,12 @@ function load_configuration()
exit 1
fi
fi
+
+ #-----------
+ # Read in primary toolchain config, if it has been defined
+ if [ -f $HOME/.scratchbox2/$TARGET/sb2.config.d/gcc.config.sh ]; then
+ . $HOME/.scratchbox2/$TARGET/sb2.config.d/gcc.config.sh
+ fi
}
function sboxify_environment()
@@ -190,14 +196,9 @@ function sboxify_environment()
. $SBOX_DIR/share/scratchbox2/modeconf/sb2rc.$SBOX_MAPMODE starting
fi
- if [ "$SBOX_CONFIG_VERSION" != "9" ]; then
- echo "Please run sb2-init for your target:"
- echo "name: $SBOX_TARGET"
- echo "dir: $SBOX_TARGET_ROOT"
- echo "gcc: $SBOX_CROSS_GCC_DIR/${SBOX_CROSS_GCC_SUBST_PREFIX}gcc"
- echo "to update its sb2.config to work with current version of sb2"
- echo "for example: "
- echo sb2-init $SBOX_TARGET $SBOX_CROSS_GCC_DIR/${SBOX_CROSS_GCC_SUBST_PREFIX}gcc""
+ if [ "$SBOX_CONFIG_VERSION" -lt "9" ]; then
+ echo "Please run sb2-init for your target"
+ echo "to update its sb2.config to work with current version of sb2."
exit 1
fi
@@ -209,6 +210,9 @@ function sboxify_environment()
exit_error "Incorrect target config in ~/.scratchbox2/$SBOX_TARGET/sb2.config"
fi
+ # This refers to the primary toolchain.
+ # FIXME: $SBOX_TARGET_TOOLCHAIN_DIR should be removed completely,
+ # but currently the "install" mode needs it.
SBOX_TARGET_TOOLCHAIN_DIR=$(dirname "$SBOX_CROSS_GCC_DIR")
if [ -z "$SBOX_MODE_PATH" ]; then
@@ -273,21 +277,6 @@ function create_common_sb2_conf_file_for_session()
sbox_user_home_dir="/home/unknown_user"
fi
- # SBOX_EXTRA_CROSS_COMPILER_ARGS and SBOX_EXTRA_CROSS_LD_ARGS contain
- # embedded absolute paths to the orig. rootstrap location.
- #
- # FIXME: It is generally a bad idea to store the rootstrap location
- # in multiple places. sb2-init and format of sb2.config should be
- # fixed, but that has been delayed (because that would also force
- # us to increment the config file version number, and that forces
- # everyone to re-initialize sb2 environment everywhere...)
- if [ "$SBOX_TARGET_ROOT_in_config_file" != "$SBOX_TARGET_ROOT" ]; then
- SBOX_EXTRA_CROSS_LD_ARGS=`echo "$SBOX_EXTRA_CROSS_LD_ARGS" |
- sed -e "s:$SBOX_TARGET_ROOT_in_config_file:$SBOX_TARGET_ROOT:g"`
- SBOX_EXTRA_CROSS_COMPILER_ARGS=`echo "$SBOX_EXTRA_CROSS_COMPILER_ARGS" |
- sed -e "s:$SBOX_TARGET_ROOT_in_config_file:$SBOX_TARGET_ROOT:g"`
- fi
-
cat <<END >>$SBOX_SESSION_DIR/sb2-session.conf
comment_1=" Common configuration file for Lua and Shell scripts."
comment_2=" Automatically generated file, do not edit."
@@ -309,19 +298,6 @@ sbox_cpu="$SBOX_CPU"
sbox_cputransparency_method="$SBOX_CPUTRANSPARENCY_METHOD"
sbox_sbrsh_config="$SBRSH_CONFIG"
-sbox_cross_gcc_prefix_list="$SBOX_CROSS_GCC_PREFIX_LIST"
-sbox_cross_gcc_dir="$SBOX_CROSS_GCC_DIR"
-sbox_cross_gcc_version="$SBOX_CROSS_GCC_VERSION"
-sbox_cross_gcc_shortversion="$SBOX_CROSS_GCC_SHORTVERSION"
-sbox_extra_cross_compiler_args="$SBOX_EXTRA_CROSS_COMPILER_ARGS"
-sbox_cross_gcc_subst_prefix="$SBOX_CROSS_GCC_SUBST_PREFIX"
-sbox_cross_gcc_specs_file="$SBOX_CROSS_GCC_SPECS_FILE"
-sbox_extra_cross_compiler_stdinc="$SBOX_EXTRA_CROSS_COMPILER_STDINC"
-sbox_block_cross_compiler_args="$SBOX_BLOCK_CROSS_COMPILER_ARGS"
-
-sbox_extra_cross_ld_args="$SBOX_EXTRA_CROSS_LD_ARGS"
-sbox_block_cross_ld_args="$SBOX_BLOCK_CROSS_LD_ARGS"
-
sbox_host_gcc_prefix_list="$SBOX_HOST_GCC_PREFIX_LIST"
sbox_host_gcc_dir="$SBOX_HOST_GCC_DIR"
sbox_extra_host_compiler_args="$SBOX_EXTRA_HOST_COMPILER_ARGS"
@@ -335,6 +311,20 @@ sbox_emulate_sb1_bugs="$SBOX_EMULATE_SB1_BUGS"
END
}
+# create $SBOX_SESSION_DIR/gcc-conf.lua
+function create_gcc_conf_file_for_session()
+{
+ gcc_config_files=`ls ~/.scratchbox2/$SBOX_TARGET/sb2.config.d/gcc.config*.lua`
+ if [ -n "$gcc_config_files" ] ; then
+ # Create the configuration file. Do some variable substitutions:
+ # "extra_cross_compiler_args" and "extra_cross_ld_args"
+ # need absolute paths to the orig. rootstrap location, at least.
+ cat $gcc_config_files | \
+ sed -e "s:@SBOX_TARGET_ROOT@:$SBOX_TARGET_ROOT:g" \
+ >$SBOX_SESSION_DIR/gcc-conf.lua
+ fi
+}
+
# write_ld_library_path_replacement_to_exec_config():
#
# Create replacement for LD_LIBRARY_PATH and write it to the created config
@@ -917,6 +907,7 @@ function write_configfiles_and_rules_for_new_session()
create_exec_config_file
create_common_sb2_conf_file_for_session
+ create_gcc_conf_file_for_session
# Copy intial contents of /var/run from the rootstrap:
mkdir $SBOX_SESSION_DIR/var
diff --git a/utils/sb2-build-qemuserver b/utils/sb2-build-qemuserver
index 299d294..75e9ef9 100755
--- a/utils/sb2-build-qemuserver
+++ b/utils/sb2-build-qemuserver
@@ -20,6 +20,16 @@ fi
. ~/.scratchbox2/$sbox_target/sb2.config
+# Read in primary toolchain config, if it has been defined;
+# SBOX_CROSS_* variables are there nowadays
+if [ -f $HOME/.scratchbox2/$sbox_target/sb2.config.d/gcc.config.sh ]; then
+ . $HOME/.scratchbox2/$sbox_target/sb2.config.d/gcc.config.sh
+else
+ echo "$HOME/.scratchbox2/$sbox_target/sb2.config.d/gcc.config.sh does not exist;"
+ echo "Can't build qemuserver"
+ exit 1
+fi
+
# ------------
# FIXME: / LTA 2008-09-18:
# Export variables from sb2.config; These used to be exported from sb2.config,
diff --git a/utils/sb2-config-gcc-toolchain b/utils/sb2-config-gcc-toolchain
new file mode 100755
index 0000000..a943a54
--- /dev/null
+++ b/utils/sb2-config-gcc-toolchain
@@ -0,0 +1,266 @@
+#!/bin/bash
+# sb2-config-gcc-toolchain - configure a cross-gcc compiler for SB2
+#
+# Copyright (c) 2008 Nokia Corporation.
+# Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org>
+# Licensed under GPL version 2
+
+my_path=$_
+if [ $(basename $my_path) != $(basename $0) ]; then
+ my_path=$0
+ if [ $(basename $my_path) = $my_path ]; then
+ my_path=$(which $my_path)
+ fi
+fi
+
+function usage()
+{
+ cat <<EOF
+sb2-config-gcc-toolchain - Configure a cross-gcc compiler for SB2
+Usage:
+ sb2-config-gcc-toolchain [OPTION]... [COMPILER]
+
+COMPILER is of the form $HOME/arm-2006q3/bin/arm-linux-gcc
+
+Options:
+ ################
+ -t target set target name
+ -C "options" add extra options for the compiler, for example:
+ "-fgnu89-inline"
+ -A arch manually override target architecture
+ -h print this help
+ -m mapping_mode target uses mapping_mode as default mode
+ -S SBOX_DIR define value for SBOX_DIR
+ -R TARGET_ROOT define value for SBOX_TARGET_ROOT
+ -V this toolchain is a secondary toolchain,
+ tools require version numbers in pathnames
+ -v verbose operation
+
+EOF
+ exit 2
+}
+
+function write_gcc_config()
+{
+ gcc_version=$1
+
+ if [ -n "$gcc_version" ] ; then
+ gcc_version_id=`echo $gcc_version | sed -e 's/[^0-9a-zA-Z]/_/g'`
+ fi
+
+ SBOX_TARGET_TOOLCHAIN_DIR=$(dirname "$SBOX_CROSS_GCC_DIR")
+ SBOX_CROSS_GCC_PREFIX_LIST=$GCC_TARGET-:$SB2INIT_CROSS_GCC_PREFIX_LIST:$GCC_PREFIX
+
+ # Note: "sb2" script will replace "@SBOX_TARGET_ROOT@" by the real
+ # value when the session is created.
+ SBOX_EXTRA_CROSS_LD_ARGS="-rpath-link @SBOX_TARGET_ROOT@/usr/lib:@SBOX_TARGET_ROOT@/lib"
+ SBOX_CROSS_GCC_SUBST_PREFIX=$GCC_PREFIX
+
+ cat - > $HOME/.scratchbox2/$TARGET/sb2.config.d/gcc$gcc_version_id.config.sh <<EOF
+# gcc configuration file generated by sb2-config-gcc-toolchain.
+SB2_GCC_INIT_ORIG_ARGS="$SB2_GCC_INIT_ORIG_ARGS"
+SB2_GCC_INIT_TIME=$SB2_GCC_INIT_TIME
+SB2_GCC_INIT_ID="$SB2_GCC_INIT_ID"
+SB2_GCC_INIT_ARCH="$ARCH"
+
+SBOX_GCC_TARGET=$GCC_TARGET
+SBOX_DEFAULT_GCC_PREFIX=$GCC_PREFIX
+SBOX_CROSS_GCC_NAME=cross-gcc
+SBOX_CROSS_GCC_VERSION="$SBOX_CROSS_GCC_VERSION"
+SBOX_CROSS_GCC_SHORTVERSION="$SBOX_CROSS_GCC_SHORTVERSION"
+SBOX_CROSS_GCC_PREFIX_LIST=$SBOX_CROSS_GCC_PREFIX_LIST
+SBOX_CROSS_GCC_SUBST_PREFIX=$SBOX_CROSS_GCC_SUBST_PREFIX
+SBOX_CROSS_GCC_SPECS_FILE="$SBOX_CROSS_GCC_SPECS_FILE"
+SBOX_CROSS_GCC_DIR=$SBOX_CROSS_GCC_DIR
+SBOX_CROSS_GCC_LD_ARGS=
+
+SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS"
+SBOX_EXTRA_CROSS_COMPILER_STDINC="$SBOX_EXTRA_CROSS_COMPILER_STDINC"
+SBOX_EXTRA_CROSS_LD_ARGS="$SBOX_CROSS_GCC_PREFIX_LIST"
+EOF
+
+ cat - > $HOME/.scratchbox2/$TARGET/sb2.config.d/gcc.config$gcc_version_id.lua <<EOF
+-- Automatically created gcc config for SB2's lua scripts. Do not edit.
+
+gcc_config$gcc_version_id = {
+ target_toolchain_dir="$SBOX_TARGET_TOOLCHAIN_DIR",
+
+ cross_gcc_prefix_list="$SBOX_CROSS_GCC_PREFIX_LIST",
+ cross_gcc_dir="$SBOX_CROSS_GCC_DIR",
+ cross_gcc_version="$SBOX_CROSS_GCC_VERSION",
+ cross_gcc_shortversion="$SBOX_CROSS_GCC_SHORTVERSION",
+
+ extra_cross_compiler_args="$SBOX_EXTRA_CROSS_COMPILER_ARGS",
+
+ cross_gcc_subst_prefix="$SBOX_CROSS_GCC_SUBST_PREFIX",
+ cross_gcc_specs_file="$SBOX_CROSS_GCC_SPECS_FILE",
+ extra_cross_compiler_stdinc="$SBOX_EXTRA_CROSS_COMPILER_STDINC",
+ block_cross_compiler_args="$SBOX_BLOCK_CROSS_COMPILER_ARGS",
+
+ extra_cross_ld_args="$SBOX_EXTRA_CROSS_LD_ARGS",
+ block_cross_ld_args="$SBOX_BLOCK_CROSS_LD_ARGS",
+}
+
+add_cross_compiler(gcc_config$gcc_version_id, "$gcc_version")
+
+EOF
+
+ if [ -n "$verbose" ] ; then
+ echo "Finished writing sb2.gcc.config"
+ fi
+}
+
+# SB2_GCC_INIT_* variables are used to record who & when this
+# toolchain was initialized
+# It is possible to set SB2_GCC_INIT_ID externally (for example, if
+# another program is used to initialize the system)
+SB2_GCC_INIT_ORIG_ARGS="$*"
+SB2_GCC_INIT_TIME=`date +%Y-%m-%d_%H:%M:%S`
+if [ -z "$SB2_GCC_INIT_ID" ]; then
+ SB2_GCC_INIT_ID="user '$USER'"
+fi
+
+SBOX_EXTRA_CROSS_COMPILER_ARGS=""
+
+if [ -z "$*" ]; then
+ usage
+fi
+
+verbose=""
+
+while getopts t:m:C:A:hS:R:Vv option
+do
+ case $option in
+ (A) ARCH=$OPTARG ;;
+ (h) usage ;;
+ (t) TARGET=$OPTARG ;;
+ (m) MAPPING_MODE=$OPTARG ;;
+ (C) SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS $OPTARG " ;;
+ (S) SBOX_DIR=$OPTARG ;;
+ (R) SBOX_TARGET_ROOT=$OPTARG ;;
+ (V) SECONDARY_COMPILER=yes ;;
+ (v) verbose=yes ;;
+ (*) usage ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+GCC=$1
+
+# ---------- Check parameters
+
+if [ -z "$SBOX_DIR" ]; then
+ SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
+fi
+
+if [ -z "$TARGET" ]; then
+ echo "Error: no target given"
+ exit 1
+fi
+
+if [ -z "$SBOX_TARGET_ROOT" ]; then
+ echo "Error: no target_root given"
+ exit 1
+fi
+
+if [ ! -d $SBOX_TARGET_ROOT ]; then
+ echo "Error: Target root directory does not exist"
+ exit 1
+fi
+
+if [ -z "$MAPPING_MODE" ]; then
+ echo "Error: no mapping mode given"
+ exit 1
+fi
+
+if [ ! -d $SBOX_DIR/share/scratchbox2/lua_scripts/pathmaps/$MAPPING_MODE ]; then
+ echo "Invalid mapping mode: $MAPPING_MODE"
+ exit 1
+fi
+
+if [ -z "$GCC" ]; then
+ echo "Error: no compiler given"
+ exit 1
+fi
+
+GCC_FULLPATH=$(which $GCC)
+# test that gcc exists and can be executed
+if [ $? != 0 ]; then
+ echo "$GCC doesn't exist"
+ exit 1
+fi
+
+SBOX_CROSS_GCC_DIR=$(dirname $(which $GCC))
+if [ $GCC -v > /dev/null 2>&1 != 0 ]; then
+ echo "Invalid compiler specified: $GCC"
+ exit 1
+fi
+
+# ---------- end of parameter checks
+
+GCC_PREFIX=$(basename $GCC | sed 's/-gcc$/-/')
+
+SBOX_CROSS_GCC_VERSION=`$GCC -dumpversion`
+
+# Create a version string with two digits
+SBOX_CROSS_GCC_SHORTVERSION=`echo $SBOX_CROSS_GCC_VERSION |
+ sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\)\..*/\1/'`
+
+if [ -z "$ARCH" ]; then
+ if [ -n "$verbose" ] ; then
+ echo "Using $GCC to detect target architecture:"
+ fi
+ ARCH=$($GCC -dumpmachine | awk -F- '{ print $1 }')
+ GCC_TARGET=$($GCC -dumpmachine)
+else
+ if [ -n "$verbose" ] ; then
+ echo "Target architecture set to $ARCH"
+ fi
+fi
+
+# default for the cross-gcc prefix list:
+# these may be changed by sb2rc.$MAPPING_MODE
+
+SB2INIT_CROSS_GCC_PREFIX_LIST=$ARCH-linux-
+
+# $ARCH has been set, get mode-specific settings..
+if [ -f $SBOX_DIR/share/scratchbox2/modeconf/sb2rc.$MAPPING_MODE ]; then
+ if [ -n "$verbose" ] ; then
+ echo "Reading mode-specific settings.."
+ fi
+ . $SBOX_DIR/share/scratchbox2/modeconf/sb2rc.$MAPPING_MODE "initializing"
+fi
+
+
+# Use "specs" file for gcc if it exists, otherwise add -I/usr/include to params
+SBOX_CROSS_GCC_SPECS_FILE=""
+SBOX_EXTRA_CROSS_COMPILER_STDINC=""
+if [ -f $SBOX_DIR/share/scratchbox2/modeconf/gcc-specs.$MAPPING_MODE ]; then
+ SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DIR/share/scratchbox2/modeconf/gcc-specs.$MAPPING_MODE"
+else
+ SBOX_EXTRA_CROSS_COMPILER_STDINC="-I/usr/include"
+fi
+
+# Note: "sb2" script will replace "@SBOX_TARGET_ROOT@" by the real
+# value when the session is created.
+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="$SBOX_EXTRA_CROSS_COMPILER_ARGS -Wno-poison-system-directories"
+fi
+
+##### HOST_GCC_INC=$(echo "#include <stdio.h>" | gcc -M -E - | SBOX_DIR=$SBOX_DIR 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"};')
+
+if [ -z "$SECONDARY_COMPILER" ] ; then
+ write_gcc_config
+else
+ write_gcc_config $SBOX_CROSS_GCC_VERSION
+fi
+
+if [ -n "$verbose" ] ; then
+ echo "gcc configured."
+fi
+exit 0
diff --git a/utils/sb2-init b/utils/sb2-init
index e28575a..3774395 100755
--- a/utils/sb2-init
+++ b/utils/sb2-init
@@ -54,13 +54,16 @@ function usage()
cat <<EOF
sb2-init - initialize a target root for scratchbox2
Usage:
- sb2-init [OPTION]... [TARGETNAME] [COMPILER]
+ sb2-init [OPTION]... [TARGETNAME] [COMPILER] [SECONDARY_COMPILER...]
sb2-init is expected to be run in the directory you want
to use as scratchbox 2 target root.
TARGETNAME is what you want to call this target
COMPILER is of the form $HOME/arm-2006q3/bin/arm-linux-gcc
+If more than one compiler is specified, the additional compilers
+are available by version number (e.g. if the primary is known as
+"gcc" and "gcc-4.1", the secondary may be "gcc-3.4", etc)
Options:
@@ -108,29 +111,14 @@ SBOX_INIT_ORIG_ARGS="$SBOX_INIT_ORIG_ARGS"
SBOX_INIT_TIME=$SB2INIT_INIT_TIME
SBOX_INIT_ID="$SB2INIT_INIT_ID"
-SBOX_CONFIG_VERSION=9
+SBOX_CONFIG_VERSION=10
SBOX_TARGET_ROOT=$SBOX_TARGET_ROOT
SBOX_CPU=$ARCH
-SBOX_GCC_TARGET=$GCC_TARGET
SBOX_CPUTRANSPARENCY_METHOD="$SB2INIT_CPUTRANSP"
SBOX_UNAME_MACHINE=$ARCH
-SBOX_DEFAULT_GCC_PREFIX=$GCC_PREFIX
-
-SBOX_CROSS_GCC_NAME=cross-gcc
-SBOX_CROSS_GCC_VERSION="$SBOX_CROSS_GCC_VERSION"
-SBOX_CROSS_GCC_SHORTVERSION="$SBOX_CROSS_GCC_SHORTVERSION"
-SBOX_CROSS_GCC_PREFIX_LIST=$GCC_TARGET-:$SB2INIT_CROSS_GCC_PREFIX_LIST:$GCC_PREFIX
-SBOX_CROSS_GCC_SUBST_PREFIX=$GCC_PREFIX
-SBOX_CROSS_GCC_SPECS_FILE="$SBOX_CROSS_GCC_SPECS_FILE"
-SBOX_CROSS_GCC_DIR=$GCC_PATH
-SBOX_CROSS_GCC_LD_ARGS=
-SBOX_EXTRA_CROSS_COMPILER_ARGS="$SBOX_EXTRA_CROSS_COMPILER_ARGS"
-SBOX_EXTRA_CROSS_COMPILER_STDINC="$SBOX_EXTRA_CROSS_COMPILER_STDINC"
-SBOX_EXTRA_CROSS_LD_ARGS="-rpath-link $SBOX_TARGET_ROOT/usr/lib:$SBOX_TARGET_ROOT/lib"
-
DEB_BUILD_ARCH=$SB2INIT_DEB_BUILD_ARCH
DEB_BUILD_ARCH_CPU=$SB2INIT_DEB_BUILD_ARCH_CPU
DEB_BUILD_ARCH_ABI=$SB2INIT_DEB_BUILD_ARCH_ABI
@@ -219,6 +207,30 @@ you can re-run this script."
fi
}
+function configure_toolchains()
+{
+ secondary_compiler=""
+ for compiler_path in $*; do
+ log_config_action "sb2-init: configuring toolchain, compiler $compiler_path"
+ $SBOX_SHARE_DIR/scripts/sb2-config-gcc-toolchain \
+ -v \
+ $secondary_compiler \
+ -R "$SBOX_TARGET_ROOT" \
+ -S "$SBOX_DIR" \
+ -t "$TARGET" \
+ -m "$MAPPING_MODE" \
+ -C "$SB2INIT_SBOX_EXTRA_CROSS_COMPILER_ARGS" \
+ -- \
+ $compiler_path
+ if [ $? != 0 ]; then
+ log_config_action "sb2-init: failed to configure $compiler_path"
+ echo "Failed to configure $compiler_path"
+ exit 1
+ fi
+ secondary_compiler="-V"
+ done
+}
+
if [ -z "$SBOX_DIR" ]; then
SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
fi
@@ -239,10 +251,8 @@ eval `$SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args $SBOX_INIT_ORIG_ARGS`
TARGET=$SB2INIT_TARGET
SBOX_TARGET_ROOT=$SB2INIT_TARGET_ROOT
-GCC=$SB2INIT_COMPILERS
MAPPING_MODE=$SB2INIT_MAPPING_MODE
-SBOX_EXTRA_CROSS_COMPILER_ARGS=$SB2INIT_SBOX_EXTRA_CROSS_COMPILER_ARGS
# ---------- Check parameters
@@ -289,39 +299,16 @@ log_config_action "sb2-init $SBOX_INIT_ORIG_ARGS"
$SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args $SBOX_INIT_ORIG_ARGS \
>$SBOX_CONFIG_DIR/sb2-init-args
-if [ -z "$GCC" ]; then
+if [ -z "$SB2INIT_COMPILERS" ]; then
echo "Warning: no compiler given"
ARCH=$SB2INIT_ARCH
- echo "Target architecture set to '$ARCH'"
else
- 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$/-/')
-
- SBOX_CROSS_GCC_VERSION=`$GCC -dumpversion`
- # Create a version string with two digits
- SBOX_CROSS_GCC_SHORTVERSION=`echo $SBOX_CROSS_GCC_VERSION |
- sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\)\..*/\1/'`
-
- if [ -z "$SB2INIT_ARCH" ]; then
- echo "Using $GCC to detect target architecture:"
- ARCH=$($GCC -dumpmachine | awk -F- '{ print $1 }')
- GCC_TARGET=$($GCC -dumpmachine)
- else
- ARCH=$SB2INIT_ARCH
- echo "Target architecture set to '$ARCH'"
- fi
+ configure_toolchains $SB2INIT_COMPILERS
+ # get ARCH from the primary gcc config file
+ . $HOME/.scratchbox2/$TARGET/sb2.config.d/gcc.config.sh
+ ARCH=$SB2_GCC_INIT_ARCH
fi
+echo "sb2-init: Target architecture is '$ARCH'"
DEBIAN_CPU=$ARCH
@@ -329,14 +316,16 @@ HOST_ARCH="$(uname -m)"
if echo "$HOST_ARCH" | grep -q "^i.86*"; then
HOST_ARCH="i[3456]86"
fi
+echo "sb2-init: Host architecture is '$HOST_ARCH'"
case "$ARCH" in
$HOST_ARCH*) ;;
arm*)
- if [ -z "$GCC_TARGET" ]; then
+ # SBOX_GCC_TARGET from gcc.config.sh..
+ if [ -z "$SBOX_GCC_TARGET" ]; then
DEBIAN_CPU=$ARCH
else
- echo $GCC_TARGET | grep -q -i eabi
+ echo $SBOX_GCC_TARGET | grep -q -i eabi
if [ $? == 0 ]; then
DEBIAN_CPU=armel
fi
@@ -372,8 +361,6 @@ SB2INIT_DEB_HOST_GNU_SYSTEM=""
SB2INIT_DEB_HOST_ARCH_OS="linux"
SB2INIT_DEB_HOST_ARCH_CPU=$DEBIAN_CPU
-SB2INIT_CROSS_GCC_PREFIX_LIST=$ARCH-linux-
-
# $ARCH has been set, get mode-specific settings..
if [ -f $SBOX_DIR/share/scratchbox2/modeconf/sb2rc.$MAPPING_MODE ]; then
echo "Reading mode-specific settings.."
@@ -402,24 +389,6 @@ if [ -n "$SB2INIT_TOOLS_ROOT" ]; then
# else assume standard FHS system
fi
-# Use "specs" file for gcc if it exists, otherwise add -I/usr/include to params
-SBOX_CROSS_GCC_SPECS_FILE=""
-SBOX_EXTRA_CROSS_COMPILER_STDINC=""
-if [ -f $SBOX_DIR/share/scratchbox2/modeconf/gcc-specs.$MAPPING_MODE ]; then
- SBOX_CROSS_GCC_SPECS_FILE="$SBOX_DIR/share/scratchbox2/modeconf/gcc-specs.$MAPPING_MODE"
-else
- SBOX_EXTRA_CROSS_COMPILER_STDINC="-I/usr/include"
-fi
-
-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="$SBOX_EXTRA_CROSS_COMPILER_ARGS -Wno-poison-system-directories"
-fi
-
HOST_GCC_INC=$(echo "#include <stdio.h>" | gcc -M -E - | SBOX_DIR=$SBOX_DIR 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"};')
mkdir -p $HOME/.scratchbox2/$TARGET/bin
diff --git a/utils/sb2-upgrade-config b/utils/sb2-upgrade-config
index c48471a..9e47099 100755
--- a/utils/sb2-upgrade-config
+++ b/utils/sb2-upgrade-config
@@ -69,6 +69,30 @@ function get_sb2_init_arguments_from_old_config_file()
log_config_action "Config upgrade: arguments of original sb2-init restored from old config file"
}
+function update_toolchain_configs()
+{
+ secondary_compiler=""
+ for compiler_path in $*; do
+ echo "Updating compiler $compiler_path"
+ log_config_action "Config upgrade: settings for compiler $compiler_path"
+ $SBOX_SHARE_DIR/scripts/sb2-config-gcc-toolchain \
+ $secondary_compiler \
+ -R "$SB2INIT_TARGET_ROOT" \
+ -S "$SBOX_SHARE_DIR/../.." \
+ -t "$SB2INIT_TARGET" \
+ -m "$SB2INIT_MAPPING_MODE" \
+ -C "$SB2INIT_SBOX_EXTRA_CROSS_COMPILER_ARGS" \
+ -- \
+ $compiler_path
+ if [ $? != 0 ]; then
+ log_config_action "failed to configure $compiler_path"
+ echo "Failed to configure $compiler_path"
+ exit 1
+ fi
+ secondary_compiler="-V"
+ done
+}
+
if [ ! -d $SBOX_CONFIG_DIR ]; then
mkdir $SBOX_CONFIG_DIR
log_config_action "Config upgrade: Created configuration directory"
@@ -86,6 +110,12 @@ fi
#==============================================
# Finally:
-log_config_action "Config updated to version #10"
-touch $SBOX_CONFIG_DIR/config-stamp.10
+# check if we need to actually update something:
+# version "11" added separate config files for gcc toolchains:
+if [ ! -f $SBOX_CONFIG_DIR/config-stamp.11 ]; then
+ update_toolchain_configs $SB2INIT_COMPILERS
+fi
+
+log_config_action "Config updated to version #11"
+touch $SBOX_CONFIG_DIR/config-stamp.11
diff --git a/wrappers/dpkg-checkbuilddeps b/wrappers/dpkg-checkbuilddeps
index 90e4c2e..b2dbd5c 100755
--- a/wrappers/dpkg-checkbuilddeps
+++ b/wrappers/dpkg-checkbuilddeps
@@ -134,7 +134,7 @@ function check_gcc_dependency()
{
required_gcc=$1
- if [ -n "$sbox_cross_gcc_dir" ]
+ if [ -f $HOME/.scratchbox2/$sbox_target/sb2.config.d/gcc.config.sh ]
then
# a cross compiler has been configured
if [ "$required_gcc" = "gcc" ]
@@ -144,13 +144,22 @@ function check_gcc_dependency()
return 0
fi
#
- # Find out if gcc version is suitable
- gcc_vrs=`gcc -dumpversion`
- case "gcc-$gcc_vrs" in
- $required_gcc*) # required_gcc is prefix of gcc_vrs => OK
- echo "SB2 provides $required_gcc ($gcc_vrs)"
- return 0
- esac
+ # Find out if gcc version is suitable, try all configured
+ # toolchains
+ for gcc_conf_file in \
+ $HOME/.scratchbox2/$sbox_target/sb2.config.d/gcc*.config.sh
+ do
+ if [ -f $gcc_conf_file ]; then
+ . $gcc_conf_file
+ short_vrs="gcc-$SBOX_CROSS_GCC_SHORTVERSION"
+ full_vrs="gcc-$SBOX_CROSS_GCC_VERSION"
+ if [ "$required_gcc" = "$short_vrs" -o \
+ "$required_gcc" = "$full_vrs" ]; then
+ echo "SB2 provides $required_gcc"
+ return 0
+ fi
+ fi
+ done
fi # else a cross-compiler is not available, gcc comes from tools
# Failed, SB2 environment does not provide a suitable gcc.