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