scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Jan 03 23:40:22 2011 +0100 (2011-01-03)
changeset 2267 7af68e6083aa
parent 2214 10d4f2bc227b
child 2301 a3818c3b03e0
permissions -rw-r--r--
libc-glibc: remove 2.3.6

This is an obsolete version which is no longer used by any sample (the only
user, the ia64 sample, has been removed).

It also makes the code path a bit complex, with twists just to accomodate
that version. Removing the version will make those twists go away, and
will ease commonalisation of glibc and eglibc in the future (hopefully!).

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