scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Aug 31 23:24:40 2010 +0200 (2010-08-31)
branch1.8
changeset 2108 68d038933dc4
parent 2004 5d6d3c28a658
child 2060 51e4597b07fc
permissions -rw-r--r--
binutils/binutils: remove faulty patch

The added code should be conditinal to the target system
being !MIPS, but is based on the host system being !MIPS.

This is plain wrong, and had not been noticed until now
as I never used those binutils versions on MIPS.

See:
http://sourceware.org/ml/crossgcc/2010-08/msg00192.html

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
(transplanted from f5ab0a80e46616adb3619cc7c5d78d0ccd7ea697)
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
    if [ "${CT_BARE_METAL}" != "y" ]; then
yann@1225
    12
        CT_DoLog EXTRA "Installing the populate helper"
yann@1225
    13
        sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
yann@1225
    14
               -e 's|@@CT_install@@|'"${install}"'|g;'  \
yann@1225
    15
               -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
yann@1225
    16
               -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
yann@1225
    17
               -e 's|@@CT_make@@|'"${make}"'|g;'        \
yann@1225
    18
               -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
yann@1225
    19
               "${CT_LIB_DIR}/scripts/populate.in"      \
yann@1225
    20
               >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
yann@1225
    21
        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
yann@1225
    22
    fi
yann@1225
    23
yann@2034
    24
    if [ "${CT_LIBC_XLDD}" = "y" ]; then
yann@2034
    25
        CT_DoLog EXTRA "Installing a cross-ldd helper"
yann@2034
    26
        sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
yann@2034
    27
               -e 's|@@CT_install@@|'"${install}"'|g;'  \
yann@2034
    28
               -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
yann@2034
    29
               -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
yann@2034
    30
               -e 's|@@CT_make@@|'"${make}"'|g;'        \
yann@2034
    31
               -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
yann@2034
    32
               "${CT_LIB_DIR}/scripts/xldd.in"          \
yann@2034
    33
               >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@2034
    34
        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@2034
    35
    fi
yann@2034
    36
yann@1225
    37
    # Create the aliases to the target tools
yann@1225
    38
    CT_DoLog EXTRA "Creating toolchain aliases"
yann@1225
    39
    CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1225
    40
    for t in "${CT_TARGET}-"*; do
yann@1225
    41
        if [ -n "${CT_TARGET_ALIAS}" ]; then
yann@1225
    42
            _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
yann@1225
    43
            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@1225
    44
        fi
yann@1225
    45
        if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
yann@1225
    46
            _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
yann@2004
    47
            if [ "${_t}" = "${t}" ]; then
yann@2004
    48
                CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
yann@2004
    49
            else
yann@2004
    50
                CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@2004
    51
            fi
yann@1225
    52
        fi
yann@1225
    53
    done
yann@1225
    54
    CT_Popd
yann@1225
    55
yann@1401
    56
    # If using the companion libraries, we need a wrapper
yann@1401
    57
    # that will set LD_LIBRARY_PATH approriately
yann@1495
    58
    if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
yann@1401
    59
        CT_DoLog EXTRA "Installing toolchain wrappers"
yann@1401
    60
        CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1402
    61
titus@1961
    62
        case "$CT_SYS_OS" in
titus@1961
    63
            Darwin|FreeBSD)
titus@1961
    64
                # wrapper does not work (when using readlink -m)
titus@1961
    65
                CT_DoLog WARN "Forcing usage of binary tool wrapper"
titus@1961
    66
                CT_TOOLS_WRAPPER="exec"
titus@1961
    67
                ;;
titus@1961
    68
        esac
yann@1493
    69
        # Install the wrapper
yann@1493
    70
        case "${CT_TOOLS_WRAPPER}" in
yann@1493
    71
            script)
yann@1493
    72
                CT_DoExecLog DEBUG install                              \
yann@1493
    73
                                   -m 0755                              \
yann@1493
    74
                                   "${CT_LIB_DIR}/scripts/wrapper.in"   \
yann@1493
    75
                                   ".${CT_TARGET}-wrapper"
yann@1493
    76
                ;;
yann@1493
    77
            exec)
yann@1518
    78
                CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
titus@1970
    79
                                   -Wall -Wextra -Werror                      \
titus@1970
    80
                                   -Os                                        \
yann@1518
    81
                                   "${CT_LIB_DIR}/scripts/wrapper.c"          \
yann@1518
    82
                                   -o ".${CT_TARGET}-wrapper"
titus@1970
    83
                if [ "${CT_DEBUG_CT}" != "y" ]; then
titus@1970
    84
                    # If not debugging crosstool-NG, strip the wrapper
titus@1970
    85
                    CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
titus@1970
    86
                fi
yann@1493
    87
                ;;
yann@1493
    88
        esac
yann@1402
    89
yann@1402
    90
        # Replace every tools with the wrapper
yann@1402
    91
        # Do it unconditionally, even for those tools that happen to be shell
yann@1402
    92
        # scripts, we don't know if they would in the end spawn a binary...
yann@1402
    93
        # Just skip symlinks
Yann@1408
    94
        for _t in "${CT_TARGET}-"*; do
titus@1955
    95
            if [ ! -L "${_t}" ]; then
yann@1413
    96
                CT_DoExecLog ALL mv "${_t}" ".${_t}"
Yann@1408
    97
                CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
yann@1402
    98
            fi
yann@1401
    99
        done
yann@1402
   100
yann@1402
   101
        # Get rid of the wrapper, we're using hardlinks
yann@1402
   102
        CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
yann@1401
   103
        CT_Popd
yann@1401
   104
    fi
yann@1401
   105
yann@1518
   106
    CT_DoLog EXTRA "Removing access to the build system tools"
yann@1518
   107
    CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
yann@1518
   108
yann@1225
   109
    # Remove the generated documentation files
yann@1225
   110
    if [ "${CT_REMOVE_DOCS}" = "y" ]; then
yann@1225
   111
        CT_DoLog EXTRA "Removing installed documentation"
yann@1225
   112
        CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
yann@1225
   113
        CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
yann@1225
   114
        CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
yann@1225
   115
    fi
yann@1225
   116
yann@1817
   117
    # Remove headers installed by native companion libraries
yann@1817
   118
    CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
yann@1817
   119
yann@1225
   120
    CT_EndStep
yann@1225
   121
}