scripts/crosstool.sh
changeset 1143 eee9e8de51e3
parent 1142 6ed79762fd99
child 1144 e1bf6cd3a27c
     1.1 --- a/scripts/crosstool.sh	Sun Jan 18 17:41:58 2009 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,510 +0,0 @@
     1.4 -#!/bin/bash
     1.5 -# Copyright 2007 Yann E. MORIN
     1.6 -# Licensed under the GPL v2. See COPYING in the root of this package.
     1.7 -
     1.8 -# This is the main entry point to crosstool
     1.9 -# This will:
    1.10 -#   - download, extract and patch the toolchain components
    1.11 -#   - build and install each components in turn
    1.12 -#   - and eventually test the resulting toolchain
    1.13 -
    1.14 -# What this file does is prepare the environment, based upon the user-choosen
    1.15 -# options. It also checks the existing environment for un-friendly variables,
    1.16 -# and builds the tools.
    1.17 -
    1.18 -# Parse the common functions
    1.19 -# Note: some initialisation and sanitizing is done while parsing this file,
    1.20 -# most notably:
    1.21 -#  - set trap handler on errors,
    1.22 -#  - don't hash commands lookups,
    1.23 -#  - initialise logging.
    1.24 -. "${CT_LIB_DIR}/scripts/functions"
    1.25 -
    1.26 -# Parse the configuration file
    1.27 -# It has some info about the logging facility, so include it early
    1.28 -. .config
    1.29 -
    1.30 -# Overide the locale early, in case we ever translate crosstool-NG messages
    1.31 -[ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C
    1.32 -
    1.33 -# Start date. Can't be done until we know the locale
    1.34 -CT_STAR_DATE=$(CT_DoDate +%s%N)
    1.35 -CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S)
    1.36 -
    1.37 -# Yes! We can do full logging from now on!
    1.38 -CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
    1.39 -
    1.40 -# renice oursleves
    1.41 -CT_DoExecLog DEBUG renice ${CT_NICE} $$
    1.42 -
    1.43 -CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
    1.44 -CT_DoExecLog DEBUG egrep '^(# |)CT_' .config
    1.45 -CT_EndStep
    1.46 -
    1.47 -# Some sanity checks in the environment and needed tools
    1.48 -CT_DoLog INFO "Checking environment sanity"
    1.49 -
    1.50 -CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS"
    1.51 -unset MAKEFLAGS
    1.52 -export MAKEFLAGS
    1.53 -
    1.54 -# Other environment sanity checks
    1.55 -CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
    1.56 -CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
    1.57 -CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
    1.58 -CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
    1.59 -export GREP_OPTIONS=
    1.60 -
    1.61 -CT_DoLog INFO "Building environment variables"
    1.62 -
    1.63 -# Include sub-scripts instead of calling them: that way, we do not have to
    1.64 -# export any variable, nor re-parse the configuration and functions files.
    1.65 -. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
    1.66 -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
    1.67 -. "${CT_LIB_DIR}/scripts/build/gmp.sh"
    1.68 -. "${CT_LIB_DIR}/scripts/build/mpfr.sh"
    1.69 -. "${CT_LIB_DIR}/scripts/build/binutils.sh"
    1.70 -. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
    1.71 -. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
    1.72 -. "${CT_LIB_DIR}/scripts/build/tools.sh"
    1.73 -. "${CT_LIB_DIR}/scripts/build/debug.sh"
    1.74 -
    1.75 -# Target tuple: CT_TARGET needs a little love:
    1.76 -CT_DoBuildTargetTuple
    1.77 -
    1.78 -# Kludge: If any of the configured options needs CT_TARGET,
    1.79 -# then rescan the options file now:
    1.80 -. .config
    1.81 -
    1.82 -# Second kludge: merge user-supplied target CFLAGS with architecture-provided
    1.83 -# target CFLAGS. Do the same for LDFLAGS in case it happens in the future.
    1.84 -# Put user-supplied flags at the end, so that they take precedence.
    1.85 -CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
    1.86 -CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
    1.87 -CT_CC_CORE_EXTRA_CONFIG="${CT_ARCH_CC_CORE_EXTRA_CONFIG} ${CT_CC_CORE_EXTRA_CONFIG}"
    1.88 -CT_CC_EXTRA_CONFIG="${CT_ARCH_CC_EXTRA_CONFIG} ${CT_CC_EXTRA_CONFIG}"
    1.89 -
    1.90 -# Where will we work?
    1.91 -: "${CT_WORK_DIR:=${CT_TOP_DIR}/targets}"
    1.92 -CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
    1.93 -CT_SRC_DIR="${CT_WORK_DIR}/src"
    1.94 -CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build"
    1.95 -CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
    1.96 -# Note: we'll always install the core compiler in its own directory, so as to
    1.97 -# not mix the two builds: core and final.
    1.98 -CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
    1.99 -CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
   1.100 -CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
   1.101 -
   1.102 -# We must ensure that we can restart if asked for!
   1.103 -if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}"  ]; then
   1.104 -    CT_DoLog ERROR "You asked to restart a non-restartable build"
   1.105 -    CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
   1.106 -    CT_DoLog ERROR "in the config options for the previous build, or the state"
   1.107 -    CT_DoLog ERROR "directory for the previous build was deleted."
   1.108 -    CT_Abort "I will stop here to avoid any carnage"
   1.109 -fi
   1.110 -
   1.111 -# If the local tarball directory does not exist, say so, and don't try to save there!
   1.112 -if [ ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then
   1.113 -    CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist. Will not save downloaded tarballs to local storage."
   1.114 -    CT_SAVE_TARBALLS=
   1.115 -fi
   1.116 -
   1.117 -# Some more sanity checks now that we have all paths set up
   1.118 -case "${CT_LOCAL_TARBALLS_DIR},${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
   1.119 -    *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
   1.120 -esac
   1.121 -
   1.122 -# Check now if we can write to the destination directory:
   1.123 -if [ -d "${CT_INSTALL_DIR}" ]; then
   1.124 -    CT_TestAndAbort "Destination directory '${CT_INSTALL_DIR}' is not removable" ! -w $(dirname "${CT_INSTALL_DIR}")
   1.125 -fi
   1.126 -
   1.127 -# Good, now grab a bit of informations on the system we're being run on,
   1.128 -# just in case something goes awok, and it's not our fault:
   1.129 -CT_SYS_USER=$(id -un)
   1.130 -CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true)
   1.131 -# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
   1.132 -CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
   1.133 -CT_SYS_KERNEL=$(uname -s)
   1.134 -CT_SYS_REVISION=$(uname -r)
   1.135 -# MacOS X lacks '-o' :
   1.136 -CT_SYS_OS=$(uname -o || echo "Unknown (maybe MacOS-X)")
   1.137 -CT_SYS_MACHINE=$(uname -m)
   1.138 -CT_SYS_PROCESSOR=$(uname -p)
   1.139 -CT_SYS_GCC=$(gcc -dumpversion)
   1.140 -CT_SYS_TARGET=$(CT_DoConfigGuess)
   1.141 -CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
   1.142 -
   1.143 -CT_DoLog EXTRA "Preparing working directories"
   1.144 -
   1.145 -# Ah! The build directory shall be eradicated, even if we restart!
   1.146 -if [ -d "${CT_BUILD_DIR}" ]; then
   1.147 -    CT_DoForceRmdir "${CT_BUILD_DIR}"
   1.148 -fi
   1.149 -
   1.150 -# Don't eradicate directories if we need to restart
   1.151 -if [ -z "${CT_RESTART}" ]; then
   1.152 -    # Get rid of pre-existing installed toolchain and previous build directories.
   1.153 -    # We need to do that _before_ we can safely log, because the log file will
   1.154 -    # most probably be in the toolchain directory.
   1.155 -    if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
   1.156 -        CT_DoForceRmdir "${CT_TARBALLS_DIR}"
   1.157 -    fi
   1.158 -    if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
   1.159 -        CT_DoForceRmdir "${CT_SRC_DIR}"
   1.160 -    fi
   1.161 -    if [ -d "${CT_INSTALL_DIR}" ]; then
   1.162 -        CT_DoForceRmdir "${CT_INSTALL_DIR}"
   1.163 -    fi
   1.164 -    if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
   1.165 -        CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}"
   1.166 -    fi
   1.167 -    # In case we start anew, get rid of the previously saved state directory
   1.168 -    if [ -d "${CT_STATE_DIR}" ]; then
   1.169 -        CT_DoForceRmdir "${CT_STATE_DIR}"
   1.170 -    fi
   1.171 -fi
   1.172 -
   1.173 -# Create the directories we'll use, even if restarting: it does no harm to
   1.174 -# create already existent directories, and CT_BUILD_DIR needs to be created
   1.175 -# anyway
   1.176 -CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}"
   1.177 -CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
   1.178 -CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}"
   1.179 -CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}"
   1.180 -CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}"
   1.181 -CT_DoExecLog ALL mkdir -p "${CT_DEBUG_INSTALL_DIR}"
   1.182 -CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}"
   1.183 -CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}"
   1.184 -CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}"
   1.185 -
   1.186 -# Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
   1.187 -# the previous build was successful. To be able to move the logfile there,
   1.188 -# switch them back to read/write
   1.189 -CT_DoExecLog ALL chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
   1.190 -
   1.191 -# Redirect log to the actual log file now we can
   1.192 -# It's quite understandable that the log file will be installed in the install
   1.193 -# directory, so we must first ensure it exists and is writeable (above) before
   1.194 -# we can log there
   1.195 -exec >/dev/null
   1.196 -case "${CT_LOG_TO_FILE}" in
   1.197 -    y)  CT_LOG_FILE="${CT_PREFIX_DIR}/build.log"
   1.198 -        cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
   1.199 -        rm -f "${tmp_log_file}"
   1.200 -        exec >>"${CT_LOG_FILE}"
   1.201 -        ;;
   1.202 -    *)  rm -f "${tmp_log_file}"
   1.203 -        ;;
   1.204 -esac
   1.205 -
   1.206 -# Setting up the rest of the environment only if not restarting
   1.207 -if [ -z "${CT_RESTART}" ]; then
   1.208 -    # What's our shell?
   1.209 -    # Will be plain /bin/sh on most systems, except if we have /bin/ash and we
   1.210 -    # _explictly_ required using it
   1.211 -    CT_SHELL="/bin/sh"
   1.212 -    [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash"
   1.213 -
   1.214 -    # Arrange paths depending on wether we use sys-root or not.
   1.215 -    if [ "${CT_USE_SYSROOT}" = "y" ]; then
   1.216 -        CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
   1.217 -        CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
   1.218 -        BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   1.219 -        CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   1.220 -        CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   1.221 -        LIBC_SYSROOT_ARG=""
   1.222 -        # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
   1.223 -        # confused when $sysroot/usr/include is not present.
   1.224 -        # Note: --prefix=/usr is magic!
   1.225 -        # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
   1.226 -    else
   1.227 -        # plain old way. All libraries in prefix/target/lib
   1.228 -        CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
   1.229 -        CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
   1.230 -        # hack!  Always use --with-sysroot for binutils.
   1.231 -        # binutils 2.14 and later obey it, older binutils ignore it.
   1.232 -        # Lets you build a working 32->64 bit cross gcc
   1.233 -        BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   1.234 -        # Use --with-headers, else final gcc will define disable_glibc while
   1.235 -        # building libgcc, and you'll have no profiling
   1.236 -        CC_CORE_SYSROOT_ARG="--without-headers"
   1.237 -        CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
   1.238 -        LIBC_SYSROOT_ARG="prefix="
   1.239 -    fi
   1.240 -
   1.241 -    # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
   1.242 -    # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
   1.243 -    #  "ld: cannot open crti.o: No such file or directory"
   1.244 -    CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib"
   1.245 -    CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
   1.246 -
   1.247 -    # Prevent gcc from installing its libraries outside of the sys-root
   1.248 -    CT_DoExecLog ALL ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib"
   1.249 -
   1.250 -    # Now, in case we're 64 bits, just have lib64/ be a symlink to lib/
   1.251 -    # so as to have all libraries in the same directory (we can do that
   1.252 -    # because we are *not* multilib).
   1.253 -    if [ "${CT_ARCH_64}" = "y" ]; then
   1.254 -        CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/lib64"
   1.255 -        CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/usr/lib64"
   1.256 -        CT_DoExecLog ALL ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib64"
   1.257 -    fi
   1.258 -
   1.259 -    # Determine build system if not set by the user
   1.260 -    CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
   1.261 -    case "${CT_BUILD}" in
   1.262 -        "") CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine);;
   1.263 -    esac
   1.264 -
   1.265 -    # Prepare mangling patterns to later modify BUILD and HOST (see below)
   1.266 -    case "${CT_TOOLCHAIN_TYPE}" in
   1.267 -        cross)
   1.268 -            CT_HOST="${CT_BUILD}"
   1.269 -            build_mangle="build_"
   1.270 -            host_mangle="build_"
   1.271 -            ;;
   1.272 -        *)  CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!"
   1.273 -            ;;
   1.274 -    esac
   1.275 -
   1.276 -    # Save the real tuples to generate shell-wrappers to the real tools
   1.277 -    CT_REAL_BUILD="${CT_BUILD}"
   1.278 -    CT_REAL_HOST="${CT_HOST}"
   1.279 -
   1.280 -    # Canonicalise CT_BUILD and CT_HOST
   1.281 -    # Not only will it give us full-qualified tuples, but it will also ensure
   1.282 -    # that they are valid tuples (in case of typo with user-provided tuples)
   1.283 -    # That's way better than trying to rewrite config.sub ourselves...
   1.284 -    CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}")
   1.285 -    CT_HOST=$(CT_DoConfigSub "${CT_HOST}")
   1.286 -
   1.287 -    # Modify BUILD and HOST so that gcc always generate a cross-compiler
   1.288 -    # even if any of the build, host or target machines are the same.
   1.289 -    # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to
   1.290 -    #       support canadain build, later...
   1.291 -    CT_BUILD="${CT_BUILD/-/-${build_mangle}}"
   1.292 -    CT_HOST="${CT_HOST/-/-${host_mangle}}"
   1.293 -
   1.294 -    # Now we have mangled our BUILD and HOST tuples, we must fake the new
   1.295 -    # cross-tools for those mangled tuples.
   1.296 -    CT_DoLog DEBUG "Making build system tools available"
   1.297 -    CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
   1.298 -    for m in BUILD HOST; do
   1.299 -        r="CT_REAL_${m}"
   1.300 -        v="CT_${m}"
   1.301 -        p="CT_${m}_PREFIX"
   1.302 -        s="CT_${m}_SUFFIX"
   1.303 -        if [ -n "${!p}" ]; then
   1.304 -            t="${!p}"
   1.305 -        else
   1.306 -            t="${!r}-"
   1.307 -        fi
   1.308 -
   1.309 -        for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do
   1.310 -            # First try with prefix + suffix
   1.311 -            # Then try with prefix only
   1.312 -            # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
   1.313 -            # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
   1.314 -            # This is needed, because some tools have a prefix and
   1.315 -            # a suffix (eg. gcc), while others may have only one,
   1.316 -            # or even none (eg. binutils)
   1.317 -            where=$(CT_Which "${t}${tool}${!s}")
   1.318 -            [ -z "${where}" ] && where=$(CT_Which "${t}${tool}")
   1.319 -            if [    -z "${where}"                         \
   1.320 -                 -a \(    "${m}" = "BUILD"                \
   1.321 -                       -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
   1.322 -                where=$(CT_Which "${tool}${!s}")
   1.323 -            fi
   1.324 -            if [ -z "${where}"                            \
   1.325 -                 -a \(    "${m}" = "BUILD"                \
   1.326 -                       -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
   1.327 -                where=$(CT_Which "${tool}")
   1.328 -            fi
   1.329 -
   1.330 -            # Not all tools are available for all platforms, but some are really,
   1.331 -            # bally needed
   1.332 -            if [ -n "${where}" ]; then
   1.333 -                CT_DoLog DEBUG "  '${!v}-${tool}' -> '${where}'"
   1.334 -                printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${!v}-${tool}"
   1.335 -                CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/${!v}-${tool}"
   1.336 -            else
   1.337 -                # We'll at least need some of them...
   1.338 -                case "${tool}" in
   1.339 -                    ar|as|gcc|ld|nm|objcopy|objdump|ranlib)
   1.340 -                        CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!"
   1.341 -                        ;;
   1.342 -                    *)
   1.343 -                        # It does not deserve a WARN level.
   1.344 -                        CT_DoLog DEBUG "  Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required."
   1.345 -                        ;;
   1.346 -                esac
   1.347 -            fi
   1.348 -        done
   1.349 -    done
   1.350 -
   1.351 -    # Carefully add paths in the order we want them:
   1.352 -    #  - first try in ${CT_PREFIX_DIR}/bin
   1.353 -    #  - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
   1.354 -    #  - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
   1.355 -    #  - fall back to searching user's PATH
   1.356 -    # Of course, neither cross-native nor canadian can run on BUILD,
   1.357 -    # so don't add those PATHs in this case...
   1.358 -    case "${CT_TOOLCHAIN_TYPE}" in
   1.359 -        cross)  export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";;
   1.360 -        *)  ;;
   1.361 -    esac
   1.362 -
   1.363 -    # Some makeinfo versions are a pain in [put your most sensible body part here].
   1.364 -    # Go ahead with those, by creating a wrapper that keeps partial files, and that
   1.365 -    # never fails:
   1.366 -    CT_DoLog DEBUG "  'makeinfo' -> '$(CT_Which makeinfo)'"
   1.367 -    printf "#${BANG}/bin/sh\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_PREFIX_DIR}/bin/makeinfo"
   1.368 -    CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/makeinfo"
   1.369 -
   1.370 -    # Help gcc
   1.371 -    CT_CFLAGS_FOR_HOST=
   1.372 -    [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
   1.373 -
   1.374 -    # Override the configured jobs with what's been given on the command line
   1.375 -    [ -n "${CT_JOBS}" ] && CT_PARALLEL_JOBS="${CT_JOBS}"
   1.376 -
   1.377 -    # Set the shell to be used by ./configure scripts and by Makefiles (those
   1.378 -    # that support it!).
   1.379 -    export CONFIG_SHELL="${CT_SHELL}"
   1.380 -
   1.381 -    # And help make go faster
   1.382 -    PARALLELMFLAGS=
   1.383 -    [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
   1.384 -    [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
   1.385 -    export PARALLELMFLAGS
   1.386 -
   1.387 -    CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
   1.388 -    CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
   1.389 -    bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
   1.390 -
   1.391 -    CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
   1.392 -    CT_DoLog EXTRA "Building a toolchain for:"
   1.393 -    CT_DoLog EXTRA "  build  = ${CT_REAL_BUILD}"
   1.394 -    CT_DoLog EXTRA "  host   = ${CT_REAL_HOST}"
   1.395 -    CT_DoLog EXTRA "  target = ${CT_TARGET}"
   1.396 -    set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
   1.397 -    CT_EndStep
   1.398 -fi
   1.399 -
   1.400 -if [ -z "${CT_RESTART}" ]; then
   1.401 -    CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   1.402 -    do_kernel_get
   1.403 -    do_gmp_get
   1.404 -    do_mpfr_get
   1.405 -    do_binutils_get
   1.406 -    do_cc_get
   1.407 -    do_libc_get
   1.408 -    do_tools_get
   1.409 -    do_debug_get
   1.410 -    CT_EndStep
   1.411 -
   1.412 -    if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
   1.413 -        if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
   1.414 -            CT_DoForceRmdir "${CT_SRC_DIR}"
   1.415 -            CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
   1.416 -        fi
   1.417 -        CT_DoStep INFO "Extracting and patching toolchain components"
   1.418 -        do_kernel_extract
   1.419 -        do_gmp_extract
   1.420 -        do_mpfr_extract
   1.421 -        do_binutils_extract
   1.422 -        do_cc_extract
   1.423 -        do_libc_extract
   1.424 -        do_tools_extract
   1.425 -        do_debug_extract
   1.426 -        CT_EndStep
   1.427 -    fi
   1.428 -fi
   1.429 -
   1.430 -# Now for the job by itself. Go have a coffee!
   1.431 -if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
   1.432 -    # Because of CT_RESTART, this becomes quite complex
   1.433 -    do_stop=0
   1.434 -    prev_step=
   1.435 -    [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
   1.436 -    # Aha! CT_STEPS comes from steps.mk!
   1.437 -    for step in ${CT_STEPS}; do
   1.438 -        if [ ${do_it} -eq 0 ]; then
   1.439 -            if [ "${CT_RESTART}" = "${step}" ]; then
   1.440 -                CT_DoLoadState "${step}"
   1.441 -                do_it=1
   1.442 -                do_stop=0
   1.443 -            fi
   1.444 -        else
   1.445 -            CT_DoSaveState ${step}
   1.446 -            if [ ${do_stop} -eq 1 ]; then
   1.447 -                CT_DoLog ERROR "Stopping just after step '${prev_step}', as requested."
   1.448 -                exit 0
   1.449 -            fi
   1.450 -        fi
   1.451 -        if [ ${do_it} -eq 1 ]; then
   1.452 -            do_${step}
   1.453 -            if [ "${CT_STOP}" = "${step}" ]; then
   1.454 -                do_stop=1
   1.455 -            fi
   1.456 -            if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then
   1.457 -                CT_DoPause "Step '${step}' finished"
   1.458 -            fi
   1.459 -        fi
   1.460 -        prev_step="${step}"
   1.461 -    done
   1.462 -
   1.463 -    CT_DoLog INFO "================================================================="
   1.464 -
   1.465 -    CT_DoLog DEBUG "Removing access to the build system tools"
   1.466 -    find "${CT_PREFIX_DIR}/bin" -name "${CT_BUILD}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
   1.467 -    find "${CT_PREFIX_DIR}/bin" -name "${CT_HOST}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
   1.468 -    CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/makeinfo"
   1.469 -
   1.470 -    if [ "${CT_BARE_METAL}" != "y" ]; then
   1.471 -        CT_DoLog EXTRA "Installing the populate helper"
   1.472 -        sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
   1.473 -            "${CT_LIB_DIR}/scripts/populate.in"           \
   1.474 -            >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
   1.475 -        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
   1.476 -    fi
   1.477 -
   1.478 -    # Create the aliases to the target tools
   1.479 -    CT_DoLog EXTRA "Creating toolchain aliases"
   1.480 -    CT_Pushd "${CT_PREFIX_DIR}/bin"
   1.481 -    for t in "${CT_TARGET}-"*; do
   1.482 -        if [ -n "${CT_TARGET_ALIAS}" ]; then
   1.483 -            _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
   1.484 -            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
   1.485 -        fi
   1.486 -        if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
   1.487 -            _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
   1.488 -            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
   1.489 -        fi
   1.490 -    done
   1.491 -    CT_Popd
   1.492 -
   1.493 -    # Remove the generated documentation files
   1.494 -    if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   1.495 -    	CT_DoLog INFO "Removing installed documentation"
   1.496 -        CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
   1.497 -        CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
   1.498 -        CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
   1.499 -    fi
   1.500 -fi
   1.501 -
   1.502 -CT_DoEnd INFO
   1.503 -
   1.504 -# From now-on, it can become impossible to log any time, because
   1.505 -# either we're compressing the log file, or it can become RO any
   1.506 -# moment... Consign all ouptut to oblivion...
   1.507 -CT_DoLog INFO "Finishing installation (may take a few seconds)..."
   1.508 -exec >/dev/null 2>&1
   1.509 -
   1.510 -[ "${CT_LOG_FILE_COMPRESS}" = y ] && bzip2 -9 "${CT_LOG_FILE}"
   1.511 -[ "${CT_INSTALL_DIR_RO}" = "y"  ] && chmod -R a-w "${CT_INSTALL_DIR}"
   1.512 -
   1.513 -trap - EXIT