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