Rename scripts/crosstool.sh to scripts/crosstool-NG.sh.
After all, this is not crosstool, but really crosstool-NG!
/trunk/steps.mk | 2 1 1 0 +-
/trunk/ct-ng.in | 2 1 1 0 +-
2 files changed, 2 insertions(+), 2 deletions(-)
1.1 --- a/ct-ng.in Sun Jan 18 17:41:58 2009 +0000
1.2 +++ b/ct-ng.in Sun Jan 18 17:45:10 2009 +0000
1.3 @@ -118,7 +118,7 @@
1.4
1.5 # Actual build
1.6 build: .config
1.7 - $(SILENT)$(CT_LIB_DIR)/scripts/crosstool.sh
1.8 + $(SILENT)$(CT_LIB_DIR)/scripts/crosstool-NG.sh
1.9
1.10 build.%:
1.11 $(SILENT)$(MAKE) -rf $(CT_NG) $(shell echo "$(@)" |sed -r -e 's|^([^.]+)\.([[:digit:]]+)$$|\1 CT_JOBS=\2|;')
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/scripts/crosstool-NG.sh Sun Jan 18 17:45:10 2009 +0000
2.3 @@ -0,0 +1,510 @@
2.4 +#!/bin/bash
2.5 +# Copyright 2007 Yann E. MORIN
2.6 +# Licensed under the GPL v2. See COPYING in the root of this package.
2.7 +
2.8 +# This is the main entry point to crosstool
2.9 +# This will:
2.10 +# - download, extract and patch the toolchain components
2.11 +# - build and install each components in turn
2.12 +# - and eventually test the resulting toolchain
2.13 +
2.14 +# What this file does is prepare the environment, based upon the user-choosen
2.15 +# options. It also checks the existing environment for un-friendly variables,
2.16 +# and builds the tools.
2.17 +
2.18 +# Parse the common functions
2.19 +# Note: some initialisation and sanitizing is done while parsing this file,
2.20 +# most notably:
2.21 +# - set trap handler on errors,
2.22 +# - don't hash commands lookups,
2.23 +# - initialise logging.
2.24 +. "${CT_LIB_DIR}/scripts/functions"
2.25 +
2.26 +# Parse the configuration file
2.27 +# It has some info about the logging facility, so include it early
2.28 +. .config
2.29 +
2.30 +# Overide the locale early, in case we ever translate crosstool-NG messages
2.31 +[ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C
2.32 +
2.33 +# Start date. Can't be done until we know the locale
2.34 +CT_STAR_DATE=$(CT_DoDate +%s%N)
2.35 +CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S)
2.36 +
2.37 +# Yes! We can do full logging from now on!
2.38 +CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
2.39 +
2.40 +# renice oursleves
2.41 +CT_DoExecLog DEBUG renice ${CT_NICE} $$
2.42 +
2.43 +CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
2.44 +CT_DoExecLog DEBUG egrep '^(# |)CT_' .config
2.45 +CT_EndStep
2.46 +
2.47 +# Some sanity checks in the environment and needed tools
2.48 +CT_DoLog INFO "Checking environment sanity"
2.49 +
2.50 +CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS"
2.51 +unset MAKEFLAGS
2.52 +export MAKEFLAGS
2.53 +
2.54 +# Other environment sanity checks
2.55 +CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
2.56 +CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
2.57 +CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
2.58 +CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
2.59 +export GREP_OPTIONS=
2.60 +
2.61 +CT_DoLog INFO "Building environment variables"
2.62 +
2.63 +# Include sub-scripts instead of calling them: that way, we do not have to
2.64 +# export any variable, nor re-parse the configuration and functions files.
2.65 +. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
2.66 +. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
2.67 +. "${CT_LIB_DIR}/scripts/build/gmp.sh"
2.68 +. "${CT_LIB_DIR}/scripts/build/mpfr.sh"
2.69 +. "${CT_LIB_DIR}/scripts/build/binutils.sh"
2.70 +. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
2.71 +. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
2.72 +. "${CT_LIB_DIR}/scripts/build/tools.sh"
2.73 +. "${CT_LIB_DIR}/scripts/build/debug.sh"
2.74 +
2.75 +# Target tuple: CT_TARGET needs a little love:
2.76 +CT_DoBuildTargetTuple
2.77 +
2.78 +# Kludge: If any of the configured options needs CT_TARGET,
2.79 +# then rescan the options file now:
2.80 +. .config
2.81 +
2.82 +# Second kludge: merge user-supplied target CFLAGS with architecture-provided
2.83 +# target CFLAGS. Do the same for LDFLAGS in case it happens in the future.
2.84 +# Put user-supplied flags at the end, so that they take precedence.
2.85 +CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
2.86 +CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
2.87 +CT_CC_CORE_EXTRA_CONFIG="${CT_ARCH_CC_CORE_EXTRA_CONFIG} ${CT_CC_CORE_EXTRA_CONFIG}"
2.88 +CT_CC_EXTRA_CONFIG="${CT_ARCH_CC_EXTRA_CONFIG} ${CT_CC_EXTRA_CONFIG}"
2.89 +
2.90 +# Where will we work?
2.91 +: "${CT_WORK_DIR:=${CT_TOP_DIR}/targets}"
2.92 +CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
2.93 +CT_SRC_DIR="${CT_WORK_DIR}/src"
2.94 +CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build"
2.95 +CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
2.96 +# Note: we'll always install the core compiler in its own directory, so as to
2.97 +# not mix the two builds: core and final.
2.98 +CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
2.99 +CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
2.100 +CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
2.101 +
2.102 +# We must ensure that we can restart if asked for!
2.103 +if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}" ]; then
2.104 + CT_DoLog ERROR "You asked to restart a non-restartable build"
2.105 + CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
2.106 + CT_DoLog ERROR "in the config options for the previous build, or the state"
2.107 + CT_DoLog ERROR "directory for the previous build was deleted."
2.108 + CT_Abort "I will stop here to avoid any carnage"
2.109 +fi
2.110 +
2.111 +# If the local tarball directory does not exist, say so, and don't try to save there!
2.112 +if [ ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then
2.113 + CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist. Will not save downloaded tarballs to local storage."
2.114 + CT_SAVE_TARBALLS=
2.115 +fi
2.116 +
2.117 +# Some more sanity checks now that we have all paths set up
2.118 +case "${CT_LOCAL_TARBALLS_DIR},${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
2.119 + *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
2.120 +esac
2.121 +
2.122 +# Check now if we can write to the destination directory:
2.123 +if [ -d "${CT_INSTALL_DIR}" ]; then
2.124 + CT_TestAndAbort "Destination directory '${CT_INSTALL_DIR}' is not removable" ! -w $(dirname "${CT_INSTALL_DIR}")
2.125 +fi
2.126 +
2.127 +# Good, now grab a bit of informations on the system we're being run on,
2.128 +# just in case something goes awok, and it's not our fault:
2.129 +CT_SYS_USER=$(id -un)
2.130 +CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true)
2.131 +# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
2.132 +CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
2.133 +CT_SYS_KERNEL=$(uname -s)
2.134 +CT_SYS_REVISION=$(uname -r)
2.135 +# MacOS X lacks '-o' :
2.136 +CT_SYS_OS=$(uname -o || echo "Unknown (maybe MacOS-X)")
2.137 +CT_SYS_MACHINE=$(uname -m)
2.138 +CT_SYS_PROCESSOR=$(uname -p)
2.139 +CT_SYS_GCC=$(gcc -dumpversion)
2.140 +CT_SYS_TARGET=$(CT_DoConfigGuess)
2.141 +CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
2.142 +
2.143 +CT_DoLog EXTRA "Preparing working directories"
2.144 +
2.145 +# Ah! The build directory shall be eradicated, even if we restart!
2.146 +if [ -d "${CT_BUILD_DIR}" ]; then
2.147 + CT_DoForceRmdir "${CT_BUILD_DIR}"
2.148 +fi
2.149 +
2.150 +# Don't eradicate directories if we need to restart
2.151 +if [ -z "${CT_RESTART}" ]; then
2.152 + # Get rid of pre-existing installed toolchain and previous build directories.
2.153 + # We need to do that _before_ we can safely log, because the log file will
2.154 + # most probably be in the toolchain directory.
2.155 + if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
2.156 + CT_DoForceRmdir "${CT_TARBALLS_DIR}"
2.157 + fi
2.158 + if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
2.159 + CT_DoForceRmdir "${CT_SRC_DIR}"
2.160 + fi
2.161 + if [ -d "${CT_INSTALL_DIR}" ]; then
2.162 + CT_DoForceRmdir "${CT_INSTALL_DIR}"
2.163 + fi
2.164 + if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
2.165 + CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}"
2.166 + fi
2.167 + # In case we start anew, get rid of the previously saved state directory
2.168 + if [ -d "${CT_STATE_DIR}" ]; then
2.169 + CT_DoForceRmdir "${CT_STATE_DIR}"
2.170 + fi
2.171 +fi
2.172 +
2.173 +# Create the directories we'll use, even if restarting: it does no harm to
2.174 +# create already existent directories, and CT_BUILD_DIR needs to be created
2.175 +# anyway
2.176 +CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}"
2.177 +CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
2.178 +CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}"
2.179 +CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}"
2.180 +CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}"
2.181 +CT_DoExecLog ALL mkdir -p "${CT_DEBUG_INSTALL_DIR}"
2.182 +CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}"
2.183 +CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}"
2.184 +CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}"
2.185 +
2.186 +# Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
2.187 +# the previous build was successful. To be able to move the logfile there,
2.188 +# switch them back to read/write
2.189 +CT_DoExecLog ALL chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
2.190 +
2.191 +# Redirect log to the actual log file now we can
2.192 +# It's quite understandable that the log file will be installed in the install
2.193 +# directory, so we must first ensure it exists and is writeable (above) before
2.194 +# we can log there
2.195 +exec >/dev/null
2.196 +case "${CT_LOG_TO_FILE}" in
2.197 + y) CT_LOG_FILE="${CT_PREFIX_DIR}/build.log"
2.198 + cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
2.199 + rm -f "${tmp_log_file}"
2.200 + exec >>"${CT_LOG_FILE}"
2.201 + ;;
2.202 + *) rm -f "${tmp_log_file}"
2.203 + ;;
2.204 +esac
2.205 +
2.206 +# Setting up the rest of the environment only if not restarting
2.207 +if [ -z "${CT_RESTART}" ]; then
2.208 + # What's our shell?
2.209 + # Will be plain /bin/sh on most systems, except if we have /bin/ash and we
2.210 + # _explictly_ required using it
2.211 + CT_SHELL="/bin/sh"
2.212 + [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash"
2.213 +
2.214 + # Arrange paths depending on wether we use sys-root or not.
2.215 + if [ "${CT_USE_SYSROOT}" = "y" ]; then
2.216 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
2.217 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
2.218 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
2.219 + CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
2.220 + CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
2.221 + LIBC_SYSROOT_ARG=""
2.222 + # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
2.223 + # confused when $sysroot/usr/include is not present.
2.224 + # Note: --prefix=/usr is magic!
2.225 + # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
2.226 + else
2.227 + # plain old way. All libraries in prefix/target/lib
2.228 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
2.229 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
2.230 + # hack! Always use --with-sysroot for binutils.
2.231 + # binutils 2.14 and later obey it, older binutils ignore it.
2.232 + # Lets you build a working 32->64 bit cross gcc
2.233 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
2.234 + # Use --with-headers, else final gcc will define disable_glibc while
2.235 + # building libgcc, and you'll have no profiling
2.236 + CC_CORE_SYSROOT_ARG="--without-headers"
2.237 + CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
2.238 + LIBC_SYSROOT_ARG="prefix="
2.239 + fi
2.240 +
2.241 + # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
2.242 + # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
2.243 + # "ld: cannot open crti.o: No such file or directory"
2.244 + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib"
2.245 + CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
2.246 +
2.247 + # Prevent gcc from installing its libraries outside of the sys-root
2.248 + CT_DoExecLog ALL ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib"
2.249 +
2.250 + # Now, in case we're 64 bits, just have lib64/ be a symlink to lib/
2.251 + # so as to have all libraries in the same directory (we can do that
2.252 + # because we are *not* multilib).
2.253 + if [ "${CT_ARCH_64}" = "y" ]; then
2.254 + CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/lib64"
2.255 + CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/usr/lib64"
2.256 + CT_DoExecLog ALL ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib64"
2.257 + fi
2.258 +
2.259 + # Determine build system if not set by the user
2.260 + CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
2.261 + case "${CT_BUILD}" in
2.262 + "") CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine);;
2.263 + esac
2.264 +
2.265 + # Prepare mangling patterns to later modify BUILD and HOST (see below)
2.266 + case "${CT_TOOLCHAIN_TYPE}" in
2.267 + cross)
2.268 + CT_HOST="${CT_BUILD}"
2.269 + build_mangle="build_"
2.270 + host_mangle="build_"
2.271 + ;;
2.272 + *) CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!"
2.273 + ;;
2.274 + esac
2.275 +
2.276 + # Save the real tuples to generate shell-wrappers to the real tools
2.277 + CT_REAL_BUILD="${CT_BUILD}"
2.278 + CT_REAL_HOST="${CT_HOST}"
2.279 +
2.280 + # Canonicalise CT_BUILD and CT_HOST
2.281 + # Not only will it give us full-qualified tuples, but it will also ensure
2.282 + # that they are valid tuples (in case of typo with user-provided tuples)
2.283 + # That's way better than trying to rewrite config.sub ourselves...
2.284 + CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}")
2.285 + CT_HOST=$(CT_DoConfigSub "${CT_HOST}")
2.286 +
2.287 + # Modify BUILD and HOST so that gcc always generate a cross-compiler
2.288 + # even if any of the build, host or target machines are the same.
2.289 + # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to
2.290 + # support canadain build, later...
2.291 + CT_BUILD="${CT_BUILD/-/-${build_mangle}}"
2.292 + CT_HOST="${CT_HOST/-/-${host_mangle}}"
2.293 +
2.294 + # Now we have mangled our BUILD and HOST tuples, we must fake the new
2.295 + # cross-tools for those mangled tuples.
2.296 + CT_DoLog DEBUG "Making build system tools available"
2.297 + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
2.298 + for m in BUILD HOST; do
2.299 + r="CT_REAL_${m}"
2.300 + v="CT_${m}"
2.301 + p="CT_${m}_PREFIX"
2.302 + s="CT_${m}_SUFFIX"
2.303 + if [ -n "${!p}" ]; then
2.304 + t="${!p}"
2.305 + else
2.306 + t="${!r}-"
2.307 + fi
2.308 +
2.309 + for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do
2.310 + # First try with prefix + suffix
2.311 + # Then try with prefix only
2.312 + # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
2.313 + # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
2.314 + # This is needed, because some tools have a prefix and
2.315 + # a suffix (eg. gcc), while others may have only one,
2.316 + # or even none (eg. binutils)
2.317 + where=$(CT_Which "${t}${tool}${!s}")
2.318 + [ -z "${where}" ] && where=$(CT_Which "${t}${tool}")
2.319 + if [ -z "${where}" \
2.320 + -a \( "${m}" = "BUILD" \
2.321 + -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
2.322 + where=$(CT_Which "${tool}${!s}")
2.323 + fi
2.324 + if [ -z "${where}" \
2.325 + -a \( "${m}" = "BUILD" \
2.326 + -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
2.327 + where=$(CT_Which "${tool}")
2.328 + fi
2.329 +
2.330 + # Not all tools are available for all platforms, but some are really,
2.331 + # bally needed
2.332 + if [ -n "${where}" ]; then
2.333 + CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'"
2.334 + printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${!v}-${tool}"
2.335 + CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/${!v}-${tool}"
2.336 + else
2.337 + # We'll at least need some of them...
2.338 + case "${tool}" in
2.339 + ar|as|gcc|ld|nm|objcopy|objdump|ranlib)
2.340 + CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!"
2.341 + ;;
2.342 + *)
2.343 + # It does not deserve a WARN level.
2.344 + CT_DoLog DEBUG " Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required."
2.345 + ;;
2.346 + esac
2.347 + fi
2.348 + done
2.349 + done
2.350 +
2.351 + # Carefully add paths in the order we want them:
2.352 + # - first try in ${CT_PREFIX_DIR}/bin
2.353 + # - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
2.354 + # - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
2.355 + # - fall back to searching user's PATH
2.356 + # Of course, neither cross-native nor canadian can run on BUILD,
2.357 + # so don't add those PATHs in this case...
2.358 + case "${CT_TOOLCHAIN_TYPE}" in
2.359 + cross) export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";;
2.360 + *) ;;
2.361 + esac
2.362 +
2.363 + # Some makeinfo versions are a pain in [put your most sensible body part here].
2.364 + # Go ahead with those, by creating a wrapper that keeps partial files, and that
2.365 + # never fails:
2.366 + CT_DoLog DEBUG " 'makeinfo' -> '$(CT_Which makeinfo)'"
2.367 + printf "#${BANG}/bin/sh\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_PREFIX_DIR}/bin/makeinfo"
2.368 + CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/makeinfo"
2.369 +
2.370 + # Help gcc
2.371 + CT_CFLAGS_FOR_HOST=
2.372 + [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
2.373 +
2.374 + # Override the configured jobs with what's been given on the command line
2.375 + [ -n "${CT_JOBS}" ] && CT_PARALLEL_JOBS="${CT_JOBS}"
2.376 +
2.377 + # Set the shell to be used by ./configure scripts and by Makefiles (those
2.378 + # that support it!).
2.379 + export CONFIG_SHELL="${CT_SHELL}"
2.380 +
2.381 + # And help make go faster
2.382 + PARALLELMFLAGS=
2.383 + [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
2.384 + [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
2.385 + export PARALLELMFLAGS
2.386 +
2.387 + CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
2.388 + CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
2.389 + bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
2.390 +
2.391 + CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
2.392 + CT_DoLog EXTRA "Building a toolchain for:"
2.393 + CT_DoLog EXTRA " build = ${CT_REAL_BUILD}"
2.394 + CT_DoLog EXTRA " host = ${CT_REAL_HOST}"
2.395 + CT_DoLog EXTRA " target = ${CT_TARGET}"
2.396 + set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
2.397 + CT_EndStep
2.398 +fi
2.399 +
2.400 +if [ -z "${CT_RESTART}" ]; then
2.401 + CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
2.402 + do_kernel_get
2.403 + do_gmp_get
2.404 + do_mpfr_get
2.405 + do_binutils_get
2.406 + do_cc_get
2.407 + do_libc_get
2.408 + do_tools_get
2.409 + do_debug_get
2.410 + CT_EndStep
2.411 +
2.412 + if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
2.413 + if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
2.414 + CT_DoForceRmdir "${CT_SRC_DIR}"
2.415 + CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
2.416 + fi
2.417 + CT_DoStep INFO "Extracting and patching toolchain components"
2.418 + do_kernel_extract
2.419 + do_gmp_extract
2.420 + do_mpfr_extract
2.421 + do_binutils_extract
2.422 + do_cc_extract
2.423 + do_libc_extract
2.424 + do_tools_extract
2.425 + do_debug_extract
2.426 + CT_EndStep
2.427 + fi
2.428 +fi
2.429 +
2.430 +# Now for the job by itself. Go have a coffee!
2.431 +if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
2.432 + # Because of CT_RESTART, this becomes quite complex
2.433 + do_stop=0
2.434 + prev_step=
2.435 + [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
2.436 + # Aha! CT_STEPS comes from steps.mk!
2.437 + for step in ${CT_STEPS}; do
2.438 + if [ ${do_it} -eq 0 ]; then
2.439 + if [ "${CT_RESTART}" = "${step}" ]; then
2.440 + CT_DoLoadState "${step}"
2.441 + do_it=1
2.442 + do_stop=0
2.443 + fi
2.444 + else
2.445 + CT_DoSaveState ${step}
2.446 + if [ ${do_stop} -eq 1 ]; then
2.447 + CT_DoLog ERROR "Stopping just after step '${prev_step}', as requested."
2.448 + exit 0
2.449 + fi
2.450 + fi
2.451 + if [ ${do_it} -eq 1 ]; then
2.452 + do_${step}
2.453 + if [ "${CT_STOP}" = "${step}" ]; then
2.454 + do_stop=1
2.455 + fi
2.456 + if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then
2.457 + CT_DoPause "Step '${step}' finished"
2.458 + fi
2.459 + fi
2.460 + prev_step="${step}"
2.461 + done
2.462 +
2.463 + CT_DoLog INFO "================================================================="
2.464 +
2.465 + CT_DoLog DEBUG "Removing access to the build system tools"
2.466 + find "${CT_PREFIX_DIR}/bin" -name "${CT_BUILD}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
2.467 + find "${CT_PREFIX_DIR}/bin" -name "${CT_HOST}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
2.468 + CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/makeinfo"
2.469 +
2.470 + if [ "${CT_BARE_METAL}" != "y" ]; then
2.471 + CT_DoLog EXTRA "Installing the populate helper"
2.472 + sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
2.473 + "${CT_LIB_DIR}/scripts/populate.in" \
2.474 + >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
2.475 + CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
2.476 + fi
2.477 +
2.478 + # Create the aliases to the target tools
2.479 + CT_DoLog EXTRA "Creating toolchain aliases"
2.480 + CT_Pushd "${CT_PREFIX_DIR}/bin"
2.481 + for t in "${CT_TARGET}-"*; do
2.482 + if [ -n "${CT_TARGET_ALIAS}" ]; then
2.483 + _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
2.484 + CT_DoExecLog ALL ln -sv "${t}" "${_t}"
2.485 + fi
2.486 + if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
2.487 + _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
2.488 + CT_DoExecLog ALL ln -sv "${t}" "${_t}"
2.489 + fi
2.490 + done
2.491 + CT_Popd
2.492 +
2.493 + # Remove the generated documentation files
2.494 + if [ "${CT_REMOVE_DOCS}" = "y" ]; then
2.495 + CT_DoLog INFO "Removing installed documentation"
2.496 + CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
2.497 + CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
2.498 + CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
2.499 + fi
2.500 +fi
2.501 +
2.502 +CT_DoEnd INFO
2.503 +
2.504 +# From now-on, it can become impossible to log any time, because
2.505 +# either we're compressing the log file, or it can become RO any
2.506 +# moment... Consign all ouptut to oblivion...
2.507 +CT_DoLog INFO "Finishing installation (may take a few seconds)..."
2.508 +exec >/dev/null 2>&1
2.509 +
2.510 +[ "${CT_LOG_FILE_COMPRESS}" = y ] && bzip2 -9 "${CT_LOG_FILE}"
2.511 +[ "${CT_INSTALL_DIR_RO}" = "y" ] && chmod -R a-w "${CT_INSTALL_DIR}"
2.512 +
2.513 +trap - EXIT
3.1 --- a/scripts/crosstool.sh Sun Jan 18 17:41:58 2009 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,510 +0,0 @@
3.4 -#!/bin/bash
3.5 -# Copyright 2007 Yann E. MORIN
3.6 -# Licensed under the GPL v2. See COPYING in the root of this package.
3.7 -
3.8 -# This is the main entry point to crosstool
3.9 -# This will:
3.10 -# - download, extract and patch the toolchain components
3.11 -# - build and install each components in turn
3.12 -# - and eventually test the resulting toolchain
3.13 -
3.14 -# What this file does is prepare the environment, based upon the user-choosen
3.15 -# options. It also checks the existing environment for un-friendly variables,
3.16 -# and builds the tools.
3.17 -
3.18 -# Parse the common functions
3.19 -# Note: some initialisation and sanitizing is done while parsing this file,
3.20 -# most notably:
3.21 -# - set trap handler on errors,
3.22 -# - don't hash commands lookups,
3.23 -# - initialise logging.
3.24 -. "${CT_LIB_DIR}/scripts/functions"
3.25 -
3.26 -# Parse the configuration file
3.27 -# It has some info about the logging facility, so include it early
3.28 -. .config
3.29 -
3.30 -# Overide the locale early, in case we ever translate crosstool-NG messages
3.31 -[ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C
3.32 -
3.33 -# Start date. Can't be done until we know the locale
3.34 -CT_STAR_DATE=$(CT_DoDate +%s%N)
3.35 -CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S)
3.36 -
3.37 -# Yes! We can do full logging from now on!
3.38 -CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
3.39 -
3.40 -# renice oursleves
3.41 -CT_DoExecLog DEBUG renice ${CT_NICE} $$
3.42 -
3.43 -CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
3.44 -CT_DoExecLog DEBUG egrep '^(# |)CT_' .config
3.45 -CT_EndStep
3.46 -
3.47 -# Some sanity checks in the environment and needed tools
3.48 -CT_DoLog INFO "Checking environment sanity"
3.49 -
3.50 -CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS"
3.51 -unset MAKEFLAGS
3.52 -export MAKEFLAGS
3.53 -
3.54 -# Other environment sanity checks
3.55 -CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
3.56 -CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
3.57 -CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
3.58 -CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
3.59 -export GREP_OPTIONS=
3.60 -
3.61 -CT_DoLog INFO "Building environment variables"
3.62 -
3.63 -# Include sub-scripts instead of calling them: that way, we do not have to
3.64 -# export any variable, nor re-parse the configuration and functions files.
3.65 -. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
3.66 -. "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
3.67 -. "${CT_LIB_DIR}/scripts/build/gmp.sh"
3.68 -. "${CT_LIB_DIR}/scripts/build/mpfr.sh"
3.69 -. "${CT_LIB_DIR}/scripts/build/binutils.sh"
3.70 -. "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
3.71 -. "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
3.72 -. "${CT_LIB_DIR}/scripts/build/tools.sh"
3.73 -. "${CT_LIB_DIR}/scripts/build/debug.sh"
3.74 -
3.75 -# Target tuple: CT_TARGET needs a little love:
3.76 -CT_DoBuildTargetTuple
3.77 -
3.78 -# Kludge: If any of the configured options needs CT_TARGET,
3.79 -# then rescan the options file now:
3.80 -. .config
3.81 -
3.82 -# Second kludge: merge user-supplied target CFLAGS with architecture-provided
3.83 -# target CFLAGS. Do the same for LDFLAGS in case it happens in the future.
3.84 -# Put user-supplied flags at the end, so that they take precedence.
3.85 -CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
3.86 -CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
3.87 -CT_CC_CORE_EXTRA_CONFIG="${CT_ARCH_CC_CORE_EXTRA_CONFIG} ${CT_CC_CORE_EXTRA_CONFIG}"
3.88 -CT_CC_EXTRA_CONFIG="${CT_ARCH_CC_EXTRA_CONFIG} ${CT_CC_EXTRA_CONFIG}"
3.89 -
3.90 -# Where will we work?
3.91 -: "${CT_WORK_DIR:=${CT_TOP_DIR}/targets}"
3.92 -CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
3.93 -CT_SRC_DIR="${CT_WORK_DIR}/src"
3.94 -CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build"
3.95 -CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
3.96 -# Note: we'll always install the core compiler in its own directory, so as to
3.97 -# not mix the two builds: core and final.
3.98 -CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
3.99 -CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
3.100 -CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
3.101 -
3.102 -# We must ensure that we can restart if asked for!
3.103 -if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}" ]; then
3.104 - CT_DoLog ERROR "You asked to restart a non-restartable build"
3.105 - CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
3.106 - CT_DoLog ERROR "in the config options for the previous build, or the state"
3.107 - CT_DoLog ERROR "directory for the previous build was deleted."
3.108 - CT_Abort "I will stop here to avoid any carnage"
3.109 -fi
3.110 -
3.111 -# If the local tarball directory does not exist, say so, and don't try to save there!
3.112 -if [ ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then
3.113 - CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist. Will not save downloaded tarballs to local storage."
3.114 - CT_SAVE_TARBALLS=
3.115 -fi
3.116 -
3.117 -# Some more sanity checks now that we have all paths set up
3.118 -case "${CT_LOCAL_TARBALLS_DIR},${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
3.119 - *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
3.120 -esac
3.121 -
3.122 -# Check now if we can write to the destination directory:
3.123 -if [ -d "${CT_INSTALL_DIR}" ]; then
3.124 - CT_TestAndAbort "Destination directory '${CT_INSTALL_DIR}' is not removable" ! -w $(dirname "${CT_INSTALL_DIR}")
3.125 -fi
3.126 -
3.127 -# Good, now grab a bit of informations on the system we're being run on,
3.128 -# just in case something goes awok, and it's not our fault:
3.129 -CT_SYS_USER=$(id -un)
3.130 -CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true)
3.131 -# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
3.132 -CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
3.133 -CT_SYS_KERNEL=$(uname -s)
3.134 -CT_SYS_REVISION=$(uname -r)
3.135 -# MacOS X lacks '-o' :
3.136 -CT_SYS_OS=$(uname -o || echo "Unknown (maybe MacOS-X)")
3.137 -CT_SYS_MACHINE=$(uname -m)
3.138 -CT_SYS_PROCESSOR=$(uname -p)
3.139 -CT_SYS_GCC=$(gcc -dumpversion)
3.140 -CT_SYS_TARGET=$(CT_DoConfigGuess)
3.141 -CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
3.142 -
3.143 -CT_DoLog EXTRA "Preparing working directories"
3.144 -
3.145 -# Ah! The build directory shall be eradicated, even if we restart!
3.146 -if [ -d "${CT_BUILD_DIR}" ]; then
3.147 - CT_DoForceRmdir "${CT_BUILD_DIR}"
3.148 -fi
3.149 -
3.150 -# Don't eradicate directories if we need to restart
3.151 -if [ -z "${CT_RESTART}" ]; then
3.152 - # Get rid of pre-existing installed toolchain and previous build directories.
3.153 - # We need to do that _before_ we can safely log, because the log file will
3.154 - # most probably be in the toolchain directory.
3.155 - if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
3.156 - CT_DoForceRmdir "${CT_TARBALLS_DIR}"
3.157 - fi
3.158 - if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
3.159 - CT_DoForceRmdir "${CT_SRC_DIR}"
3.160 - fi
3.161 - if [ -d "${CT_INSTALL_DIR}" ]; then
3.162 - CT_DoForceRmdir "${CT_INSTALL_DIR}"
3.163 - fi
3.164 - if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
3.165 - CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}"
3.166 - fi
3.167 - # In case we start anew, get rid of the previously saved state directory
3.168 - if [ -d "${CT_STATE_DIR}" ]; then
3.169 - CT_DoForceRmdir "${CT_STATE_DIR}"
3.170 - fi
3.171 -fi
3.172 -
3.173 -# Create the directories we'll use, even if restarting: it does no harm to
3.174 -# create already existent directories, and CT_BUILD_DIR needs to be created
3.175 -# anyway
3.176 -CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}"
3.177 -CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
3.178 -CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}"
3.179 -CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}"
3.180 -CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}"
3.181 -CT_DoExecLog ALL mkdir -p "${CT_DEBUG_INSTALL_DIR}"
3.182 -CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}"
3.183 -CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}"
3.184 -CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}"
3.185 -
3.186 -# Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
3.187 -# the previous build was successful. To be able to move the logfile there,
3.188 -# switch them back to read/write
3.189 -CT_DoExecLog ALL chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
3.190 -
3.191 -# Redirect log to the actual log file now we can
3.192 -# It's quite understandable that the log file will be installed in the install
3.193 -# directory, so we must first ensure it exists and is writeable (above) before
3.194 -# we can log there
3.195 -exec >/dev/null
3.196 -case "${CT_LOG_TO_FILE}" in
3.197 - y) CT_LOG_FILE="${CT_PREFIX_DIR}/build.log"
3.198 - cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
3.199 - rm -f "${tmp_log_file}"
3.200 - exec >>"${CT_LOG_FILE}"
3.201 - ;;
3.202 - *) rm -f "${tmp_log_file}"
3.203 - ;;
3.204 -esac
3.205 -
3.206 -# Setting up the rest of the environment only if not restarting
3.207 -if [ -z "${CT_RESTART}" ]; then
3.208 - # What's our shell?
3.209 - # Will be plain /bin/sh on most systems, except if we have /bin/ash and we
3.210 - # _explictly_ required using it
3.211 - CT_SHELL="/bin/sh"
3.212 - [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash"
3.213 -
3.214 - # Arrange paths depending on wether we use sys-root or not.
3.215 - if [ "${CT_USE_SYSROOT}" = "y" ]; then
3.216 - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
3.217 - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
3.218 - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.219 - CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.220 - CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.221 - LIBC_SYSROOT_ARG=""
3.222 - # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
3.223 - # confused when $sysroot/usr/include is not present.
3.224 - # Note: --prefix=/usr is magic!
3.225 - # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
3.226 - else
3.227 - # plain old way. All libraries in prefix/target/lib
3.228 - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
3.229 - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
3.230 - # hack! Always use --with-sysroot for binutils.
3.231 - # binutils 2.14 and later obey it, older binutils ignore it.
3.232 - # Lets you build a working 32->64 bit cross gcc
3.233 - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
3.234 - # Use --with-headers, else final gcc will define disable_glibc while
3.235 - # building libgcc, and you'll have no profiling
3.236 - CC_CORE_SYSROOT_ARG="--without-headers"
3.237 - CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
3.238 - LIBC_SYSROOT_ARG="prefix="
3.239 - fi
3.240 -
3.241 - # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
3.242 - # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
3.243 - # "ld: cannot open crti.o: No such file or directory"
3.244 - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib"
3.245 - CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
3.246 -
3.247 - # Prevent gcc from installing its libraries outside of the sys-root
3.248 - CT_DoExecLog ALL ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib"
3.249 -
3.250 - # Now, in case we're 64 bits, just have lib64/ be a symlink to lib/
3.251 - # so as to have all libraries in the same directory (we can do that
3.252 - # because we are *not* multilib).
3.253 - if [ "${CT_ARCH_64}" = "y" ]; then
3.254 - CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/lib64"
3.255 - CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/usr/lib64"
3.256 - CT_DoExecLog ALL ln -sf "sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib64"
3.257 - fi
3.258 -
3.259 - # Determine build system if not set by the user
3.260 - CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
3.261 - case "${CT_BUILD}" in
3.262 - "") CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine);;
3.263 - esac
3.264 -
3.265 - # Prepare mangling patterns to later modify BUILD and HOST (see below)
3.266 - case "${CT_TOOLCHAIN_TYPE}" in
3.267 - cross)
3.268 - CT_HOST="${CT_BUILD}"
3.269 - build_mangle="build_"
3.270 - host_mangle="build_"
3.271 - ;;
3.272 - *) CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!"
3.273 - ;;
3.274 - esac
3.275 -
3.276 - # Save the real tuples to generate shell-wrappers to the real tools
3.277 - CT_REAL_BUILD="${CT_BUILD}"
3.278 - CT_REAL_HOST="${CT_HOST}"
3.279 -
3.280 - # Canonicalise CT_BUILD and CT_HOST
3.281 - # Not only will it give us full-qualified tuples, but it will also ensure
3.282 - # that they are valid tuples (in case of typo with user-provided tuples)
3.283 - # That's way better than trying to rewrite config.sub ourselves...
3.284 - CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}")
3.285 - CT_HOST=$(CT_DoConfigSub "${CT_HOST}")
3.286 -
3.287 - # Modify BUILD and HOST so that gcc always generate a cross-compiler
3.288 - # even if any of the build, host or target machines are the same.
3.289 - # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to
3.290 - # support canadain build, later...
3.291 - CT_BUILD="${CT_BUILD/-/-${build_mangle}}"
3.292 - CT_HOST="${CT_HOST/-/-${host_mangle}}"
3.293 -
3.294 - # Now we have mangled our BUILD and HOST tuples, we must fake the new
3.295 - # cross-tools for those mangled tuples.
3.296 - CT_DoLog DEBUG "Making build system tools available"
3.297 - CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
3.298 - for m in BUILD HOST; do
3.299 - r="CT_REAL_${m}"
3.300 - v="CT_${m}"
3.301 - p="CT_${m}_PREFIX"
3.302 - s="CT_${m}_SUFFIX"
3.303 - if [ -n "${!p}" ]; then
3.304 - t="${!p}"
3.305 - else
3.306 - t="${!r}-"
3.307 - fi
3.308 -
3.309 - for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do
3.310 - # First try with prefix + suffix
3.311 - # Then try with prefix only
3.312 - # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
3.313 - # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
3.314 - # This is needed, because some tools have a prefix and
3.315 - # a suffix (eg. gcc), while others may have only one,
3.316 - # or even none (eg. binutils)
3.317 - where=$(CT_Which "${t}${tool}${!s}")
3.318 - [ -z "${where}" ] && where=$(CT_Which "${t}${tool}")
3.319 - if [ -z "${where}" \
3.320 - -a \( "${m}" = "BUILD" \
3.321 - -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
3.322 - where=$(CT_Which "${tool}${!s}")
3.323 - fi
3.324 - if [ -z "${where}" \
3.325 - -a \( "${m}" = "BUILD" \
3.326 - -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
3.327 - where=$(CT_Which "${tool}")
3.328 - fi
3.329 -
3.330 - # Not all tools are available for all platforms, but some are really,
3.331 - # bally needed
3.332 - if [ -n "${where}" ]; then
3.333 - CT_DoLog DEBUG " '${!v}-${tool}' -> '${where}'"
3.334 - printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${!v}-${tool}"
3.335 - CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/${!v}-${tool}"
3.336 - else
3.337 - # We'll at least need some of them...
3.338 - case "${tool}" in
3.339 - ar|as|gcc|ld|nm|objcopy|objdump|ranlib)
3.340 - CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!"
3.341 - ;;
3.342 - *)
3.343 - # It does not deserve a WARN level.
3.344 - CT_DoLog DEBUG " Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required."
3.345 - ;;
3.346 - esac
3.347 - fi
3.348 - done
3.349 - done
3.350 -
3.351 - # Carefully add paths in the order we want them:
3.352 - # - first try in ${CT_PREFIX_DIR}/bin
3.353 - # - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
3.354 - # - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
3.355 - # - fall back to searching user's PATH
3.356 - # Of course, neither cross-native nor canadian can run on BUILD,
3.357 - # so don't add those PATHs in this case...
3.358 - case "${CT_TOOLCHAIN_TYPE}" in
3.359 - cross) export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";;
3.360 - *) ;;
3.361 - esac
3.362 -
3.363 - # Some makeinfo versions are a pain in [put your most sensible body part here].
3.364 - # Go ahead with those, by creating a wrapper that keeps partial files, and that
3.365 - # never fails:
3.366 - CT_DoLog DEBUG " 'makeinfo' -> '$(CT_Which makeinfo)'"
3.367 - printf "#${BANG}/bin/sh\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_PREFIX_DIR}/bin/makeinfo"
3.368 - CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/makeinfo"
3.369 -
3.370 - # Help gcc
3.371 - CT_CFLAGS_FOR_HOST=
3.372 - [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
3.373 -
3.374 - # Override the configured jobs with what's been given on the command line
3.375 - [ -n "${CT_JOBS}" ] && CT_PARALLEL_JOBS="${CT_JOBS}"
3.376 -
3.377 - # Set the shell to be used by ./configure scripts and by Makefiles (those
3.378 - # that support it!).
3.379 - export CONFIG_SHELL="${CT_SHELL}"
3.380 -
3.381 - # And help make go faster
3.382 - PARALLELMFLAGS=
3.383 - [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
3.384 - [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
3.385 - export PARALLELMFLAGS
3.386 -
3.387 - CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
3.388 - CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
3.389 - bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
3.390 -
3.391 - CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
3.392 - CT_DoLog EXTRA "Building a toolchain for:"
3.393 - CT_DoLog EXTRA " build = ${CT_REAL_BUILD}"
3.394 - CT_DoLog EXTRA " host = ${CT_REAL_HOST}"
3.395 - CT_DoLog EXTRA " target = ${CT_TARGET}"
3.396 - set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
3.397 - CT_EndStep
3.398 -fi
3.399 -
3.400 -if [ -z "${CT_RESTART}" ]; then
3.401 - CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
3.402 - do_kernel_get
3.403 - do_gmp_get
3.404 - do_mpfr_get
3.405 - do_binutils_get
3.406 - do_cc_get
3.407 - do_libc_get
3.408 - do_tools_get
3.409 - do_debug_get
3.410 - CT_EndStep
3.411 -
3.412 - if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
3.413 - if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
3.414 - CT_DoForceRmdir "${CT_SRC_DIR}"
3.415 - CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
3.416 - fi
3.417 - CT_DoStep INFO "Extracting and patching toolchain components"
3.418 - do_kernel_extract
3.419 - do_gmp_extract
3.420 - do_mpfr_extract
3.421 - do_binutils_extract
3.422 - do_cc_extract
3.423 - do_libc_extract
3.424 - do_tools_extract
3.425 - do_debug_extract
3.426 - CT_EndStep
3.427 - fi
3.428 -fi
3.429 -
3.430 -# Now for the job by itself. Go have a coffee!
3.431 -if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
3.432 - # Because of CT_RESTART, this becomes quite complex
3.433 - do_stop=0
3.434 - prev_step=
3.435 - [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
3.436 - # Aha! CT_STEPS comes from steps.mk!
3.437 - for step in ${CT_STEPS}; do
3.438 - if [ ${do_it} -eq 0 ]; then
3.439 - if [ "${CT_RESTART}" = "${step}" ]; then
3.440 - CT_DoLoadState "${step}"
3.441 - do_it=1
3.442 - do_stop=0
3.443 - fi
3.444 - else
3.445 - CT_DoSaveState ${step}
3.446 - if [ ${do_stop} -eq 1 ]; then
3.447 - CT_DoLog ERROR "Stopping just after step '${prev_step}', as requested."
3.448 - exit 0
3.449 - fi
3.450 - fi
3.451 - if [ ${do_it} -eq 1 ]; then
3.452 - do_${step}
3.453 - if [ "${CT_STOP}" = "${step}" ]; then
3.454 - do_stop=1
3.455 - fi
3.456 - if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then
3.457 - CT_DoPause "Step '${step}' finished"
3.458 - fi
3.459 - fi
3.460 - prev_step="${step}"
3.461 - done
3.462 -
3.463 - CT_DoLog INFO "================================================================="
3.464 -
3.465 - CT_DoLog DEBUG "Removing access to the build system tools"
3.466 - find "${CT_PREFIX_DIR}/bin" -name "${CT_BUILD}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
3.467 - find "${CT_PREFIX_DIR}/bin" -name "${CT_HOST}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
3.468 - CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/makeinfo"
3.469 -
3.470 - if [ "${CT_BARE_METAL}" != "y" ]; then
3.471 - CT_DoLog EXTRA "Installing the populate helper"
3.472 - sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
3.473 - "${CT_LIB_DIR}/scripts/populate.in" \
3.474 - >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
3.475 - CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
3.476 - fi
3.477 -
3.478 - # Create the aliases to the target tools
3.479 - CT_DoLog EXTRA "Creating toolchain aliases"
3.480 - CT_Pushd "${CT_PREFIX_DIR}/bin"
3.481 - for t in "${CT_TARGET}-"*; do
3.482 - if [ -n "${CT_TARGET_ALIAS}" ]; then
3.483 - _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
3.484 - CT_DoExecLog ALL ln -sv "${t}" "${_t}"
3.485 - fi
3.486 - if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
3.487 - _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
3.488 - CT_DoExecLog ALL ln -sv "${t}" "${_t}"
3.489 - fi
3.490 - done
3.491 - CT_Popd
3.492 -
3.493 - # Remove the generated documentation files
3.494 - if [ "${CT_REMOVE_DOCS}" = "y" ]; then
3.495 - CT_DoLog INFO "Removing installed documentation"
3.496 - CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
3.497 - CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
3.498 - CT_DoForceRmdir "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
3.499 - fi
3.500 -fi
3.501 -
3.502 -CT_DoEnd INFO
3.503 -
3.504 -# From now-on, it can become impossible to log any time, because
3.505 -# either we're compressing the log file, or it can become RO any
3.506 -# moment... Consign all ouptut to oblivion...
3.507 -CT_DoLog INFO "Finishing installation (may take a few seconds)..."
3.508 -exec >/dev/null 2>&1
3.509 -
3.510 -[ "${CT_LOG_FILE_COMPRESS}" = y ] && bzip2 -9 "${CT_LOG_FILE}"
3.511 -[ "${CT_INSTALL_DIR_RO}" = "y" ] && chmod -R a-w "${CT_INSTALL_DIR}"
3.512 -
3.513 -trap - EXIT
4.1 --- a/steps.mk Sun Jan 18 17:41:58 2009 +0000
4.2 +++ b/steps.mk Sun Jan 18 17:45:10 2009 +0000
4.3 @@ -34,7 +34,7 @@
4.4 tools \
4.5 debug \
4.6
4.7 -# Make the list available to sub-processes (scripts/crosstool.sh needs it)
4.8 +# Make the list available to sub-processes (scripts/crosstool-NG.sh needs it)
4.9 export CT_STEPS
4.10
4.11 # Print the steps list