scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Sep 04 17:27:16 2009 +0200 (2009-09-04)
changeset 1512 439a6b292917
parent 1495 2542421e3321
child 1518 ecf0e1c4f2f2
permissions -rw-r--r--
TODO: update

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