scripts/crosstool.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Sep 15 08:40:07 2007 +0000 (2007-09-15)
changeset 390 eb3b271ca27c
parent 387 2fa4b675a9a3
child 391 11172b754564
permissions -rwxr-xr-x
We don't support Cygwin yet, no point in having quirks in.
     1 #!/bin/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 . "${CT_LIB_DIR}/scripts/functions"
    17 
    18 CT_STAR_DATE=`CT_DoDate +%s%N`
    19 CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
    20 
    21 # Are we configured? We'll need that later...
    22 CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
    23 
    24 # Parse the configuration file
    25 # It has some info about the logging facility, so include it early
    26 . "${CT_TOP_DIR}/.config"
    27 
    28 # Yes! We can do full logging from now on!
    29 CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
    30 
    31 # renice oursleves
    32 renice ${CT_NICE} $$ |CT_DoLog DEBUG
    33 
    34 CT_DoStep DEBUG "Dumping crosstool-NG configuration"
    35 cat "${CT_TOP_DIR}/.config" |egrep '^(# |)CT_' |CT_DoLog DEBUG
    36 CT_EndStep
    37 
    38 # Some sanity checks in the environment and needed tools
    39 CT_DoLog INFO "Checking environment sanity"
    40 
    41 CT_DoLog DEBUG "Unsetting and unexporting MAKEFLAGS"
    42 unset MAKEFLAGS
    43 export MAKEFLAGS
    44 
    45 # Enable known ordering of files in directory listings:
    46 CT_Test "crosstool-NG might not work as expected with LANG=\"${LANG}\"" -n "${LANG}"
    47 case "${LC_COLLATE},${LC_ALL}" in
    48   # These four combinations are known to sort files in the correct order:
    49   fr_FR*,)  ;;
    50   en_US*,)  ;;
    51   *,fr_FR*) ;;
    52   *,en_US*) ;;
    53   # Anything else is destined to be borked if not gracefuly handled:
    54   *) CT_DoLog WARN "Either LC_COLLATE=\"${LC_COLLATE}\" or LC_ALL=\"${LC_ALL}\" is not supported."
    55      export LC_ALL=`locale -a |egrep "^(fr_FR|en_US)" |head -n 1`
    56      CT_TestOrAbort "Neither en_US* nor fr_FR* locales found on your system." -n "${LC_ALL}"
    57      CT_DoLog WARN "Forcing to known working LC_ALL=\"${LC_ALL}\"."
    58      ;;
    59 esac
    60 
    61 # Other environment sanity checks
    62 CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}"
    63 CT_TestAndAbort "Don't set CFLAGS. It screws up the build." -n "${CFLAGS}"
    64 CT_TestAndAbort "Don't set CXXFLAGS. It screws up the build." -n "${CXXFLAGS}"
    65 CT_Test "GREP_OPTIONS screws up the build. Resetting." -n "${GREP_OPTIONS}"
    66 GREP_OPTIONS=
    67 CT_HasOrAbort awk
    68 CT_HasOrAbort sed
    69 CT_HasOrAbort bison
    70 CT_HasOrAbort flex
    71 CT_HasOrAbort lynx
    72 
    73 CT_DoLog INFO "Building environment variables"
    74 
    75 # Parse architecture-specific functions
    76 . ${CT_LIB_DIR}/arch/${CT_ARCH}/functions
    77 
    78 # Target tuple: CT_TARGET needs a little love:
    79 CT_DoBuildTargetTuple
    80 
    81 # Kludge: If any of the configured options needs CT_TARGET,
    82 # then rescan the options file now:
    83 . "${CT_TOP_DIR}/.config"
    84 
    85 # Now, build up the variables from the user-configured options.
    86 CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}"
    87 CT_BINUTILS_FILE="binutils-${CT_BINUTILS_VERSION}"
    88 CT_CC_FILE="${CT_CC}-${CT_CC_VERSION}"
    89 CT_LIBC_FILE="${CT_LIBC}-${CT_LIBC_VERSION}"
    90 
    91 # Where will we work?
    92 CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
    93 CT_SRC_DIR="${CT_TOP_DIR}/targets/src"
    94 CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
    95 CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
    96 # Note: we'll always install the core compiler in its own directory, so as to
    97 # not mix the two builds: core and final.
    98 CT_CC_CORE_STATIC_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-static"
    99 CT_CC_CORE_SHARED_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core-shared"
   100 CT_STATE_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/state"
   101 
   102 # We must ensure that we can restart if asked for!
   103 if [ -n "${CT_RESTART}" -a ! -d "${CT_STATE_DIR}"  ]; then
   104     CT_DoLog ERROR "You asked to restart a non-restartable build"
   105     CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS"
   106     CT_DoLog ERROR "in the config options for the previous build, or the state"
   107     CT_DoLog ERROR "directoy for the previous build was deleted."
   108     CT_Abort "I will stop here to avoid any carnage"
   109 fi
   110 
   111 # Make all path absolute, it so much easier!
   112 CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
   113 
   114 # Some more sanity checks now that we have all paths set up
   115 case "${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
   116     *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
   117 esac
   118 
   119 # Check now if we can write to the destination directory:
   120 if [ -d "${CT_INSTALL_DIR}" ]; then
   121     CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
   122 fi
   123 
   124 # Good, now grab a bit of informations on the system we're being run on,
   125 # just in case something goes awok, and it's not our fault:
   126 CT_SYS_USER="`id -un`"
   127 CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
   128 # Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
   129 CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
   130 CT_SYS_KERNEL=`uname -s`
   131 CT_SYS_REVISION=`uname -r`
   132 # MacOS X lacks '-o' :
   133 CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
   134 CT_SYS_MACHINE=`uname -m`
   135 CT_SYS_PROCESSOR=`uname -p`
   136 CT_SYS_GCC=`gcc -dumpversion`
   137 CT_SYS_TARGET=`CT_DoConfigGuess`
   138 CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
   139 
   140 CT_DoLog EXTRA "Preparing working directories"
   141 
   142 # Ah! The build directory shall be eradicated, even if we restart!
   143 if [ -d "${CT_BUILD_DIR}" ]; then
   144     mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
   145     chmod -R u+w "${CT_BUILD_DIR}.$$"
   146     setsid nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
   147 fi
   148 
   149 # Don't eradicate directories if we need to restart
   150 if [ -z "${CT_RESTART}" ]; then
   151     # Get rid of pre-existing installed toolchain and previous build directories.
   152     # We need to do that _before_ we can safely log, because the log file will
   153     # most probably be in the toolchain directory.
   154     if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
   155         mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
   156         chmod -R u+w "${CT_TARBALLS_DIR}.$$"
   157         setsid nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
   158     fi
   159     if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
   160         mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
   161         chmod -R u+w "${CT_SRC_DIR}.$$"
   162         setsid nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
   163     fi
   164     if [ -d "${CT_INSTALL_DIR}" ]; then
   165         mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
   166         chmod -R u+w "${CT_INSTALL_DIR}.$$"
   167         setsid nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
   168     fi
   169     if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
   170         mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
   171         chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
   172         setsid nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
   173     fi
   174     # In case we start anew, get rid of the previously saved state directory
   175     if [ -d "${CT_STATE_DIR}" ]; then
   176         mv "${CT_STATE_DIR}" "${CT_STATE_DIR}.$$"
   177         chmod -R u+w "${CT_STATE_DIR}.$$"
   178         setsid nohup rm -rf "${CT_STATE_DIR}.$$" >/dev/null 2>&1 &
   179     fi
   180 fi
   181 
   182 # Create the directories we'll use, even if restarting: it does no harm to
   183 # create already existent directories, and CT_BUILD_DIR needs to be created
   184 # anyway
   185 mkdir -p "${CT_TARBALLS_DIR}"
   186 mkdir -p "${CT_SRC_DIR}"
   187 mkdir -p "${CT_BUILD_DIR}"
   188 mkdir -p "${CT_INSTALL_DIR}"
   189 mkdir -p "${CT_PREFIX_DIR}"
   190 mkdir -p "${CT_DEBUG_INSTALL_DIR}"
   191 mkdir -p "${CT_CC_CORE_STATIC_PREFIX_DIR}"
   192 mkdir -p "${CT_CC_CORE_SHARED_PREFIX_DIR}"
   193 mkdir -p "${CT_STATE_DIR}"
   194 
   195 # Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
   196 # the previous build was successfull. To be able to move the logfile there,
   197 # switch them back to read/write
   198 chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
   199 
   200 # Redirect log to the actual log file now we can
   201 # It's quite understandable that the log file will be installed in the install
   202 # directory, so we must first ensure it exists and is writeable (above) before
   203 # we can log there
   204 exec >/dev/null
   205 case "${CT_LOG_TO_FILE}" in
   206     y)  CT_LOG_FILE="${CT_PREFIX_DIR}/build.log"
   207         cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
   208         rm -f "${tmp_log_file}"
   209         exec >>"${CT_LOG_FILE}"
   210         ;;
   211     *)  rm -f "${tmp_log_file}"
   212         ;;
   213 esac
   214 
   215 # Setting up the rest of the environment only is not restarting
   216 if [ -z "${CT_RESTART}" ]; then
   217     # Determine build system if not set by the user
   218     CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
   219     CT_BUILD="${CT_BUILD:-`CT_DoConfigGuess`}"
   220     CT_BUILD=`CT_DoConfigSub "${CT_BUILD}"`
   221 
   222     # Arrange paths depending on wether we use sys-root or not.
   223     if [ "${CT_USE_SYSROOT}" = "y" ]; then
   224         CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
   225         CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
   226         BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   227         CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   228         CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   229         LIBC_SYSROOT_ARG=""
   230         # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
   231         # confused when $sysroot/usr/include is not present.
   232         # Note: --prefix=/usr is magic!
   233         # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
   234     else
   235         # plain old way. All libraries in prefix/target/lib
   236         CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
   237         CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
   238         # hack!  Always use --with-sysroot for binutils.
   239         # binutils 2.14 and later obey it, older binutils ignore it.
   240         # Lets you build a working 32->64 bit cross gcc
   241         BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   242         # Use --with-headers, else final gcc will define disable_glibc while
   243         # building libgcc, and you'll have no profiling
   244         CC_CORE_SYSROOT_ARG="--without-headers"
   245         CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
   246         LIBC_SYSROOT_ARG="prefix="
   247     fi
   248 
   249     # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
   250     # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
   251     #  "ld: cannot open crti.o: No such file or directory"
   252     mkdir -p "${CT_SYSROOT_DIR}/lib"
   253     mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
   254 
   255     # Canadian-cross are really picky on the way they are built. Tweak the values.
   256     CT_UNIQ_BUILD=`echo "${CT_BUILD}" |sed -r -e 's/-/-build_/'`
   257     if [ "${CT_CANADIAN}" = "y" ]; then
   258         # Arrange so that gcc never, ever think that build system == host system
   259         CT_CANADIAN_OPT="--build=${CT_UNIQ_BUILD}"
   260         # We shall have a compiler for this target!
   261         # Do test here...
   262     else
   263         CT_HOST="${CT_BUILD}"
   264         CT_CANADIAN_OPT="--build=${CT_BUILD}"
   265         # Add the target toolchain in the path so that we can build the C library
   266         # Carefully add paths in the order we want them:
   267         #  - first try in ${CT_PREFIX_DIR}/bin
   268         #  - then try in ${CT_CC_CORE_SHARED_PREFIX_DIR}/bin
   269         #  - then try in ${CT_CC_CORE_STATIC_PREFIX_DIR}/bin
   270         #  - fall back to searching user's PATH
   271         export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_SHARED_PREFIX_DIR}/bin:${CT_CC_CORE_STATIC_PREFIX_DIR}/bin:${PATH}"
   272     fi
   273 
   274     # Modify GCC_HOST to never be equal to $BUILD or $TARGET
   275     # This strange operation causes gcc to always generate a cross-compiler
   276     # even if the build machine is the same kind as the host.
   277     # This is why CC has to be set when doing a canadian cross; you can't find a
   278     # host compiler by appending -gcc to our whacky $GCC_HOST
   279     # Kludge: it is reported that the above causes canadian crosses with cygwin
   280     # hosts to fail, so avoid it just in that one case.  It would be cleaner to
   281     # just move this into the non-canadian case above, but I'm afraid that might
   282     # cause some configure script somewhere to decide that since build==host, they
   283     # could run host binaries.
   284     # (Copied almost as-is from original crosstool):
   285     case "${CT_KERNEL},${CT_CANADIAN}" in
   286         cygwin,y) ;;
   287         *,y)      CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
   288     esac
   289 
   290     # Ah! Recent versions of binutils need some of the build and/or host system
   291     # (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
   292     # Do that:
   293     CT_DoLog DEBUG "Making build system tools available"
   294     mkdir -p "${CT_PREFIX_DIR}/bin"
   295     for tool in ar as dlltool gcc g++ gnatbind gnatmake ld nm ranlib strip windres objcopy objdump; do
   296         tmp=`CT_Which ${tool}`
   297         if [ -n "${tmp}" ]; then
   298             ln -sfv "${tmp}" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
   299             ln -sfv "${tmp}" "${CT_PREFIX_DIR}/bin/${CT_UNIQ_BUILD}-${tool}"
   300             ln -sfv "${tmp}" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
   301         fi |CT_DoLog DEBUG
   302     done
   303 
   304     # Build up the TARGET_CFLAGS from user-provided options
   305     # Override with user-specified CFLAGS
   306     [ -n "${CT_ARCH_CPU}" ]  && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
   307     [ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
   308     [ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
   309     [ -n "${CT_ARCH_FPU}" ]  && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
   310 
   311     # Help gcc
   312     CT_CFLAGS_FOR_HOST=
   313     [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
   314 
   315     # Override the configured jobs with what's been given on the command line
   316     [ -n "${CT_JOBS}" ] && CT_PARALLEL_JOBS="${CT_JOBS}"
   317 
   318     # And help make go faster
   319     PARALLELMFLAGS=
   320     [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
   321     [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
   322 
   323     CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
   324     CT_DoLog EXTRA "Building a toolchain for:"
   325     CT_DoLog EXTRA "  build  = ${CT_BUILD}"
   326     CT_DoLog EXTRA "  host   = ${CT_HOST}"
   327     CT_DoLog EXTRA "  target = ${CT_TARGET}"
   328     set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
   329     CT_EndStep
   330 fi
   331 
   332 # Include sub-scripts instead of calling them: that way, we do not have to
   333 # export any variable, nor re-parse the configuration and functions files.
   334 . "${CT_LIB_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
   335 . "${CT_LIB_DIR}/scripts/build/binutils.sh"
   336 . "${CT_LIB_DIR}/scripts/build/libc_${CT_LIBC}.sh"
   337 . "${CT_LIB_DIR}/scripts/build/cc_${CT_CC}.sh"
   338 . "${CT_LIB_DIR}/scripts/build/debug.sh"
   339 . "${CT_LIB_DIR}/scripts/build/tools.sh"
   340 
   341 if [ -z "${CT_RESTART}" ]; then
   342     CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   343     do_kernel_get
   344     do_binutils_get
   345     do_cc_get
   346     do_libc_get
   347     do_tools_get
   348     do_debug_get
   349     CT_EndStep
   350 
   351     if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
   352         if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
   353             mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
   354             setsid nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
   355         fi
   356         CT_DoStep INFO "Extracting and patching toolchain components"
   357         do_kernel_extract
   358         do_binutils_extract
   359         do_cc_extract
   360         do_libc_extract
   361         do_tools_extract
   362         do_debug_extract
   363         CT_EndStep
   364     fi
   365 fi
   366 
   367 # Now for the job by itself. Go have a coffee!
   368 if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
   369     # Because of CT_RESTART, this becomes quite complex
   370     do_stop=0
   371     prev_step=
   372     [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
   373     for step in libc_check_config       \
   374                 kernel_check_config     \
   375                 kernel_headers          \
   376                 binutils                \
   377                 cc_core_pass_1          \
   378                 libc_headers            \
   379                 libc_start_files        \
   380                 cc_core_pass_2          \
   381                 libc                    \
   382                 cc                      \
   383                 libc_finish             \
   384                 tools                   \
   385                 debug                   \
   386                 ; do
   387         if [ ${do_it} -eq 0 ]; then
   388             if [ "${CT_RESTART}" = "${step}" ]; then
   389                 CT_DoLoadState "${step}"
   390                 do_it=1
   391                 do_stop=0
   392             fi
   393         else
   394             CT_DoSaveState ${step}
   395             if [ ${do_stop} -eq 1 ]; then
   396                 CT_DoLog ERROR "Stopping just after step \"${prev_step}\", as requested."
   397                 exit 0
   398             fi
   399         fi
   400         if [ ${do_it} -eq 1 ]; then
   401             do_${step}
   402             if [ "${CT_STOP}" = "${step}" ]; then
   403                 do_stop=1
   404             fi
   405             if [ "${CTDEBUG_CT_PAUSE_STEPS}" = "y" ]; then
   406                 CT_DoPause "Step \"${step}\" finished"
   407             fi
   408         fi
   409         prev_step="${step}"
   410     done
   411 
   412     CT_DoLog DEBUG "Removing access to the build system tools"
   413     find "${CT_PREFIX_DIR}/bin" -name "${CT_BUILD}-"'*' -exec rm -fv {} \+ |CT_DoLog DEBUG
   414     find "${CT_PREFIX_DIR}/bin" -name "${CT_UNIQ_BUILD}-"'*' -exec rm -fv {} \+ |CT_DoLog DEBUG
   415     find "${CT_PREFIX_DIR}/bin" -name "${CT_HOST}-"'*' -exec rm -fv {} \+ |CT_DoLog DEBUG
   416 
   417     # Install the /populator/
   418     CT_DoLog EXTRA "Installing the populate helper"
   419     sed -r -e 's,@@CT_READELF@@,'"${CT_PREFIX_DIR}/bin/${CT_TARGET}-readelf"',g;'   \
   420            -e 's,@@CT_SYSROOT_DIR@@,'"${CT_SYSROOT_DIR}"',g;'                       \
   421            "${CT_LIB_DIR}/tools/populate.in" >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
   422     chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
   423 
   424     # Create the aliases to the target tools
   425     CT_DoStep EXTRA "Creating toolchain aliases"
   426     CT_Pushd "${CT_PREFIX_DIR}/bin"
   427     for t in "${CT_TARGET}-"*; do
   428         if [ -n "${CT_TARGET_ALIAS}" ]; then
   429             _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
   430             CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
   431             ln -sv "${t}" "${_t}" 2>&1 |CT_DoLog ALL
   432         fi
   433         if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
   434             _t="`echo \"$t\" |sed -r -e \"${CT_TARGET_ALIAS_SED_EXPR}\"`"
   435             CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
   436             ln -sv "${t}" "${_t}" 2>&1 |CT_DoLog ALL
   437         fi
   438     done
   439     CT_Popd
   440     CT_EndStep
   441 
   442     # Remove the generated documentation files
   443     if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   444     	CT_DoLog INFO "Removing installed documentation"
   445         rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
   446         rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
   447         rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
   448     fi
   449 fi
   450 
   451 CT_DoEnd INFO
   452 
   453 if [ "${CT_LOG_FILE_COMPRESS}" = y ]; then
   454     CT_DoLog EXTRA "Compressing log file"
   455     exec >/dev/null
   456     bzip2 -9 "${CT_LOG_FILE}"
   457 fi
   458 
   459 if [ "${CT_INSTALL_DIR_RO}" = "y" ]; then
   460     # OK, now we're done, set the toolchain read-only
   461     # Don't log, the log file may become read-only any moment...
   462     chmod -R a-w "${CT_INSTALL_DIR}" >/dev/null 2>&1
   463 fi
   464 
   465 trap - EXIT