scripts/crosstool-NG.sh.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed May 27 21:08:17 2009 +0000 (2009-05-27)
branchgcc-4.4
changeset 1392 8b36ebce12cf
parent 1384 b23f3c2e0c73
child 1415 f1ce1411d671
permissions -rw-r--r--
/devel/gcc-4.4:
- crosstool-NG.sh.in: include prefix/lib in LD_LIBRARY_PATH

-------- diffstat follows --------
/devel/gcc-4.4/scripts/crosstool-NG.sh.in | 4 4 0 0 ++++
1 file changed, 4 insertions(+)
     1 #!@@CT_bash@@
     2 # Copyright 2007 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package.
     4 
     5 # This is the main entry point to crosstool
     6 # This will:
     7 #   - download, extract and patch the toolchain components
     8 #   - build and install each components in turn
     9 #   - and eventually test the resulting toolchain
    10 
    11 # What this file does is prepare the environment, based upon the user-choosen
    12 # options. It also checks the existing environment for un-friendly variables,
    13 # and builds the tools.
    14 
    15 # Parse the common functions
    16 # Note: some initialisation and sanitizing is done while parsing this file,
    17 # most notably:
    18 #  - set trap handler on errors,
    19 #  - don't hash commands lookups,
    20 #  - initialise logging.
    21 . "${CT_LIB_DIR}/scripts/functions"
    22 
    23 # Parse the configuration file
    24 # It has some info about the logging facility, so include it early
    25 . .config
    26 # Yes! We can do full logging from now on!
    27 
    28 # Overide the locale early, in case we ever translate crosstool-NG messages
    29 [ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C
    30 
    31 # Where will we work?
    32 CT_WORK_DIR="${CT_WORK_DIR:-${CT_TOP_DIR}/targets}"
    33 CT_DoExecLog ALL mkdir -p "${CT_WORK_DIR}"
    34 
    35 # Check build file system case-sensitiveness
    36 CT_DoExecLog DEBUG touch "${CT_WORK_DIR}/foo"
    37 CT_TestAndAbort "Your file system in '${CT_WORK_DIR}' is *not* case-sensitive!" -f "${CT_WORK_DIR}/FOO"
    38 CT_DoExecLog DEBUG rm -f "${CT_WORK_DIR}/foo"
    39 
    40 # Create the bin-overide early
    41 # Contains symlinks to the tools found by ./configure
    42 # Note: CT_DoLog and CT_DoExecLog do not use any of those tool, so
    43 # they can be safely used
    44 CT_BIN_OVERIDE_DIR="${CT_WORK_DIR}/bin"
    45 CT_DoLog DEBUG "Creating bin-overide for tools in '${CT_BIN_OVERIDE_DIR}'"
    46 CT_DoExecLog DEBUG mkdir -p "${CT_BIN_OVERIDE_DIR}"
    47 cat "${CT_LIB_DIR}/paths.mk" |while read trash line; do
    48     tool="${line%%=*}"
    49     path="${line#*=}"
    50     CT_DoLog DEBUG "  '${tool}' -> '${path}'"
    51     printf "#${BANG}/bin/sh\nexec '${path}' \"\${@}\"\n" >"${CT_BIN_OVERIDE_DIR}/${tool}"
    52     CT_DoExecLog ALL chmod 700 "${CT_BIN_OVERIDE_DIR}/${tool}"
    53 done
    54 export PATH="${CT_BIN_OVERIDE_DIR}:${PATH}"
    55 
    56 # Start date. Can't be done until we know the locale
    57 CT_STAR_DATE=$(CT_DoDate +%s%N)
    58 CT_STAR_DATE_HUMAN=$(CT_DoDate +%Y%m%d.%H%M%S)
    59 
    60 # Log real begining of build, now
    61 CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
    62 
    63 # renice oursleves
    64 CT_DoExecLog DEBUG renice ${CT_NICE} $$
    65 
    66 CT_DoStep DEBUG "Dumping user-supplied crosstool-NG configuration"
    67 CT_DoExecLog DEBUG grep -E '^(# |)CT_' .config
    68 CT_EndStep
    69 
    70 # Some sanity checks in the environment and needed tools
    71 CT_DoLog INFO "Checking environment sanity"
    72 
    73 CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS"
    74 unset MAKEFLAGS
    75 export MAKEFLAGS
    76 
    77 # Other environment sanity checks
    78 CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
    79 CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
    80 CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
    81 CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
    82 export GREP_OPTIONS=
    83 
    84 CT_DoLog INFO "Building environment variables"
    85 
    86 # Include sub-scripts instead of calling them: that way, we do not have to
    87 # export any variable, nor re-parse the configuration and functions files.
    88 . "${CT_LIB_DIR}/scripts/build/internals.sh"
    89 . "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"
    90 . "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh"
    91 . "${CT_LIB_DIR}/scripts/build/companion_libs/gmp.sh"
    92 . "${CT_LIB_DIR}/scripts/build/companion_libs/mpfr.sh"
    93 . "${CT_LIB_DIR}/scripts/build/companion_libs/ppl.sh"
    94 . "${CT_LIB_DIR}/scripts/build/companion_libs/cloog.sh"
    95 . "${CT_LIB_DIR}/scripts/build/companion_libs/mpc.sh"
    96 . "${CT_LIB_DIR}/scripts/build/binutils/binutils.sh"
    97 . "${CT_LIB_DIR}/scripts/build/binutils/elf2flt.sh"
    98 . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh"
    99 . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh"
   100 . "${CT_LIB_DIR}/scripts/build/tools.sh"
   101 . "${CT_LIB_DIR}/scripts/build/debug.sh"
   102 
   103 # Target tuple: CT_TARGET needs a little love:
   104 CT_DoBuildTargetTuple
   105 
   106 # Kludge: If any of the configured options needs CT_TARGET,
   107 # then rescan the options file now:
   108 . .config
   109 
   110 # Second kludge: merge user-supplied target CFLAGS with architecture-provided
   111 # target CFLAGS. Do the same for LDFLAGS in case it happens in the future.
   112 # Put user-supplied flags at the end, so that they take precedence.
   113 CT_TARGET_CFLAGS="${CT_ARCH_TARGET_CFLAGS} ${CT_TARGET_CFLAGS}"
   114 CT_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_TARGET_LDFLAGS}"
   115 CT_CC_CORE_EXTRA_CONFIG="${CT_ARCH_CC_CORE_EXTRA_CONFIG} ${CT_CC_CORE_EXTRA_CONFIG}"
   116 CT_CC_EXTRA_CONFIG="${CT_ARCH_CC_EXTRA_CONFIG} ${CT_CC_EXTRA_CONFIG}"
   117 
   118 # Create the working directories
   119 CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
   120 CT_SRC_DIR="${CT_WORK_DIR}/src"
   121 CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build"
   122 CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
   123 CT_CONFIG_DIR="${CT_BUILD_DIR}/configs"
   124 
   125 # Note: we'll always install the core compiler in its own directory, so as to
   126 # not mix the two builds: core and final.
   127 CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
   128 CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
   129 
   130 # Set LD_LIBRARY_PATH to point to prefix/lib so we can find our own
   131 # libraries; add as first path, so we get hit first by the dynamic linker
   132 CT_SetLibPath "${CT_PREFIX_DIR}/lib" first
   133 
   134 # We must ensure that we can restart if asked for!
   135 if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}"  ]; then
   136     CT_DoLog ERROR "You asked to restart a non-restartable build"
   137     CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
   138     CT_DoLog ERROR "in the config options for the previous build, or the state"
   139     CT_DoLog ERROR "directory for the previous build was deleted."
   140     CT_Abort "I will stop here to avoid any carnage"
   141 fi
   142 
   143 # If the local tarball directory does not exist, say so, and don't try to save there!
   144 if [ ! -d "${CT_LOCAL_TARBALLS_DIR}" ]; then
   145     CT_DoLog WARN "Directory '${CT_LOCAL_TARBALLS_DIR}' does not exist. Will not save downloaded tarballs to local storage."
   146     CT_SAVE_TARBALLS=
   147 fi
   148 
   149 # Some more sanity checks now that we have all paths set up
   150 case "${CT_LOCAL_TARBALLS_DIR},${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
   151     *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
   152 esac
   153 
   154 # Check now if we can write to the destination directory:
   155 if [ -d "${CT_INSTALL_DIR}" ]; then
   156     CT_TestAndAbort "Destination directory '${CT_INSTALL_DIR}' is not removable" ! -w $(dirname "${CT_INSTALL_DIR}")
   157 fi
   158 
   159 # Good, now grab a bit of informations on the system we're being run on,
   160 # just in case something goes awok, and it's not our fault:
   161 CT_SYS_USER=$(id -un)
   162 CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true)
   163 # Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
   164 CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}"
   165 CT_SYS_KERNEL=$(uname -s)
   166 CT_SYS_REVISION=$(uname -r)
   167 # MacOS X lacks '-o' :
   168 CT_SYS_OS=$(uname -o || echo "Unknown (maybe MacOS-X)")
   169 CT_SYS_MACHINE=$(uname -m)
   170 CT_SYS_PROCESSOR=$(uname -p)
   171 CT_SYS_GCC=$(gcc -dumpversion)
   172 CT_SYS_TARGET=$(CT_DoConfigGuess)
   173 CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
   174 
   175 CT_DoLog EXTRA "Preparing working directories"
   176 
   177 # Ah! The build directory shall be eradicated, even if we restart!
   178 if [ -d "${CT_BUILD_DIR}" ]; then
   179     CT_DoForceRmdir "${CT_BUILD_DIR}"
   180 fi
   181 
   182 # Don't eradicate directories if we need to restart
   183 if [ -z "${CT_RESTART}" ]; then
   184     # Get rid of pre-existing installed toolchain and previous build directories.
   185     # We need to do that _before_ we can safely log, because the log file will
   186     # most probably be in the toolchain directory.
   187     if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
   188         CT_DoForceRmdir "${CT_TARBALLS_DIR}"
   189     fi
   190     if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
   191         CT_DoForceRmdir "${CT_SRC_DIR}"
   192     fi
   193     if [ -d "${CT_INSTALL_DIR}" ]; then
   194         CT_DoForceRmdir "${CT_INSTALL_DIR}"
   195     fi
   196     # In case we start anew, get rid of the previously saved state directory
   197     if [ -d "${CT_STATE_DIR}" ]; then
   198         CT_DoForceRmdir "${CT_STATE_DIR}"
   199     fi
   200 fi
   201 
   202 # Create the directories we'll use, even if restarting: it does no harm to
   203 # create already existent directories, and CT_BUILD_DIR needs to be created
   204 # anyway
   205 CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}"
   206 CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
   207 CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}"
   208 CT_DoExecLog ALL mkdir -p "${CT_CONFIG_DIR}"
   209 CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}"
   210 CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}"
   211 CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}"
   212 CT_DoExecLog ALL mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}"
   213 
   214 # Only create the state dir if asked for a restartable build
   215 [ -n "${CT_DEBUG_CT_SAVE_STEPS}" ] && CT_DoExecLog ALL mkdir -p "${CT_STATE_DIR}"
   216 
   217 # Check install file system case-sensitiveness
   218 CT_DoExecLog DEBUG touch "${CT_PREFIX_DIR}/foo"
   219 CT_TestAndAbort "Your file system in '${CT_PREFIX_DIR}' is *not* case-sensitive!" -f "${CT_PREFIX_DIR}/FOO"
   220 CT_DoExecLog DEBUG rm -f "${CT_PREFIX_DIR}/foo"
   221 
   222 # Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
   223 # the previous build was successful. To be able to move the logfile there,
   224 # switch them back to read/write
   225 CT_DoExecLog ALL chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
   226 
   227 # Redirect log to the actual log file now we can
   228 # It's quite understandable that the log file will be installed in the install
   229 # directory, so we must first ensure it exists and is writeable (above) before
   230 # we can log there
   231 exec >/dev/null
   232 case "${CT_LOG_TO_FILE}" in
   233     y)  CT_LOG_FILE="${CT_PREFIX_DIR}/build.log"
   234         cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
   235         rm -f "${tmp_log_file}"
   236         exec >>"${CT_LOG_FILE}"
   237         ;;
   238     *)  rm -f "${tmp_log_file}"
   239         ;;
   240 esac
   241 
   242 # Setting up the rest of the environment only if not restarting
   243 if [ -z "${CT_RESTART}" ]; then
   244     # What's our shell?
   245     # Will be plain /bin/sh on most systems, except if we have /bin/ash and we
   246     # _explictly_ required using it
   247     CT_SHELL="/bin/sh"
   248     [ "${CT_CONFIG_SHELL_ASH}" = "y" -a -x "/bin/ash" ] && CT_SHELL="/bin/ash"
   249 
   250     # Arrange paths depending on wether we use sys-root or not.
   251     if [ "${CT_USE_SYSROOT}" = "y" ]; then
   252         CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/sys-root"
   253         CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root"
   254         CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
   255         BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   256         CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   257         CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   258         LIBC_SYSROOT_ARG=""
   259         # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
   260         # confused when $sysroot/usr/include is not present.
   261         # Note: --prefix=/usr is magic!
   262         # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
   263     else
   264         # plain old way. All libraries in prefix/target/lib
   265         CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
   266         CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
   267         # hack!  Always use --with-sysroot for binutils.
   268         # binutils 2.14 and later obey it, older binutils ignore it.
   269         # Lets you build a working 32->64 bit cross gcc
   270         BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   271         # Use --with-headers, else final gcc will define disable_glibc while
   272         # building libgcc, and you'll have no profiling
   273         CC_CORE_SYSROOT_ARG="--without-headers"
   274         CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
   275         LIBC_SYSROOT_ARG="prefix="
   276     fi
   277     CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}"
   278     CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}"
   279 
   280     # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
   281     # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail
   282     # with: "ld: cannot open crti.o: No such file or directory"
   283     # Also prepare the lib directory in the install dir, else some 64 bit archs
   284     # won't build
   285     CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/lib"
   286     CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/lib"
   287     CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
   288 
   289     # Prevent gcc from installing its libraries outside of the sys-root
   290     CT_DoExecLog ALL ln -sf "./${CT_SYSROOT_DIR_PREFIX}/sys-root/lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib"
   291 
   292     # Now, in case we're 64 bits, just have lib64/ be a symlink to lib/
   293     # so as to have all libraries in the same directory (we can do that
   294     # because we are *not* multilib).
   295     if [ "${CT_ARCH_64}" = "y" ]; then
   296         CT_DoExecLog ALL ln -sf "lib" "${CT_PREFIX_DIR}/lib64"
   297         CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/lib64"
   298         CT_DoExecLog ALL ln -sf "lib" "${CT_SYSROOT_DIR}/usr/lib64"
   299         CT_DoExecLog ALL ln -sf "lib" "${CT_PREFIX_DIR}/${CT_TARGET}/lib64"
   300     fi
   301 
   302     # Determine build system if not set by the user
   303     CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
   304     case "${CT_BUILD}" in
   305         "") CT_BUILD=$("${CT_BUILD_PREFIX}gcc${CT_BUILD_SUFFIX}" -dumpmachine);;
   306     esac
   307 
   308     # Prepare mangling patterns to later modify BUILD and HOST (see below)
   309     case "${CT_TOOLCHAIN_TYPE}" in
   310         cross)
   311             CT_HOST="${CT_BUILD}"
   312             build_mangle="build_"
   313             host_mangle="build_"
   314             ;;
   315         *)  CT_Abort "No code for '${CT_TOOLCHAIN_TYPE}' toolchain type!"
   316             ;;
   317     esac
   318 
   319     # Save the real tuples to generate shell-wrappers to the real tools
   320     CT_REAL_BUILD="${CT_BUILD}"
   321     CT_REAL_HOST="${CT_HOST}"
   322 
   323     # Canonicalise CT_BUILD and CT_HOST
   324     # Not only will it give us full-qualified tuples, but it will also ensure
   325     # that they are valid tuples (in case of typo with user-provided tuples)
   326     # That's way better than trying to rewrite config.sub ourselves...
   327     CT_BUILD=$(CT_DoConfigSub "${CT_BUILD}")
   328     CT_HOST=$(CT_DoConfigSub "${CT_HOST}")
   329 
   330     # Modify BUILD and HOST so that gcc always generate a cross-compiler
   331     # even if any of the build, host or target machines are the same.
   332     # NOTE: we'll have to mangle the (BUILD|HOST)->TARGET x-compiler to
   333     #       support canadain build, later...
   334     CT_BUILD="${CT_BUILD/-/-${build_mangle}}"
   335     CT_HOST="${CT_HOST/-/-${host_mangle}}"
   336 
   337     # Now we have mangled our BUILD and HOST tuples, we must fake the new
   338     # cross-tools for those mangled tuples.
   339     CT_DoLog DEBUG "Making build system tools available"
   340     CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin"
   341     for m in BUILD HOST; do
   342         r="CT_REAL_${m}"
   343         v="CT_${m}"
   344         p="CT_${m}_PREFIX"
   345         s="CT_${m}_SUFFIX"
   346         if [ -n "${!p}" ]; then
   347             t="${!p}"
   348         else
   349             t="${!r}-"
   350         fi
   351 
   352         for tool in ar as dlltool gcc g++ gcj gnatbind gnatmake ld nm objcopy objdump ranlib strip windres; do
   353             # First try with prefix + suffix
   354             # Then try with prefix only
   355             # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
   356             # Finally try with neither prefix nor suffix, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST
   357             # This is needed, because some tools have a prefix and
   358             # a suffix (eg. gcc), while others may have only one,
   359             # or even none (eg. binutils)
   360             where=$(CT_Which "${t}${tool}${!s}")
   361             [ -z "${where}" ] && where=$(CT_Which "${t}${tool}")
   362             if [    -z "${where}"                         \
   363                  -a \(    "${m}" = "BUILD"                \
   364                        -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
   365                 where=$(CT_Which "${tool}${!s}")
   366             fi
   367             if [ -z "${where}"                            \
   368                  -a \(    "${m}" = "BUILD"                \
   369                        -o "${CT_REAL_BUILD}" = "${!r}" \) ]; then
   370                 where=$(CT_Which "${tool}")
   371             fi
   372 
   373             # Not all tools are available for all platforms, but some are really,
   374             # bally needed
   375             if [ -n "${where}" ]; then
   376                 CT_DoLog DEBUG "  '${!v}-${tool}' -> '${where}'"
   377                 printf "#${BANG}${CT_SHELL}\nexec '${where}' \"\${@}\"\n" >"${CT_PREFIX_DIR}/bin/${!v}-${tool}"
   378                 CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/${!v}-${tool}"
   379             else
   380                 case "${tool}" in
   381                     # We'll at least need some of them...
   382                     ar|as|gcc|ld|nm|objcopy|objdump|ranlib)
   383                         CT_Abort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!"
   384                         ;;
   385                     # Some are conditionnally required
   386                     # Add them in alphabetical (C locale) ordering
   387                     gcj)
   388                         CT_TestAndAbort "Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : either needed!" "${CT_CC_LANG_JAVA}" = "y"
   389                         ;;
   390                     # If any other is missing, only warn at low level
   391                     *)
   392                         # It does not deserve a WARN level.
   393                         CT_DoLog DEBUG "  Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required."
   394                         ;;
   395                 esac
   396             fi
   397         done
   398     done
   399 
   400     # Carefully add paths in the order we want them:
   401     #  - first try in ${CT_PREFIX_DIR}/bin
   402     #  - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
   403     #  - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
   404     #  - fall back to searching user's PATH
   405     # Of course, neither cross-native nor canadian can run on BUILD,
   406     # so don't add those PATHs in this case...
   407     case "${CT_TOOLCHAIN_TYPE}" in
   408         cross)  export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}";;
   409         *)  ;;
   410     esac
   411 
   412     # Some makeinfo versions are a pain in [put your most sensible body part here].
   413     # Go ahead with those, by creating a wrapper that keeps partial files, and that
   414     # never fails:
   415     CT_DoLog DEBUG "  'makeinfo' -> '$(CT_Which makeinfo)'"
   416     printf "#${BANG}/bin/sh\n$(CT_Which makeinfo) --force \"\${@}\"\ntrue\n" >"${CT_PREFIX_DIR}/bin/makeinfo"
   417     CT_DoExecLog ALL chmod 700 "${CT_PREFIX_DIR}/bin/makeinfo"
   418 
   419     # Help gcc
   420     CT_CFLAGS_FOR_HOST=
   421     [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
   422 
   423     # Override the configured jobs with what's been given on the command line
   424     [ -n "${CT_JOBS}" ] && CT_PARALLEL_JOBS="${CT_JOBS}"
   425 
   426     # Set the shell to be used by ./configure scripts and by Makefiles (those
   427     # that support it!).
   428     export CONFIG_SHELL="${CT_SHELL}"
   429 
   430     # And help make go faster
   431     PARALLELMFLAGS=
   432     [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
   433     [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
   434     export PARALLELMFLAGS
   435 
   436     CT_DoLog EXTRA "Installing user-supplied crosstool-NG configuration"
   437     CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
   438     CT_DoExecLog DEBUG sed -r -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
   439     bzip2 -c -9 .config >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ct-ng.config"
   440 
   441     CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
   442     CT_DoLog EXTRA "Building a toolchain for:"
   443     CT_DoLog EXTRA "  build  = ${CT_REAL_BUILD}"
   444     CT_DoLog EXTRA "  host   = ${CT_REAL_HOST}"
   445     CT_DoLog EXTRA "  target = ${CT_TARGET}"
   446     set |grep -E '^CT_.+=' |sort |CT_DoLog DEBUG
   447     CT_EndStep
   448 fi
   449 
   450 if [ -z "${CT_RESTART}" ]; then
   451     CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   452     do_kernel_get
   453     do_gmp_get
   454     do_mpfr_get
   455     do_ppl_get
   456     do_cloog_get
   457     do_mpc_get
   458     do_binutils_get
   459     do_cc_get
   460     do_libc_get
   461     do_tools_get
   462     do_debug_get
   463     CT_EndStep
   464 
   465     if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
   466         if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
   467             CT_DoForceRmdir "${CT_SRC_DIR}"
   468             CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}"
   469         fi
   470         CT_DoStep INFO "Extracting and patching toolchain components"
   471         do_kernel_extract
   472         do_gmp_extract
   473         do_mpfr_extract
   474         do_ppl_extract
   475         do_cloog_extract
   476         do_mpc_extract
   477         do_binutils_extract
   478         do_cc_extract
   479         do_libc_extract
   480         do_tools_extract
   481         do_debug_extract
   482         CT_EndStep
   483     fi
   484 fi
   485 
   486 # Now for the job by itself. Go have a coffee!
   487 if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
   488     # Because of CT_RESTART, this becomes quite complex
   489     do_stop=0
   490     prev_step=
   491     [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
   492     # Aha! CT_STEPS comes from steps.mk!
   493     for step in ${CT_STEPS}; do
   494         if [ ${do_it} -eq 0 ]; then
   495             if [ "${CT_RESTART}" = "${step}" ]; then
   496                 CT_DoLoadState "${step}"
   497                 do_it=1
   498                 do_stop=0
   499             fi
   500         else
   501             CT_DoSaveState ${step}
   502             if [ ${do_stop} -eq 1 ]; then
   503                 CT_DoLog ERROR "Stopping just after step '${prev_step}', as requested."
   504                 exit 0
   505             fi
   506         fi
   507         if [ ${do_it} -eq 1 ]; then
   508             do_${step}
   509             if [ "${CT_STOP}" = "${step}" ]; then
   510                 do_stop=1
   511             fi
   512             if [ "${CT_DEBUG_PAUSE_STEPS}" = "y" ]; then
   513                 CT_DoPause "Step '${step}' finished"
   514             fi
   515         fi
   516         prev_step="${step}"
   517     done
   518 fi
   519 
   520 CT_DoEnd INFO
   521 
   522 # From now-on, it can become impossible to log any time, because
   523 # either we're compressing the log file, or it can become RO any
   524 # moment... Consign all ouptut to oblivion...
   525 CT_DoLog INFO "Finishing installation (may take a few seconds)..."
   526 exec >/dev/null 2>&1
   527 
   528 [ "${CT_LOG_FILE_COMPRESS}" = y ] && bzip2 -9 "${CT_LOG_FILE}"
   529 [ "${CT_INSTALL_DIR_RO}" = "y"  ] && chmod -R a-w "${CT_INSTALL_DIR}"
   530 
   531 trap - EXIT