scripts/build/internals.sh
author Titus von Boxberg <titus@v9g.de>
Sat May 22 22:01:18 2010 +0200 (2010-05-22)
changeset 1970 cdd761ad2d1a
parent 1961 e0619b242cb6
child 2004 5d6d3c28a658
permissions -rw-r--r--
scripts/build/internals.sh: compile wrapper with portable options.

static linking is not possible on MacOS, and unnessecary on other systems.
The old optimization and warning flags crash the gcc on MacOS
and (imho) are a bit overdone for this software.
     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     if [ "${CT_BARE_METAL}" != "y" ]; then
    12         CT_DoLog EXTRA "Installing the populate helper"
    13         sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
    14                -e 's|@@CT_install@@|'"${install}"'|g;'  \
    15                -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
    16                -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
    17                -e 's|@@CT_make@@|'"${make}"'|g;'        \
    18                -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
    19                "${CT_LIB_DIR}/scripts/populate.in"      \
    20                >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    21         CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    22     fi
    23 
    24     # Create the aliases to the target tools
    25     CT_DoLog EXTRA "Creating toolchain aliases"
    26     CT_Pushd "${CT_PREFIX_DIR}/bin"
    27     for t in "${CT_TARGET}-"*; do
    28         if [ -n "${CT_TARGET_ALIAS}" ]; then
    29             _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
    30             CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    31         fi
    32         if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
    33             _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
    34             CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    35         fi
    36     done
    37     CT_Popd
    38 
    39     # If using the companion libraries, we need a wrapper
    40     # that will set LD_LIBRARY_PATH approriately
    41     if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
    42         CT_DoLog EXTRA "Installing toolchain wrappers"
    43         CT_Pushd "${CT_PREFIX_DIR}/bin"
    44 
    45         case "$CT_SYS_OS" in
    46             Darwin|FreeBSD)
    47                 # wrapper does not work (when using readlink -m)
    48                 CT_DoLog WARN "Forcing usage of binary tool wrapper"
    49                 CT_TOOLS_WRAPPER="exec"
    50                 ;;
    51         esac
    52         # Install the wrapper
    53         case "${CT_TOOLS_WRAPPER}" in
    54             script)
    55                 CT_DoExecLog DEBUG install                              \
    56                                    -m 0755                              \
    57                                    "${CT_LIB_DIR}/scripts/wrapper.in"   \
    58                                    ".${CT_TARGET}-wrapper"
    59                 ;;
    60             exec)
    61                 CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
    62                                    -Wall -Wextra -Werror                      \
    63                                    -Os                                        \
    64                                    "${CT_LIB_DIR}/scripts/wrapper.c"          \
    65                                    -o ".${CT_TARGET}-wrapper"
    66                 if [ "${CT_DEBUG_CT}" != "y" ]; then
    67                     # If not debugging crosstool-NG, strip the wrapper
    68                     CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
    69                 fi
    70                 ;;
    71         esac
    72 
    73         # Replace every tools with the wrapper
    74         # Do it unconditionally, even for those tools that happen to be shell
    75         # scripts, we don't know if they would in the end spawn a binary...
    76         # Just skip symlinks
    77         for _t in "${CT_TARGET}-"*; do
    78             if [ ! -L "${_t}" ]; then
    79                 CT_DoExecLog ALL mv "${_t}" ".${_t}"
    80                 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
    81             fi
    82         done
    83 
    84         # Get rid of the wrapper, we're using hardlinks
    85         CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
    86         CT_Popd
    87     fi
    88 
    89     CT_DoLog EXTRA "Removing access to the build system tools"
    90     CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
    91 
    92     # Remove the generated documentation files
    93     if [ "${CT_REMOVE_DOCS}" = "y" ]; then
    94         CT_DoLog EXTRA "Removing installed documentation"
    95         CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
    96         CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
    97         CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
    98     fi
    99 
   100     # Remove headers installed by native companion libraries
   101     CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
   102 
   103     CT_EndStep
   104 }