From 1c625d676cb8703fbf8956bc87d90bf5cdf21d89 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Thu, 23 Oct 2008 13:45:48 +0000 Subject: Push the calculation of the tuple's kernel part down to kernel's build scripts: - update the kernel script's API with the function CT_DiKernelTupleValues - update doc accordingly (also with the architecture change, missing in the previous commit) - small clean-up in the main script, remove useless test /trunk/scripts/build/kernel/bare-metal.sh | 5 5 0 0 +++++ /trunk/scripts/build/kernel/linux.sh | 5 5 0 0 +++++ /trunk/scripts/crosstool.sh | 31 13 18 0 +++++++++++++------------------ /trunk/scripts/functions | 15 8 7 0 ++++++++------- /trunk/docs/overview.txt | 13 9 4 0 +++++++++---- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/docs/overview.txt b/docs/overview.txt index 675f2da..c040646 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -512,9 +512,8 @@ was unbuildable. Kconfig parser | ---------------+ -The kconfig language is a hacked version, vampirised from the toybox project -by Rob LANDLEY (http://www.landley.net/code/toybox/), itself coming from the -Linux kernel (http://www.kernel.org/), and (heavily) adapted to my needs. +The kconfig language is a hacked version, vampirised from the Linux kernel +(http://www.kernel.org/), and (heavily) adapted to my needs. The kconfig parsers (conf and mconf) are not installed pre-built, but as source files. Thus you can have the directory where crosstool-NG is installed, @@ -573,7 +572,7 @@ The architecture's ".in" file API: prefix is unique among architectures, and does not cause harm). The architecture's ".sh" file API: - > the function "CT_DoArchValues" + > the function "CT_DoArchTupleValues" + parameters: none + environment: - all variables from the ".config" file, @@ -701,6 +700,12 @@ The kernel's ".in" file must contain: The kernel's ".sh" file API: > is a bash script fragment + > defines the function CT_DoKernelTupleValues + + see the architecture's CT_DoArchTupleValues, except for: + + set the environment variable CT_TARGET_KERNEL, the kernel part of the + target tuple + + return value: ignored + > defines the function "do_print_filename": + parameters: none + environment: diff --git a/scripts/build/kernel/bare-metal.sh b/scripts/build/kernel/bare-metal.sh index 2dfda41..be83d16 100644 --- a/scripts/build/kernel/bare-metal.sh +++ b/scripts/build/kernel/bare-metal.sh @@ -2,6 +2,11 @@ # Copyright 2008 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package +CT_DoKernelTupleValues() { + # For bare-metal, there is no kernel part in the tuple + CT_TARGET_KERNEL= +} + do_print_filename() { : } diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh index 27749e2..2313c8b 100644 --- a/scripts/build/kernel/linux.sh +++ b/scripts/build/kernel/linux.sh @@ -2,6 +2,11 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package +CT_DoKernelTupleValues() { + # Nothing to do, keep the default value + : +} + do_print_filename() { echo "linux-${CT_KERNEL_VERSION}" } diff --git a/scripts/crosstool.sh b/scripts/crosstool.sh index cc4ed2a..d688c28 100755 --- a/scripts/crosstool.sh +++ b/scripts/crosstool.sh @@ -23,12 +23,9 @@ CT_STAR_DATE=$(CT_DoDate +%s%N) CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S) -# Are we configured? We'll need that later... -CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config" - # Parse the configuration file # It has some info about the logging facility, so include it early -. "${CT_TOP_DIR}/.config" +. .config # Yes! We can do full logging from now on! CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" @@ -37,7 +34,7 @@ CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}" CT_DoExecLog DEBUG renice ${CT_NICE} $$ CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration" -cat "${CT_TOP_DIR}/.config" |egrep '^(# |)CT_' |CT_DoLog DEBUG +CT_DoExecLog DEBUG egrep '^(# |)CT_' .config CT_EndStep # Some sanity checks in the environment and needed tools @@ -52,12 +49,21 @@ CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LI CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}" CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}" CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}" -GREP_OPTIONS= +export GREP_OPTIONS= CT_DoLog INFO "Building environment variables" -# Parse architecture-specific functions +# Include sub-scripts instead of calling them: that way, we do not have to +# export any variable, nor re-parse the configuration and functions files. . "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" +. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" +. "${CT_LIB_DIR}/scripts/build/gmp.sh" +. "${CT_LIB_DIR}/scripts/build/mpfr.sh" +. "${CT_LIB_DIR}/scripts/build/binutils.sh" +. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" +. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" +. "${CT_LIB_DIR}/scripts/build/tools.sh" +. "${CT_LIB_DIR}/scripts/build/debug.sh" # Target tuple: CT_TARGET needs a little love: CT_DoBuildTargetTuple @@ -354,17 +360,6 @@ if [ -z "${CT_RESTART}" ]; then CT_EndStep fi -# Include sub-scripts instead of calling them: that way, we do not have to -# export any variable, nor re-parse the configuration and functions files. -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" -. "${CT_LIB_DIR}/scripts/build/gmp.sh" -. "${CT_LIB_DIR}/scripts/build/mpfr.sh" -. "${CT_LIB_DIR}/scripts/build/binutils.sh" -. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" -. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" -. "${CT_LIB_DIR}/scripts/build/tools.sh" -. "${CT_LIB_DIR}/scripts/build/debug.sh" - if [ -z "${CT_RESTART}" ]; then CT_DoStep INFO "Retrieving needed toolchain components' tarballs" do_kernel_get diff --git a/scripts/functions b/scripts/functions index f14cc27..d69d549 100644 --- a/scripts/functions +++ b/scripts/functions @@ -674,6 +674,9 @@ CT_DoBuildTargetTuple() { ;; esac + # Build the default architecture tuple part + CT_TARGET_ARCH="${CT_ARCH}" + # Set defaults for the system part of the tuple. Can be overriden # by architecture-specific values. case "${CT_LIBC}" in @@ -695,17 +698,15 @@ CT_DoBuildTargetTuple() { [ "${CT_ARCH_FPU}" ] && { CT_ARCH_FPU_CFLAG="-mfpu=${CT_ARCH_FPU}"; CT_ARCH_WITH_FPU="--with-fpu=${CT_ARCH_FPU}"; } [ "${CT_ARCH_FLOAT_SW}" ] && { CT_ARCH_FLOAT_CFLAG="-msoft-float"; CT_ARCH_WITH_FLOAT="--with-float=soft"; } - # Build the kernel tuple part - case "${CT_KERNEL}" in - bare-metal) CT_TARGET_KERNEL=;; - linux) CT_TARGET_KERNEL=linux-;; - esac + # Build the default kernel tuple part + CT_TARGET_KERNEL="${CT_KERNEL}" - # Call the architecture specific settings + # Overide the default values with the components specific settings CT_DoArchTupleValues + CT_DoKernelTupleValues # Finish the target tuple construction - CT_TARGET=$(CT_DoConfigSub "${CT_TARGET_ARCH}-${CT_TARGET_VENDOR:-unknown}-${CT_TARGET_KERNEL}${CT_TARGET_SYS}") + CT_TARGET=$(CT_DoConfigSub "${CT_TARGET_ARCH}-${CT_TARGET_VENDOR:-unknown}-${CT_TARGET_KERNEL}${CT_TARGET_KERNEL:+-}${CT_TARGET_SYS}") # Prepare the target CFLAGS CT_ARCH_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_ARCH_ENDIAN_CFLAG}" -- cgit v0.10.2-6-g49f6