scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Nov 23 21:34:56 2010 +0100 (2010-11-23)
changeset 2184 e826624966a1
parent 2163 96082aa6459f
child 2185 46330accf748
child 2254 361e852ef8c1
permissions -rw-r--r--
scripts/xldd: fix version string

The version string was hard-coded.
Now, the version string follows the crosstool-NG version.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
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
titus@2089
     8
    local strip_args
yann@1401
     9
yann@1225
    10
    CT_DoStep INFO "Cleaning-up the toolchain's directory"
yann@1225
    11
linux@2060
    12
    if [ "${CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
titus@2089
    13
        case "$CT_HOST" in
titus@2089
    14
            *darwin*)
titus@2089
    15
                strip_args=""
titus@2089
    16
                ;;
titus@2089
    17
            *)
titus@2089
    18
                strip_args="--strip-all -v"
titus@2089
    19
                ;;
titus@2089
    20
        esac
linux@2060
    21
        CT_DoLog INFO "Stripping all toolchain executables"
linux@2060
    22
        CT_Pushd "${CT_PREFIX_DIR}"
titus@2089
    23
        for t in ar as c++ c++filt cpp dlltool dllwrap g++ gcc gcc-${CT_CC_VERSION} gcov gprof ld nm objcopy objdump ranlib readelf size strings strip addr2line windmc windres; do
titus@2089
    24
            [ -x bin/${CT_TARGET}-${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip ${strip_args} bin/${CT_TARGET}-${t}${CT_HOST_SUFFIX}
titus@2089
    25
            [ -x ${CT_TARGET}/bin/${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip ${strip_args} ${CT_TARGET}/bin/${t}${CT_HOST_SUFFIX}
linux@2060
    26
        done
linux@2060
    27
        CT_Popd
linux@2060
    28
        CT_Pushd "${CT_PREFIX_DIR}/libexec/gcc/${CT_TARGET}/${CT_CC_VERSION}"
titus@2089
    29
        for t in cc1 cc1plus collect2; do
titus@2089
    30
            [ -x ${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip ${strip_args} ${t}${CT_HOST_SUFFIX}
linux@2060
    31
        done
linux@2060
    32
        CT_Popd
linux@2060
    33
    fi
linux@2060
    34
yann@1225
    35
    if [ "${CT_BARE_METAL}" != "y" ]; then
yann@1225
    36
        CT_DoLog EXTRA "Installing the populate helper"
yann@1225
    37
        sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
yann@1225
    38
               -e 's|@@CT_install@@|'"${install}"'|g;'  \
yann@1225
    39
               -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
yann@1225
    40
               -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
yann@1225
    41
               -e 's|@@CT_make@@|'"${make}"'|g;'        \
yann@1225
    42
               -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
yann@1225
    43
               "${CT_LIB_DIR}/scripts/populate.in"      \
yann@1225
    44
               >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
yann@1225
    45
        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
yann@1225
    46
    fi
yann@1225
    47
yann@2034
    48
    if [ "${CT_LIBC_XLDD}" = "y" ]; then
yann@2034
    49
        CT_DoLog EXTRA "Installing a cross-ldd helper"
yann@2184
    50
        sed -r -e 's|@@CT_VERSION@@|'"${CT_VERSION}"'|g;'   \
yann@2184
    51
               -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
yann@2034
    52
               -e 's|@@CT_install@@|'"${install}"'|g;'  \
yann@2034
    53
               -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
yann@2034
    54
               -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
yann@2034
    55
               -e 's|@@CT_make@@|'"${make}"'|g;'        \
yann@2034
    56
               -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
yann@2034
    57
               "${CT_LIB_DIR}/scripts/xldd.in"          \
yann@2034
    58
               >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@2034
    59
        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@2034
    60
    fi
yann@2034
    61
yann@1225
    62
    # Create the aliases to the target tools
yann@1225
    63
    CT_DoLog EXTRA "Creating toolchain aliases"
yann@1225
    64
    CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1225
    65
    for t in "${CT_TARGET}-"*; do
yann@1225
    66
        if [ -n "${CT_TARGET_ALIAS}" ]; then
yann@1225
    67
            _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
yann@1225
    68
            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@1225
    69
        fi
yann@1225
    70
        if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
yann@1225
    71
            _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
yann@2004
    72
            if [ "${_t}" = "${t}" ]; then
yann@2004
    73
                CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
yann@2004
    74
            else
yann@2004
    75
                CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@2004
    76
            fi
yann@1225
    77
        fi
yann@1225
    78
    done
yann@1225
    79
    CT_Popd
yann@1225
    80
yann@1401
    81
    # If using the companion libraries, we need a wrapper
yann@1401
    82
    # that will set LD_LIBRARY_PATH approriately
yann@1495
    83
    if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
yann@1401
    84
        CT_DoLog EXTRA "Installing toolchain wrappers"
yann@1401
    85
        CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1402
    86
titus@1961
    87
        case "$CT_SYS_OS" in
titus@1961
    88
            Darwin|FreeBSD)
titus@1961
    89
                # wrapper does not work (when using readlink -m)
titus@1961
    90
                CT_DoLog WARN "Forcing usage of binary tool wrapper"
titus@1961
    91
                CT_TOOLS_WRAPPER="exec"
titus@1961
    92
                ;;
titus@1961
    93
        esac
yann@1493
    94
        # Install the wrapper
yann@1493
    95
        case "${CT_TOOLS_WRAPPER}" in
yann@1493
    96
            script)
yann@1493
    97
                CT_DoExecLog DEBUG install                              \
yann@1493
    98
                                   -m 0755                              \
yann@1493
    99
                                   "${CT_LIB_DIR}/scripts/wrapper.in"   \
yann@1493
   100
                                   ".${CT_TARGET}-wrapper"
yann@1493
   101
                ;;
yann@1493
   102
            exec)
yann@1518
   103
                CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
titus@1970
   104
                                   -Wall -Wextra -Werror                      \
titus@1970
   105
                                   -Os                                        \
yann@1518
   106
                                   "${CT_LIB_DIR}/scripts/wrapper.c"          \
yann@1518
   107
                                   -o ".${CT_TARGET}-wrapper"
titus@1970
   108
                if [ "${CT_DEBUG_CT}" != "y" ]; then
titus@1970
   109
                    # If not debugging crosstool-NG, strip the wrapper
titus@1970
   110
                    CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
titus@1970
   111
                fi
yann@1493
   112
                ;;
yann@1493
   113
        esac
yann@1402
   114
yann@1402
   115
        # Replace every tools with the wrapper
yann@1402
   116
        # Do it unconditionally, even for those tools that happen to be shell
yann@1402
   117
        # scripts, we don't know if they would in the end spawn a binary...
yann@1402
   118
        # Just skip symlinks
Yann@1408
   119
        for _t in "${CT_TARGET}-"*; do
titus@1955
   120
            if [ ! -L "${_t}" ]; then
yann@1413
   121
                CT_DoExecLog ALL mv "${_t}" ".${_t}"
Yann@1408
   122
                CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
yann@1402
   123
            fi
yann@1401
   124
        done
yann@1402
   125
yann@1402
   126
        # Get rid of the wrapper, we're using hardlinks
yann@1402
   127
        CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
yann@1401
   128
        CT_Popd
yann@1401
   129
    fi
yann@1401
   130
yann@1518
   131
    CT_DoLog EXTRA "Removing access to the build system tools"
yann@1518
   132
    CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
yann@1518
   133
yann@1225
   134
    # Remove the generated documentation files
yann@1225
   135
    if [ "${CT_REMOVE_DOCS}" = "y" ]; then
yann@1225
   136
        CT_DoLog EXTRA "Removing installed documentation"
yann@1225
   137
        CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
yann@1225
   138
        CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
yann@1225
   139
        CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
yann@1225
   140
    fi
yann@1225
   141
yann@1817
   142
    # Remove headers installed by native companion libraries
yann@1817
   143
    CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
yann@1817
   144
yann@2117
   145
    # Remove the lib* symlinks, now:
yann@2117
   146
    # The symlinks are needed only during the build process.
yann@2117
   147
    # The final gcc will still search those dirs, but will also search
yann@2117
   148
    # the standard lib/ dirs, so we can get rid of the symlinks
yann@2117
   149
    for d in                            \
yann@2117
   150
        "${CT_PREFIX_DIR}"              \
yann@2117
   151
        "${CT_SYSROOT_DIR}"             \
yann@2117
   152
        "${CT_SYSROOT_DIR}/usr"         \
yann@2117
   153
        "${CT_PREFIX_DIR}/${CT_TARGET}" \
yann@2117
   154
    ; do
yann@2117
   155
        CT_DoExecLog ALL rm -f "${d}/lib32"
yann@2117
   156
        CT_DoExecLog ALL rm -f "${d}/lib64"
yann@2117
   157
    done
yann@2117
   158
yann@2163
   159
    # Also remove the lib/ symlink out-side of sysroot
yann@2117
   160
    if [ "${CT_USE_SYSROOT}" = "y" ]; then
yann@2117
   161
        CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/${CT_TARGET}/lib"
yann@2117
   162
    fi
yann@2117
   163
yann@1225
   164
    CT_EndStep
yann@1225
   165
}