scripts/build/internals.sh
author Yann E. MORIN
Sun Jun 14 22:57:57 2009 +0200 (2009-06-14)
branchgcc-4.4
changeset 1408 f334df41f069
parent 1402 146c62142e1b
child 1413 084d38788c1d
permissions -rw-r--r--
[finish-step] Use local variable in finish-step

When wrapping the tools, use a local variable when iterating.
     1 # This file contains crosstool-NG internal steps
     2 
     3 # This step is called once all components were built, to remove
     4 # un-wanted files, to add tuple aliases, and to add the final
     5 # crosstool-NG-provided files.
     6 do_finish() {
     7     local _t
     8 
     9     CT_DoStep INFO "Cleaning-up the toolchain's directory"
    10 
    11     CT_DoLog EXTRA "Removing access to the build system tools"
    12     find "${CT_PREFIX_DIR}/bin" -name "${CT_BUILD}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
    13     find "${CT_PREFIX_DIR}/bin" -name "${CT_HOST}-"'*' -exec rm -fv {} \; |CT_DoLog DEBUG
    14     CT_DoExecLog DEBUG rm -fv "${CT_PREFIX_DIR}/bin/makeinfo"
    15 
    16     if [ "${CT_BARE_METAL}" != "y" ]; then
    17         CT_DoLog EXTRA "Installing the populate helper"
    18         sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
    19                -e 's|@@CT_install@@|'"${install}"'|g;'  \
    20                -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
    21                -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
    22                -e 's|@@CT_make@@|'"${make}"'|g;'        \
    23                -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
    24                "${CT_LIB_DIR}/scripts/populate.in"      \
    25                >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    26         CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    27     fi
    28 
    29     # Create the aliases to the target tools
    30     CT_DoLog EXTRA "Creating toolchain aliases"
    31     CT_Pushd "${CT_PREFIX_DIR}/bin"
    32     for t in "${CT_TARGET}-"*; do
    33         if [ -n "${CT_TARGET_ALIAS}" ]; then
    34             _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
    35             CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    36         fi
    37         if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
    38             _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
    39             CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    40         fi
    41     done
    42     CT_Popd
    43 
    44     # If using the companion libraries, we need a wrapper
    45     # that will set LD_LIBRARY_PATH approriately
    46     if [    "${CT_GMP_MPFR}" = "y"      \
    47          -o "${CT_PPL_CLOOG_MPC}" = "y" ]; then
    48         CT_DoLog EXTRA "Installing toolchain wrappers"
    49         CT_Pushd "${CT_PREFIX_DIR}/bin"
    50 
    51         # Copy the wrapper
    52         CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/wrapper.in"   \
    53                                            ".${CT_TARGET}-wrapper"
    54 
    55         # Replace every tools with the wrapper
    56         # Do it unconditionally, even for those tools that happen to be shell
    57         # scripts, we don't know if they would in the end spawn a binary...
    58         # Just skip symlinks
    59         for _t in "${CT_TARGET}-"*; do
    60             if [ "$( LANG=C stat -c '%F' "${_t}" )" != "symbolic link" ]; then
    61                 CT_DoExecLog ALL mv "${t}" ".${_t}"
    62                 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
    63             fi
    64         done
    65 
    66         # Get rid of the wrapper, we're using hardlinks
    67         CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
    68         CT_Popd
    69     fi
    70 
    71     # Remove the generated documentation files
    72     if [ "${CT_REMOVE_DOCS}" = "y" ]; then
    73         CT_DoLog EXTRA "Removing installed documentation"
    74         CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
    75         CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
    76         CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
    77     fi
    78 
    79     CT_EndStep
    80 }