scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Aug 30 00:57:40 2009 +0200 (2009-08-30)
changeset 1495 2542421e3321
parent 1493 0dce3a3986a1
child 1503 7dcef3fb5e8f
permissions -rw-r--r--
tools wrapper: introduce the silent WRAPPER_NEEDED config option

Add the WRAPPER_NEEDED silent config option, that can be selected by
components that require it (companion libs so far).
Rely on this config option when deciding to install the wrapper,
instead of checking GMP/MPFR or PPL/CLoog/MPC.
yann@1225
     1
# This file contains crosstool-NG internal steps
yann@1225
     2
yann@1225
     3
# This step is called once all components were built, to remove
yann@1225
     4
# un-wanted files, to add tuple aliases, and to add the final
yann@1225
     5
# crosstool-NG-provided files.
yann@1225
     6
do_finish() {
yann@1401
     7
    local _t
yann@1401
     8
yann@1225
     9
    CT_DoStep INFO "Cleaning-up the toolchain's directory"
yann@1225
    10
yann@1225
    11
    CT_DoLog EXTRA "Removing access to the build system tools"
yann@1423
    12
    CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
yann@1225
    13
yann@1225
    14
    if [ "${CT_BARE_METAL}" != "y" ]; then
yann@1225
    15
        CT_DoLog EXTRA "Installing the populate helper"
yann@1225
    16
        sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
yann@1225
    17
               -e 's|@@CT_install@@|'"${install}"'|g;'  \
yann@1225
    18
               -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
yann@1225
    19
               -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
yann@1225
    20
               -e 's|@@CT_make@@|'"${make}"'|g;'        \
yann@1225
    21
               -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
yann@1225
    22
               "${CT_LIB_DIR}/scripts/populate.in"      \
yann@1225
    23
               >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
yann@1225
    24
        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
yann@1225
    25
    fi
yann@1225
    26
yann@1225
    27
    # Create the aliases to the target tools
yann@1225
    28
    CT_DoLog EXTRA "Creating toolchain aliases"
yann@1225
    29
    CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1225
    30
    for t in "${CT_TARGET}-"*; do
yann@1225
    31
        if [ -n "${CT_TARGET_ALIAS}" ]; then
yann@1225
    32
            _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
yann@1225
    33
            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@1225
    34
        fi
yann@1225
    35
        if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
yann@1225
    36
            _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
yann@1225
    37
            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@1225
    38
        fi
yann@1225
    39
    done
yann@1225
    40
    CT_Popd
yann@1225
    41
yann@1401
    42
    # If using the companion libraries, we need a wrapper
yann@1401
    43
    # that will set LD_LIBRARY_PATH approriately
yann@1495
    44
    if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
yann@1401
    45
        CT_DoLog EXTRA "Installing toolchain wrappers"
yann@1401
    46
        CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1402
    47
yann@1493
    48
        # Install the wrapper
yann@1493
    49
        case "${CT_TOOLS_WRAPPER}" in
yann@1493
    50
            script)
yann@1493
    51
                CT_DoExecLog DEBUG install                              \
yann@1493
    52
                                   -m 0755                              \
yann@1493
    53
                                   "${CT_LIB_DIR}/scripts/wrapper.in"   \
yann@1493
    54
                                   ".${CT_TARGET}-wrapper"
yann@1493
    55
                ;;
yann@1493
    56
            exec)
yann@1493
    57
                _t="-s"
yann@1493
    58
                if [ "${CT_DEBUG_CT}" = "y" ]; then
yann@1493
    59
                  _t="" # If debugging crosstool-NG, don't strip the wrapper
yann@1493
    60
                fi
yann@1493
    61
                CT_DoExecLog "${HOST_CC}"                               \
yann@1493
    62
                             -Wall -Wextra -Wunreachable-code -Werror   \
yann@1493
    63
                             -O3 -static ${_t}                          \
yann@1493
    64
                             -o ".${CT_TARGET}-wrapper"
yann@1493
    65
                ;;
yann@1493
    66
        esac
yann@1402
    67
yann@1402
    68
        # Replace every tools with the wrapper
yann@1402
    69
        # Do it unconditionally, even for those tools that happen to be shell
yann@1402
    70
        # scripts, we don't know if they would in the end spawn a binary...
yann@1402
    71
        # Just skip symlinks
Yann@1408
    72
        for _t in "${CT_TARGET}-"*; do
Yann@1408
    73
            if [ "$( LANG=C stat -c '%F' "${_t}" )" != "symbolic link" ]; then
yann@1413
    74
                CT_DoExecLog ALL mv "${_t}" ".${_t}"
Yann@1408
    75
                CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
yann@1402
    76
            fi
yann@1401
    77
        done
yann@1402
    78
yann@1402
    79
        # Get rid of the wrapper, we're using hardlinks
yann@1402
    80
        CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
yann@1401
    81
        CT_Popd
yann@1401
    82
    fi
yann@1401
    83
yann@1225
    84
    # Remove the generated documentation files
yann@1225
    85
    if [ "${CT_REMOVE_DOCS}" = "y" ]; then
yann@1225
    86
        CT_DoLog EXTRA "Removing installed documentation"
yann@1225
    87
        CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
yann@1225
    88
        CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
yann@1225
    89
        CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
yann@1225
    90
    fi
yann@1225
    91
yann@1225
    92
    CT_EndStep
yann@1225
    93
}