Push the calculation of the tuple's kernel part down to kernel's build scripts:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Oct 23 13:45:48 2008 +0000 (2008-10-23)
changeset 96545ddf096def1
parent 964 0535f7bf1069
child 966 b6eec1274efb
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(-)
docs/overview.txt
scripts/build/kernel/bare-metal.sh
scripts/build/kernel/linux.sh
scripts/crosstool.sh
scripts/functions
     1.1 --- a/docs/overview.txt	Thu Oct 23 13:00:45 2008 +0000
     1.2 +++ b/docs/overview.txt	Thu Oct 23 13:45:48 2008 +0000
     1.3 @@ -512,9 +512,8 @@
     1.4  Kconfig parser |
     1.5  ---------------+
     1.6  
     1.7 -The kconfig language is a hacked version, vampirised from the toybox project
     1.8 -by Rob LANDLEY (http://www.landley.net/code/toybox/), itself coming from the
     1.9 -Linux kernel (http://www.kernel.org/), and (heavily) adapted to my needs.
    1.10 +The kconfig language is a hacked version, vampirised from the Linux kernel
    1.11 +(http://www.kernel.org/), and (heavily) adapted to my needs.
    1.12  
    1.13  The kconfig parsers (conf and mconf) are not installed pre-built, but as
    1.14  source files. Thus you can have the directory where crosstool-NG is installed,
    1.15 @@ -573,7 +572,7 @@
    1.16      prefix is unique among architectures, and does not cause harm).
    1.17  
    1.18  The architecture's ".sh" file API:
    1.19 - > the function "CT_DoArchValues"
    1.20 + > the function "CT_DoArchTupleValues"
    1.21     + parameters: none
    1.22     + environment:
    1.23       - all variables from the ".config" file,
    1.24 @@ -701,6 +700,12 @@
    1.25  The kernel's ".sh" file API:
    1.26   > is a bash script fragment
    1.27  
    1.28 + > defines the function CT_DoKernelTupleValues
    1.29 +   + see the architecture's CT_DoArchTupleValues, except for:
    1.30 +   + set the environment variable CT_TARGET_KERNEL, the kernel part of the
    1.31 +     target tuple
    1.32 +   + return value: ignored
    1.33 +
    1.34   > defines the function "do_print_filename":
    1.35     + parameters: none
    1.36     + environment:
     2.1 --- a/scripts/build/kernel/bare-metal.sh	Thu Oct 23 13:00:45 2008 +0000
     2.2 +++ b/scripts/build/kernel/bare-metal.sh	Thu Oct 23 13:45:48 2008 +0000
     2.3 @@ -2,6 +2,11 @@
     2.4  # Copyright 2008 Yann E. MORIN
     2.5  # Licensed under the GPL v2. See COPYING in the root of this package
     2.6  
     2.7 +CT_DoKernelTupleValues() {
     2.8 +    # For bare-metal, there is no kernel part in the tuple
     2.9 +    CT_TARGET_KERNEL=
    2.10 +}
    2.11 +
    2.12  do_print_filename() {
    2.13      :
    2.14  }
     3.1 --- a/scripts/build/kernel/linux.sh	Thu Oct 23 13:00:45 2008 +0000
     3.2 +++ b/scripts/build/kernel/linux.sh	Thu Oct 23 13:45:48 2008 +0000
     3.3 @@ -2,6 +2,11 @@
     3.4  # Copyright 2007 Yann E. MORIN
     3.5  # Licensed under the GPL v2. See COPYING in the root of this package
     3.6  
     3.7 +CT_DoKernelTupleValues() {
     3.8 +    # Nothing to do, keep the default value
     3.9 +    :
    3.10 +}
    3.11 +
    3.12  do_print_filename() {
    3.13      echo "linux-${CT_KERNEL_VERSION}"
    3.14  }
     4.1 --- a/scripts/crosstool.sh	Thu Oct 23 13:00:45 2008 +0000
     4.2 +++ b/scripts/crosstool.sh	Thu Oct 23 13:45:48 2008 +0000
     4.3 @@ -23,12 +23,9 @@
     4.4  CT_STAR_DATE=$(CT_DoDate +%s%N)
     4.5  CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S)
     4.6  
     4.7 -# Are we configured? We'll need that later...
     4.8 -CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
     4.9 -
    4.10  # Parse the configuration file
    4.11  # It has some info about the logging facility, so include it early
    4.12 -. "${CT_TOP_DIR}/.config"
    4.13 +. .config
    4.14  
    4.15  # Yes! We can do full logging from now on!
    4.16  CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
    4.17 @@ -37,7 +34,7 @@
    4.18  CT_DoExecLog DEBUG renice ${CT_NICE} $$
    4.19  
    4.20  CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
    4.21 -cat "${CT_TOP_DIR}/.config" |egrep '^(# |)CT_' |CT_DoLog DEBUG
    4.22 +CT_DoExecLog DEBUG egrep '^(# |)CT_' .config
    4.23  CT_EndStep
    4.24  
    4.25  # Some sanity checks in the environment and needed tools
    4.26 @@ -52,12 +49,21 @@
    4.27  CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
    4.28  CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
    4.29  CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
    4.30 -GREP_OPTIONS=
    4.31 +export GREP_OPTIONS=
    4.32  
    4.33  CT_DoLog INFO "Building environment variables"
    4.34  
    4.35 -# Parse architecture-specific functions
    4.36 +# Include sub-scripts instead of calling them: that way, we do not have to
    4.37 +# export any variable, nor re-parse the configuration and functions files.
    4.38  . "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
    4.39 +. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
    4.40 +. "${CT_LIB_DIR}/scripts/build/gmp.sh"
    4.41 +. "${CT_LIB_DIR}/scripts/build/mpfr.sh"
    4.42 +. "${CT_LIB_DIR}/scripts/build/binutils.sh"
    4.43 +. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
    4.44 +. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
    4.45 +. "${CT_LIB_DIR}/scripts/build/tools.sh"
    4.46 +. "${CT_LIB_DIR}/scripts/build/debug.sh"
    4.47  
    4.48  # Target tuple: CT_TARGET needs a little love:
    4.49  CT_DoBuildTargetTuple
    4.50 @@ -354,17 +360,6 @@
    4.51      CT_EndStep
    4.52  fi
    4.53  
    4.54 -# Include sub-scripts instead of calling them: that way, we do not have to
    4.55 -# export any variable, nor re-parse the configuration and functions files.
    4.56 -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
    4.57 -. "${CT_LIB_DIR}/scripts/build/gmp.sh"
    4.58 -. "${CT_LIB_DIR}/scripts/build/mpfr.sh"
    4.59 -. "${CT_LIB_DIR}/scripts/build/binutils.sh"
    4.60 -. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
    4.61 -. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
    4.62 -. "${CT_LIB_DIR}/scripts/build/tools.sh"
    4.63 -. "${CT_LIB_DIR}/scripts/build/debug.sh"
    4.64 -
    4.65  if [ -z "${CT_RESTART}" ]; then
    4.66      CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
    4.67      do_kernel_get
     5.1 --- a/scripts/functions	Thu Oct 23 13:00:45 2008 +0000
     5.2 +++ b/scripts/functions	Thu Oct 23 13:45:48 2008 +0000
     5.3 @@ -674,6 +674,9 @@
     5.4              ;;
     5.5      esac
     5.6  
     5.7 +    # Build the default architecture tuple part
     5.8 +    CT_TARGET_ARCH="${CT_ARCH}"
     5.9 +
    5.10      # Set defaults for the system part of the tuple. Can be overriden
    5.11      # by architecture-specific values.
    5.12      case "${CT_LIBC}" in
    5.13 @@ -695,17 +698,15 @@
    5.14      [ "${CT_ARCH_FPU}"      ] && { CT_ARCH_FPU_CFLAG="-mfpu=${CT_ARCH_FPU}";     CT_ARCH_WITH_FPU="--with-fpu=${CT_ARCH_FPU}";    }
    5.15      [ "${CT_ARCH_FLOAT_SW}" ] && { CT_ARCH_FLOAT_CFLAG="-msoft-float";           CT_ARCH_WITH_FLOAT="--with-float=soft";          }
    5.16  
    5.17 -    # Build the kernel tuple part
    5.18 -    case "${CT_KERNEL}" in
    5.19 -        bare-metal) CT_TARGET_KERNEL=;;
    5.20 -        linux)      CT_TARGET_KERNEL=linux-;;
    5.21 -    esac
    5.22 +    # Build the default kernel tuple part
    5.23 +    CT_TARGET_KERNEL="${CT_KERNEL}"
    5.24  
    5.25 -    # Call the architecture specific settings
    5.26 +    # Overide the default values with the components specific settings
    5.27      CT_DoArchTupleValues
    5.28 +    CT_DoKernelTupleValues
    5.29  
    5.30      # Finish the target tuple construction
    5.31 -    CT_TARGET=$(CT_DoConfigSub "${CT_TARGET_ARCH}-${CT_TARGET_VENDOR:-unknown}-${CT_TARGET_KERNEL}${CT_TARGET_SYS}")
    5.32 +    CT_TARGET=$(CT_DoConfigSub "${CT_TARGET_ARCH}-${CT_TARGET_VENDOR:-unknown}-${CT_TARGET_KERNEL}${CT_TARGET_KERNEL:+-}${CT_TARGET_SYS}")
    5.33  
    5.34      # Prepare the target CFLAGS
    5.35      CT_ARCH_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_ARCH_ENDIAN_CFLAG}"