scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Aug 23 14:32:16 2010 +0200 (2010-08-23)
changeset 2100 f9fcfc002c8a
parent 2060 51e4597b07fc
child 2117 24aacb93191d
permissions -rw-r--r--
debug/gdb: install dependable libs in a generic target static libs dir

For now, ncurses is the only dependable target library built for gdb.
But expat is coming, and there's no reason to install each library in
its own place.

So, install ncurses in a generic directory, where other dependable
libraries can be installed as well.

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@2034
    50
        sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
yann@2034
    51
               -e 's|@@CT_install@@|'"${install}"'|g;'  \
yann@2034
    52
               -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
yann@2034
    53
               -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
yann@2034
    54
               -e 's|@@CT_make@@|'"${make}"'|g;'        \
yann@2034
    55
               -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
yann@2034
    56
               "${CT_LIB_DIR}/scripts/xldd.in"          \
yann@2034
    57
               >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@2034
    58
        CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
yann@2034
    59
    fi
yann@2034
    60
yann@1225
    61
    # Create the aliases to the target tools
yann@1225
    62
    CT_DoLog EXTRA "Creating toolchain aliases"
yann@1225
    63
    CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1225
    64
    for t in "${CT_TARGET}-"*; do
yann@1225
    65
        if [ -n "${CT_TARGET_ALIAS}" ]; then
yann@1225
    66
            _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
yann@1225
    67
            CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@1225
    68
        fi
yann@1225
    69
        if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
yann@1225
    70
            _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
yann@2004
    71
            if [ "${_t}" = "${t}" ]; then
yann@2004
    72
                CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
yann@2004
    73
            else
yann@2004
    74
                CT_DoExecLog ALL ln -sv "${t}" "${_t}"
yann@2004
    75
            fi
yann@1225
    76
        fi
yann@1225
    77
    done
yann@1225
    78
    CT_Popd
yann@1225
    79
yann@1401
    80
    # If using the companion libraries, we need a wrapper
yann@1401
    81
    # that will set LD_LIBRARY_PATH approriately
yann@1495
    82
    if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
yann@1401
    83
        CT_DoLog EXTRA "Installing toolchain wrappers"
yann@1401
    84
        CT_Pushd "${CT_PREFIX_DIR}/bin"
yann@1402
    85
titus@1961
    86
        case "$CT_SYS_OS" in
titus@1961
    87
            Darwin|FreeBSD)
titus@1961
    88
                # wrapper does not work (when using readlink -m)
titus@1961
    89
                CT_DoLog WARN "Forcing usage of binary tool wrapper"
titus@1961
    90
                CT_TOOLS_WRAPPER="exec"
titus@1961
    91
                ;;
titus@1961
    92
        esac
yann@1493
    93
        # Install the wrapper
yann@1493
    94
        case "${CT_TOOLS_WRAPPER}" in
yann@1493
    95
            script)
yann@1493
    96
                CT_DoExecLog DEBUG install                              \
yann@1493
    97
                                   -m 0755                              \
yann@1493
    98
                                   "${CT_LIB_DIR}/scripts/wrapper.in"   \
yann@1493
    99
                                   ".${CT_TARGET}-wrapper"
yann@1493
   100
                ;;
yann@1493
   101
            exec)
yann@1518
   102
                CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
titus@1970
   103
                                   -Wall -Wextra -Werror                      \
titus@1970
   104
                                   -Os                                        \
yann@1518
   105
                                   "${CT_LIB_DIR}/scripts/wrapper.c"          \
yann@1518
   106
                                   -o ".${CT_TARGET}-wrapper"
titus@1970
   107
                if [ "${CT_DEBUG_CT}" != "y" ]; then
titus@1970
   108
                    # If not debugging crosstool-NG, strip the wrapper
titus@1970
   109
                    CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
titus@1970
   110
                fi
yann@1493
   111
                ;;
yann@1493
   112
        esac
yann@1402
   113
yann@1402
   114
        # Replace every tools with the wrapper
yann@1402
   115
        # Do it unconditionally, even for those tools that happen to be shell
yann@1402
   116
        # scripts, we don't know if they would in the end spawn a binary...
yann@1402
   117
        # Just skip symlinks
Yann@1408
   118
        for _t in "${CT_TARGET}-"*; do
titus@1955
   119
            if [ ! -L "${_t}" ]; then
yann@1413
   120
                CT_DoExecLog ALL mv "${_t}" ".${_t}"
Yann@1408
   121
                CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
yann@1402
   122
            fi
yann@1401
   123
        done
yann@1402
   124
yann@1402
   125
        # Get rid of the wrapper, we're using hardlinks
yann@1402
   126
        CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
yann@1401
   127
        CT_Popd
yann@1401
   128
    fi
yann@1401
   129
yann@1518
   130
    CT_DoLog EXTRA "Removing access to the build system tools"
yann@1518
   131
    CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
yann@1518
   132
yann@1225
   133
    # Remove the generated documentation files
yann@1225
   134
    if [ "${CT_REMOVE_DOCS}" = "y" ]; then
yann@1225
   135
        CT_DoLog EXTRA "Removing installed documentation"
yann@1225
   136
        CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
yann@1225
   137
        CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
yann@1225
   138
        CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
yann@1225
   139
    fi
yann@1225
   140
yann@1817
   141
    # Remove headers installed by native companion libraries
yann@1817
   142
    CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
yann@1817
   143
yann@1225
   144
    CT_EndStep
yann@1225
   145
}