Merge #1195, #1196 and #1203 from /devel/YEM-build_host_target_cleanup:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Nov 13 18:22:23 2008 +0000 (2008-11-13)
changeset 10412573519c00d6
parent 1040 dc17e615de2c
child 1042 3d35a55cdfbc
Merge #1195, #1196 and #1203 from /devel/YEM-build_host_target_cleanup:
- Get rid of CT_CC_NATIVE
- Get rid of CT_CANADIAN_OPT
- Sanitise CT_BUILD vs. CT_HOST

/trunk/scripts/build/tools/200-sstrip.sh | 4 2 2 0
/trunk/scripts/build/binutils.sh | 1 0 1 0 -
/trunk/scripts/build/cc/gcc.sh | 11 6 5 0 +-
/trunk/scripts/build/debug/200-duma.sh | 3 1 2 0 -
/trunk/scripts/build/libc/glibc.sh | 10 5 5 0 +-
/trunk/scripts/build/libc/eglibc.sh | 8 4 4 0 +-
/trunk/scripts/crosstool.sh | 168 113 55 0 ++++++++++++++++++++++++++------------
/trunk/config/toolchain.in | 160 137 23 0 +++++++++++++++++++++++++++++++-----
8 files changed, 268 insertions(+), 97 deletions(-)
config/toolchain.in
scripts/build/binutils.sh
scripts/build/cc/gcc.sh
scripts/build/debug/200-duma.sh
scripts/build/libc/eglibc.sh
scripts/build/libc/glibc.sh
scripts/build/tools/200-sstrip.sh
scripts/crosstool.sh
     1.1 --- a/config/toolchain.in	Thu Nov 13 17:55:16 2008 +0000
     1.2 +++ b/config/toolchain.in	Thu Nov 13 18:22:23 2008 +0000
     1.3 @@ -81,7 +81,7 @@
     1.4  
     1.5  config NATIVE
     1.6      bool
     1.7 -    prompt "Native (EXPERIMENTAL)"
     1.8 +    prompt "Native       (NO CODE!) (EXPERIMENTAL)"
     1.9      depends on EXPERIMENTAL
    1.10      help
    1.11        Build a native toolchain.
    1.12 @@ -96,7 +96,7 @@
    1.13  
    1.14  config CROSS_NATIVE
    1.15      bool
    1.16 -    prompt "Cross-native (EXPERIMENTAL)"
    1.17 +    prompt "Cross-native (NO CODE!) (EXPERIMENTAL)"
    1.18      depends on EXPERIMENTAL
    1.19      help
    1.20        Build a cross-native toolchain.
    1.21 @@ -104,7 +104,7 @@
    1.22  
    1.23  config CANADIAN
    1.24      bool
    1.25 -    prompt "Canadian (EXPERIMENTAL)"
    1.26 +    prompt "Canadian     (NO CODE!) (EXPERIMENTAL)"
    1.27      depends on EXPERIMENTAL
    1.28      help
    1.29        Build a canadian-toolchain.
    1.30 @@ -119,48 +119,162 @@
    1.31      default "cross-native"  if CROSS_NATIVE
    1.32      default "canadian"      if CANADIAN
    1.33  
    1.34 +comment "Build system"
    1.35 +
    1.36  config BUILD 
    1.37      string
    1.38 -    prompt "Build system tuple"
    1.39 +    prompt "|  Tuple        (READ HELP!)"
    1.40      default ""
    1.41      help
    1.42        Canonical name of the machine building the toolchain.
    1.43        You should leave empty, unless you really now what you're doing.
    1.44  
    1.45 -config CC_NATIVE
    1.46 +config BUILD_PREFIX
    1.47      string
    1.48 -    prompt "Native gcc"
    1.49 -    default "gcc"
    1.50 +    prompt "|  Tools prefix (READ HELP!)"
    1.51 +    default ""
    1.52      help
    1.53 -      The native C compiler.
    1.54 +      If you have your *build system* tools in a weird location, and/or
    1.55 +      they have an unusual prefix, enter it here.
    1.56        
    1.57 -      You can set this to an alternative compiler if you have more than one
    1.58 -      installed (eg. gcc is gcc-4.1.1 and you want to use gcc-3.4.6).
    1.59 +      Usually, you should leave that empty!
    1.60        
    1.61 -      You can leave this empty as well, in which case gcc will be used.
    1.62 +      Eg.:
    1.63 +        If your *build* gcc is /opt/build-tools/bin/weird-gcc then you
    1.64 +        should enter:
    1.65 +            /opt/build-tools/bin/weird-
    1.66 +        
    1.67 +        If your *build* gcc is /opt/build-tools/bin/weird-gcc and
    1.68 +        /opt/build-tools/bin is in your PATH, you should enter:
    1.69 +            weird-
    1.70 +        
    1.71 +        If your *build* gcc is /opt/build-tools/bin/gcc then you
    1.72 +        should enter (do not forget to add the trailing '/'):
    1.73 +            /opt/build-tools/bin/
    1.74 +
    1.75 +config BUILD_SUFFIX
    1.76 +    string
    1.77 +    prompt "|  Tools suffix (READ HELP!)"
    1.78 +    default ""
    1.79 +    help
    1.80 +      If your *build system* tools have an unusual suffix, enter it
    1.81 +      here.
    1.82 +      
    1.83 +      Usually, you should leave that empty!
    1.84 +      
    1.85 +      Eg.:
    1.86 +        If your 'default' gcc is gcc 4.3.1, but you also have gcc-3.4.2
    1.87 +        installed as gcc-3.4, then you should enter:
    1.88 +            -3.4
    1.89 +      
    1.90 +      It can happen that some of the tools have a suffix, when others
    1.91 +      don't, eg. you can have 'gcc-3.4' and 'ar'. crosstool-NG accounts
    1.92 +      for that by checking the tools without the suffix in case it can
    1.93 +      not find some of the tool.
    1.94 +
    1.95 +if CANADIAN
    1.96 +
    1.97 +comment "Host system"
    1.98  
    1.99  config HOST
   1.100      string
   1.101 -    prompt "Host system tuple"
   1.102 +    prompt "|  Tuple        (READ HELP!)"
   1.103      default ""
   1.104 -    depends on NATIVE || CANADIAN
   1.105      help
   1.106        Canonical name of the machine running the toolchain.
   1.107  
   1.108 -config HOST_CC
   1.109 +config HOST_PREFIX
   1.110      string
   1.111 -    prompt "Cross-compiler prefix for host system"
   1.112 -    default "${CT_HOST}-"
   1.113 -    depends on NATIVE || CANADIAN
   1.114 +    prompt "|  Tools prefix (READ HELP!)"
   1.115 +    default ""
   1.116      help
   1.117 -      C compiler targeting the host system.
   1.118 +      If you have your *host system* tools in a weird location, and/or
   1.119 +      they have an unusual prefix, enter it here.
   1.120 +      
   1.121 +      Usually, you should leave that empty!
   1.122 +      
   1.123 +      Eg.:
   1.124 +        If your *host* gcc is /opt/host-tools/bin/weird-gcc then you
   1.125 +        should enter:
   1.126 +            /opt/host-tools/bin/weird-
   1.127 +        
   1.128 +        If your *host* gcc is /opt/host-tools/bin/weird-gcc and
   1.129 +        /opt/host-tools/bin is in your PATH, you should enter:
   1.130 +            weird-
   1.131 +        
   1.132 +        If your *host* gcc is /opt/host-tools/bin/gcc then you
   1.133 +        should enter (do not forget to add the trailing '/'):
   1.134 +            /opt/host-tools/bin/
   1.135  
   1.136 -config TARGET_CC
   1.137 +config HOST_SUFFIX
   1.138      string
   1.139 -    prompt "Cross-compiler prefix for target system"
   1.140 -    default "${CT_TARGET}-"
   1.141 -    depends on CANADIAN
   1.142 +    prompt "|  Tools suffix (READ HELP!)"
   1.143 +    default ""
   1.144      help
   1.145 -      C compiler targeting the target system.
   1.146 +      If your *host system* tools have an unusual suffix, enter it
   1.147 +      here.
   1.148 +      
   1.149 +      Usually, you should leave that empty!
   1.150 +      
   1.151 +      Eg.:
   1.152 +        If your 'default' gcc is gcc 4.3.1, but you also have gcc-3.4.2
   1.153 +        installed as gcc-3.4, then you should enter:
   1.154 +            -3.4
   1.155 +      
   1.156 +      It can happen that some of the tools have a suffix, when others
   1.157 +      don't, eg. you can have 'gcc-3.4' and 'ar'. crosstool-NG accounts
   1.158 +      for that by checking the tools without the suffix in case it can
   1.159 +      not find some of the tool.
   1.160 +
   1.161 +endif # CANADIAN
   1.162 +
   1.163 +if CROSS_NATIVE || CANADIAN
   1.164 +
   1.165 +comment "Target system"
   1.166 +
   1.167 +config TARGET_PREFIX
   1.168 +    string
   1.169 +    prompt "|  Tools prefix (READ HELP!)"
   1.170 +    default ""
   1.171 +    help
   1.172 +      If you have your *target system* tools in a weird location, and/or
   1.173 +      they have an unusual prefix, enter it here.
   1.174 +      
   1.175 +      Usually, you should leave that empty!
   1.176 +      
   1.177 +      Eg.:
   1.178 +        If your *target* gcc is /opt/target-tools/bin/weird-gcc then you
   1.179 +        should enter:
   1.180 +            /opt/target-tools/bin/weird-
   1.181 +        
   1.182 +        If your *target* gcc is /opt/target-tools/bin/weird-gcc and
   1.183 +        /opt/target-tools/bin is in your PATH, you should enter:
   1.184 +            weird-
   1.185 +        
   1.186 +        If your *target* gcc is /opt/target-tools/bin/gcc then you
   1.187 +        should enter (do not forget to add the trailing '/'):
   1.188 +            /opt/target-tools/bin/
   1.189 +
   1.190 +config TARGET_SUFFIX
   1.191 +    string
   1.192 +    prompt "|  Tools suffix (READ HELP!)"
   1.193 +    default ""
   1.194 +    help
   1.195 +      If your *target system* tools have an unusual suffix, enter it
   1.196 +      here.
   1.197 +      
   1.198 +      Usually, you should leave that empty!
   1.199 +      
   1.200 +      Eg.:
   1.201 +        If your 'default' gcc is gcc 4.3.1, but you also have gcc-3.4.2
   1.202 +        installed as gcc-3.4, then you should enter:
   1.203 +            -3.4
   1.204 +      
   1.205 +      It can happen that some of the tools have a suffix, when others
   1.206 +      don't, eg. you can have 'gcc-3.4' and 'ar'. crosstool-NG accounts
   1.207 +      for that by checking the tools without the suffix in case it can
   1.208 +      not find some of the tool.
   1.209 +
   1.210 +endif # CROSS_NATIVE || CANADIAN
   1.211  
   1.212  endmenu
     2.1 --- a/scripts/build/binutils.sh	Thu Nov 13 17:55:16 2008 +0000
     2.2 +++ b/scripts/build/binutils.sh	Thu Nov 13 18:22:23 2008 +0000
     2.3 @@ -36,7 +36,6 @@
     2.4      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
     2.5      CT_DoExecLog ALL                                \
     2.6      "${CT_SRC_DIR}/${CT_BINUTILS_FILE}/configure"   \
     2.7 -        ${CT_CANADIAN_OPT}                          \
     2.8          --build=${CT_BUILD}                         \
     2.9          --host=${CT_HOST}                           \
    2.10          --target=${CT_TARGET}                       \
     3.1 --- a/scripts/build/cc/gcc.sh	Thu Nov 13 17:55:16 2008 +0000
     3.2 +++ b/scripts/build/cc/gcc.sh	Thu Nov 13 18:22:23 2008 +0000
     3.3 @@ -126,11 +126,11 @@
     3.4      CT_DoLog DEBUG "Extra config passed: '${extra_config}'"
     3.5  
     3.6      # Use --with-local-prefix so older gccs don't look in /usr/local (http://gcc.gnu.org/PR10532)
     3.7 -    CC_FOR_BUILD="${CT_CC_NATIVE}"                  \
     3.8 +    CC_FOR_BUILD="${CT_BUILD}-gcc"                  \
     3.9      CFLAGS="${CT_CFLAGS_FOR_HOST}"                  \
    3.10      CT_DoExecLog ALL                                \
    3.11      "${CT_SRC_DIR}/${CT_CC_FILE}/configure"         \
    3.12 -        ${CT_CANADIAN_OPT}                          \
    3.13 +        --build=${CT_BUILD}                         \
    3.14          --host=${CT_HOST}                           \
    3.15          --target=${CT_TARGET}                       \
    3.16          --prefix="${core_prefix_dir}"               \
    3.17 @@ -263,15 +263,16 @@
    3.18      # detection problem only matters for gcc-3.2.x and later, I think.
    3.19      # --disable-nls to work around crash bug on ppc405, but also because
    3.20      # embedded systems don't really need message catalogs...
    3.21 -    CC_FOR_BUILD="${CT_CC_NATIVE}"              \
    3.22 +    CC_FOR_BUILD="${CT_BUILD}-gcc"              \
    3.23      CFLAGS="${CT_CFLAGS_FOR_HOST}"              \
    3.24      CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"     \
    3.25      CXXFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"   \
    3.26      LDFLAGS_FOR_TARGET="${CT_TARGET_LDFLAGS}"   \
    3.27      CT_DoExecLog ALL                            \
    3.28      "${CT_SRC_DIR}/${CT_CC_FILE}/configure"     \
    3.29 -        ${CT_CANADIAN_OPT}                      \
    3.30 -        --target=${CT_TARGET} --host=${CT_HOST} \
    3.31 +        --build=${CT_BUILD}                     \
    3.32 +        --host=${CT_HOST}                       \
    3.33 +        --target=${CT_TARGET}                   \
    3.34          --prefix="${CT_PREFIX_DIR}"             \
    3.35          ${CC_SYSROOT_ARG}                       \
    3.36          ${extra_config}                         \
     4.1 --- a/scripts/build/debug/200-duma.sh	Thu Nov 13 17:55:16 2008 +0000
     4.2 +++ b/scripts/build/debug/200-duma.sh	Thu Nov 13 18:22:23 2008 +0000
     4.3 @@ -44,8 +44,7 @@
     4.4      libs="${libs# }"
     4.5      CT_DoLog EXTRA "Building libraries '${libs}'"
     4.6      CT_DoExecLog ALL                    \
     4.7 -    make HOSTCC="${CT_CC_NATIVE}"       \
     4.8 -         HOSTCXX="${CT_CC_NATIVE}"      \
     4.9 +    make HOSTCC="${CT_BUILD}-gcc"       \
    4.10           CC="${CT_TARGET}-gcc"          \
    4.11           CXX="${CT_TARGET}-gcc"         \
    4.12           RANLIB="${CT_TARGET}-ranlib"   \
     5.1 --- a/scripts/build/libc/eglibc.sh	Thu Nov 13 17:55:16 2008 +0000
     5.2 +++ b/scripts/build/libc/eglibc.sh	Thu Nov 13 18:22:23 2008 +0000
     5.3 @@ -149,7 +149,7 @@
     5.4      CT_DoLog DEBUG "Using ar for target: '${cross_ar}'"
     5.5      CT_DoLog DEBUG "Using ranlib for target: '${cross_ranlib}'"
     5.6  
     5.7 -    BUILD_CC=${CT_CC_NATIVE}                    \
     5.8 +    BUILD_CC="${CT_BUILD}-gcc"                  \
     5.9      CC=${cross_cc}                              \
    5.10      CXX=${cross_cxx}                            \
    5.11      AR=${cross_ar}                              \
    5.12 @@ -158,7 +158,7 @@
    5.13      "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"   \
    5.14          --prefix=/usr                           \
    5.15          --with-headers="${CT_HEADERS_DIR}"      \
    5.16 -        --build="${CT_UNIQ_BUILD}"              \
    5.17 +        --build="${CT_BUILD}"                   \
    5.18          --host="${CT_TARGET}"                   \
    5.19          --disable-profile                       \
    5.20          --without-gd                            \
    5.21 @@ -245,7 +245,7 @@
    5.22      CT_DoLog DEBUG "Extra config args passed: '${extra_config}'"
    5.23      CT_DoLog DEBUG "Extra CC args passed    : '${extra_cc_args}'"
    5.24  
    5.25 -    BUILD_CC=${CT_CC_NATIVE}                                        \
    5.26 +    BUILD_CC="${CT_BUILD}-gcc"                                      \
    5.27      CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O"   \
    5.28      CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
    5.29      AR=${CT_TARGET}-ar                                              \
    5.30 @@ -254,7 +254,7 @@
    5.31      "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"                       \
    5.32          --prefix=/usr                                               \
    5.33          --with-headers="${CT_HEADERS_DIR}"                          \
    5.34 -        --build=${CT_UNIQ_BUILD}                                    \
    5.35 +        --build=${CT_BUILD}                                         \
    5.36          --host=${CT_TARGET}                                         \
    5.37          --disable-profile                                           \
    5.38          --without-gd                                                \
     6.1 --- a/scripts/build/libc/glibc.sh	Thu Nov 13 17:55:16 2008 +0000
     6.2 +++ b/scripts/build/libc/glibc.sh	Thu Nov 13 18:22:23 2008 +0000
     6.3 @@ -105,7 +105,7 @@
     6.4      CC=${cross_cc}                              \
     6.5      CT_DoExecLog ALL                            \
     6.6      "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"   \
     6.7 -        --build="${CT_UNIQ_BUILD}"              \
     6.8 +        --build="${CT_BUILD}"                   \
     6.9          --host="${CT_TARGET}"                   \
    6.10          --prefix=/usr                           \
    6.11          --with-headers="${CT_HEADERS_DIR}"      \
    6.12 @@ -272,7 +272,7 @@
    6.13  
    6.14      # Please see the comment for the configure step in do_libc().
    6.15  
    6.16 -    BUILD_CC=${CT_CC_NATIVE}                                        \
    6.17 +    BUILD_CC="${CT_BUILD}-gcc"                                      \
    6.18      CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O "  \
    6.19      CC="${cross_cc} ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}"      \
    6.20      AR=${CT_TARGET}-ar                                              \
    6.21 @@ -280,7 +280,7 @@
    6.22      CT_DoExecLog ALL                                                \
    6.23      "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"                       \
    6.24          --prefix=/usr                                               \
    6.25 -        --build="${CT_UNIQ_BUILD}"                                  \
    6.26 +        --build="${CT_BUILD}"                                       \
    6.27          --host=${CT_TARGET}                                         \
    6.28          --without-cvs                                               \
    6.29          --disable-profile                                           \
    6.30 @@ -400,7 +400,7 @@
    6.31      # I don't want nptl! --disable-sanity-checks will shut up those
    6.32      # silly messages. GNU folks again, he?
    6.33  
    6.34 -    BUILD_CC=${CT_CC_NATIVE}                                        \
    6.35 +    BUILD_CC="${CT_BUILD}-gcc"                                      \
    6.36      CFLAGS="${CT_TARGET_CFLAGS} ${CT_LIBC_GLIBC_EXTRA_CFLAGS} -O"   \
    6.37      CC="${CT_TARGET}-gcc ${CT_LIBC_EXTRA_CC_ARGS} ${extra_cc_args}" \
    6.38      AR=${CT_TARGET}-ar                                              \
    6.39 @@ -408,7 +408,7 @@
    6.40      CT_DoExecLog ALL                                                \
    6.41      "${CT_SRC_DIR}/${CT_LIBC_FILE}/configure"                       \
    6.42          --prefix=/usr                                               \
    6.43 -        --build=${CT_UNIQ_BUILD}                                    \
    6.44 +        --build=${CT_BUILD}                                         \
    6.45          --host=${CT_TARGET}                                         \
    6.46          --without-cvs                                               \
    6.47          --disable-profile                                           \
     7.1 --- a/scripts/build/tools/200-sstrip.sh	Thu Nov 13 17:55:16 2008 +0000
     7.2 +++ b/scripts/build/tools/200-sstrip.sh	Thu Nov 13 18:22:23 2008 +0000
     7.3 @@ -19,7 +19,7 @@
     7.4              ( cd "${CT_SRC_DIR}/ELFkickers-${CT_SSTRIP_ELFKICKERS_VERSION}/sstrip"; tar cf - . ) |tar xf -
     7.5  
     7.6              CT_DoLog EXTRA "Building sstrip"
     7.7 -            CT_DoExecLog ALL make CC="${CT_CC_NATIVE}" sstrip
     7.8 +            CT_DoExecLog ALL make CC="${CT_HOST}-gcc" sstrip
     7.9              
    7.10              CT_DoLog EXTRA "Installing sstrip"
    7.11              CT_DoExecLog ALL install -m 755 sstrip "${CT_PREFIX_DIR}/bin/${CT_TARGET}-sstrip"
    7.12 @@ -48,7 +48,7 @@
    7.13              cd "${CT_BUILD_DIR}/build-sstrip"
    7.14  
    7.15              CT_DoLog EXTRA "Building sstrip"
    7.16 -            CT_DoExecLog ALL ${CT_CC_NATIVE} -Wall -o sstrip "${CT_SRC_DIR}/sstrip/sstrip.c"
    7.17 +            CT_DoExecLog ALL "${CT_HOST}-gcc" -Wall -o sstrip "${CT_SRC_DIR}/sstrip/sstrip.c"
    7.18  
    7.19              CT_DoLog EXTRA "Installing sstrip"
    7.20              CT_DoExecLog ALL install -m 755 sstrip "${CT_PREFIX_DIR}/bin/${CT_TARGET}-sstrip"
     8.1 --- a/scripts/crosstool.sh	Thu Nov 13 17:55:16 2008 +0000
     8.2 +++ b/scripts/crosstool.sh	Thu Nov 13 18:22:23 2008 +0000
     8.3 @@ -223,10 +223,11 @@
     8.4  
     8.5  # Setting up the rest of the environment only if not restarting
     8.6  if [ -z "${CT_RESTART}" ]; then
     8.7 -    # Determine build system if not set by the user
     8.8 -    CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
     8.9 -    CT_BUILD="${CT_BUILD:-$(CT_DoConfigGuess)}"
    8.10 -    CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}")
    8.11 +    # What's our shell?
    8.12 +    # Will be plain /bin/sh on most systems, except if we have /bin/ash and we
    8.13 +    # _explictly_ required using it
    8.14 +    CT_SHELL="/bin/sh"
    8.15 +    [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash"
    8.16  
    8.17      # Arrange paths depending on wether we use sys-root or not.
    8.18      if [ "${CT_USE_SYSROOT}" = "y" ]; then
    8.19 @@ -273,63 +274,121 @@
    8.20          ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib64"
    8.21      fi
    8.22  
    8.23 -    # Canadian-cross are really picky on the way they are built. Tweak the values.
    8.24 -    CT_UNIQ_BUILD=$(echo "${CT_BUILD}" |sed -r -e 's/-/-build_/')
    8.25 -    if [ "${CT_CANADIAN}" = "y" ]; then
    8.26 -        # Arrange so that gcc never, ever think that build system == host system
    8.27 -        CT_CANADIAN_OPT="--build=${CT_UNIQ_BUILD}"
    8.28 -        # We shall have a compiler for this target!
    8.29 -        # Do test here...
    8.30 -    else
    8.31 -        CT_HOST="${CT_BUILD}"
    8.32 -        CT_CANADIAN_OPT="--build=${CT_BUILD}"
    8.33 -        # Add the target toolchain in the path so that we can build the C library
    8.34 -        # Carefully add paths in the order we want them:
    8.35 -        #  - first try in ${CT_PREFIX_DIR}/bin
    8.36 -        #  - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
    8.37 -        #  - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
    8.38 -        #  - fall back to searching user's PATH
    8.39 -        export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}"
    8.40 -    fi
    8.41 -
    8.42 -    # Modify GCC_HOST to never be equal to $BUILD or $TARGET
    8.43 -    # This strange operation causes gcc to always generate a cross-compiler
    8.44 -    # even if the build machine is the same kind as the host.
    8.45 -    # This is why CC has to be set when doing a canadian cross; you can't find a
    8.46 -    # host compiler by appending -gcc to our whacky $GCC_HOST
    8.47 -    # Kludge: it is reported that the above causes canadian crosses with cygwin
    8.48 -    # hosts to fail, so avoid it just in that one case.  It would be cleaner to
    8.49 -    # just move this into the non-canadian case above, but I'm afraid that might
    8.50 -    # cause some configure script somewhere to decide that since build==host, they
    8.51 -    # could run host binaries.
    8.52 -    # (Copied almost as-is from original crosstool):
    8.53 -    case "${CT_KERNEL},${CT_CANADIAN}" in
    8.54 -        cygwin,y) ;;
    8.55 -        *,y)      CT_HOST=$(echo "${CT_HOST}" |sed -r -e 's/-/-host_/;');;
    8.56 +    # Determine build system if not set by the user
    8.57 +    CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
    8.58 +    case "${CT_BUILD}" in
    8.59 +        "") CT_BUILD=$(gcc -dumpmachine);;
    8.60 +        *)  CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}");;
    8.61      esac
    8.62  
    8.63 -    # What's our shell?
    8.64 -    # Will be plain /bin/sh on most systems, except if we have /bin/ash and we
    8.65 -    # _explictly_ required using it
    8.66 -    CT_SHELL="/bin/sh"
    8.67 -    [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash"
    8.68 +    # Prepare mangling patterns to later modifyu BUILD and HOST (see below)
    8.69 +    case "${CT_TOOLCHAIN_TYPE}" in
    8.70 +        cross)
    8.71 +            CT_HOST="${CT_BUILD}"
    8.72 +            build_mangle="build_"
    8.73 +            host_mangle="build_"
    8.74 +            ;;
    8.75 +        *)  CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!"
    8.76 +            ;;
    8.77 +    esac
    8.78  
    8.79 -    # Ah! Recent versions of binutils need some of the build and/or host system
    8.80 -    # (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
    8.81 -    # Do that:
    8.82 +    # Save the real tuples to generate shell-wrappers to the real tools
    8.83 +    CT_REAL_BUILD="${CT_BUILD}"
    8.84 +    CT_REAL_HOST="${CT_HOST}"
    8.85 +
    8.86 +    # Make BUILD and HOST full-fledge four-part tuples (gcc -dumpmachine
    8.87 +    # might be only three-part tuple, and I don't know wether config.guess
    8.88 +    # can return 3-part tuples...)
    8.89 +    case "${CT_BUILD}" in
    8.90 +        *-*-*-*-*)  CT_Abort "Unexpected 5-part (or more) build tuple: '${CT_BUILD}'";;
    8.91 +        *-*-*-*)    ;;
    8.92 +        *-*-*)      CT_BUILD="${CT_BUILD/-/-unknown-}";;
    8.93 +        *)          CT_Abort "Unepxected 1- or 2-part build tuple: '${CT_BUILD}'";;
    8.94 +    esac
    8.95 +    case "${CT_HOST}" in
    8.96 +        *-*-*-*-*)  CT_Abort "Unexpected 5-part (or more) host tuple: '${CT_HOST}'";;
    8.97 +        *-*-*-*)    ;;
    8.98 +        *-*-*)      CT_HOST="${CT_HOST/-/-unknown-}";;
    8.99 +        *)          CT_Abort "Unepxected 1- or 2-part host tuple: '${CT_HOST}'";;
   8.100 +    esac
   8.101 +
   8.102 +    # Modify BUILD and HOST so that gcc always generate a cross-compiler
   8.103 +    # even if any of the build, host or target machines are the same.
   8.104 +    # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to
   8.105 +    #       support canadain build, later...
   8.106 +    CT_BUILD="${CT_BUILD/-/-${build_mangle}}"
   8.107 +    CT_HOST="${CT_HOST/-/-${host_mangle}}"
   8.108 +
   8.109 +    # Now we have mangled our BUILD and HOST tuples, we must fake the new
   8.110 +    # cross-tools for those mangled tuples.
   8.111      BANG='!'
   8.112      CT_DoLog DEBUG "Making build system tools available"
   8.113      mkdir -p "${CT_PREFIX_DIR}/bin"
   8.114 -    for tool in ar as dlltool ${CT_CC_NATIVE:=gcc} gnatbind gnatmake ld nm ranlib strip windres objcopy objdump; do
   8.115 -        tmp=$(CT_Which ${tool})
   8.116 -        if [ -n "${tmp}" ]; then
   8.117 -            printf "#${BANG}${CT_SHELL}\nexec '${tmp}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
   8.118 -            printf "#${BANG}${CT_SHELL}\nexec '${tmp}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${CT_UNIQ_BUILD}-${tool}"
   8.119 -            printf "#${BANG}${CT_SHELL}\nexec '${tmp}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
   8.120 -            chmod 700 "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}" "${CT_PREFIX_DIR}/bin/${CT_UNIQ_BUILD}-${tool}" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
   8.121 -        fi |CT_DoLog DEBUG
   8.122 +    for m in BUILD HOST; do
   8.123 +        r="CT_REAL_${m}"
   8.124 +        v="CT_${m}"
   8.125 +        p="CT_${m}_PREFIX"
   8.126 +        s="CT_${m}_SUFFIX"
   8.127 +        if [ -n "${!p}" ]; then
   8.128 +            t="${!p}"
   8.129 +        else
   8.130 +            t="${!r}-"
   8.131 +        fi
   8.132 +
   8.133 +        for tool in ar as dlltool gcc g++ gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do
   8.134 +            # First try with prefix + suffix
   8.135 +            # Then try with prefix only
   8.136 +            # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
   8.137 +            # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
   8.138 +            # This is needed, because some tools have a prefix and
   8.139 +            # a suffix (eg. gcc), while others may have only one,
   8.140 +            # or even none (eg. binutils)
   8.141 +            where=$(CT_Which "${t}${tool}${!s}")
   8.142 +            [ -z "${where}" ] && where=$(CT_Which "${t}${tool}")
   8.143 +            if [    -z "${where}"                         \
   8.144 +                 -a \(    "${m}" = "BUILD"                \
   8.145 +                       -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
   8.146 +                where=$(CT_Which "${tool}${!s}")
   8.147 +            fi
   8.148 +            if [ -z "${where}"                            \
   8.149 +                 -a \(    "${m}" = "BUILD"                \
   8.150 +                       -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
   8.151 +                where=$(CT_Which "${tool}")
   8.152 +            fi
   8.153 +
   8.154 +            # Not all tools are available for all platforms, but some are really,
   8.155 +            # bally needed
   8.156 +            if [ -n "${where}" ]; then
   8.157 +                CT_DoLog DEBUG "  '${!v}-${tool}' -> '${where}'"
   8.158 +                printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${!v}-${tool}"
   8.159 +                chmod 700 "${CT_PREFIX_DIR}/bin/${!v}-${tool}"
   8.160 +            else
   8.161 +                # We'll at least need some of them...
   8.162 +                case "${tool}" in
   8.163 +                    ar|as|gcc|ld|nm|objcopy|objdump|ranlib)
   8.164 +                        CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!"
   8.165 +                        ;;
   8.166 +                    *)
   8.167 +                        # It does not deserve a WARN level.
   8.168 +                        CT_DoLog DEBUG "  Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required."
   8.169 +                        ;;
   8.170 +                esac
   8.171 +            fi
   8.172 +        done
   8.173      done
   8.174  
   8.175 +    # Carefully add paths in the order we want them:
   8.176 +    #  - first try in ${CT_PREFIX_DIR}/bin
   8.177 +    #  - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
   8.178 +    #  - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
   8.179 +    #  - fall back to searching user's PATH
   8.180 +    # Of course, neither cross-native nor canadian can run on BUILD,
   8.181 +    # so don't add those PATHs in this case...
   8.182 +    case "${CT_TOOLCHAIN_TYPE}" in
   8.183 +        cross)  export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";;
   8.184 +        *)  ;;
   8.185 +    esac
   8.186 +
   8.187      # Some makeinfo versions are a pain in [put your most sensible body part here].
   8.188      # Go ahead with those, by creating a wrapper that keeps partial files, and that
   8.189      # never fails:
   8.190 @@ -359,8 +418,8 @@
   8.191  
   8.192      CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
   8.193      CT_DoLog EXTRA "Building a toolchain for:"
   8.194 -    CT_DoLog EXTRA "  build  = ${CT_BUILD}"
   8.195 -    CT_DoLog EXTRA "  host   = ${CT_HOST}"
   8.196 +    CT_DoLog EXTRA "  build  = ${CT_REAL_BUILD}"
   8.197 +    CT_DoLog EXTRA "  host   = ${CT_REAL_HOST}"
   8.198      CT_DoLog EXTRA "  target = ${CT_TARGET}"
   8.199      set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
   8.200      CT_EndStep
   8.201 @@ -434,7 +493,6 @@
   8.202  
   8.203      CT_DoLog DEBUG "Removing access to the build system tools"
   8.204      find "${CT_PREFIX_DIR}/bin" -name "${CT_BUILD}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
   8.205 -    find "${CT_PREFIX_DIR}/bin" -name "${CT_UNIQ_BUILD}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
   8.206      find "${CT_PREFIX_DIR}/bin" -name "${CT_HOST}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
   8.207      rm -fv "${CT_PREFIX_DIR}/bin/makeinfo" |CT_DoLog DEBUG
   8.208