scripts/build/internals.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jul 03 01:15:28 2010 +0200 (2010-07-03)
changeset 2009 7e19c1de65cd
parent 1970 cdd761ad2d1a
child 2034 c3967b2c49b4
permissions -rw-r--r--
libc/uClibc: enable NPTL for snapshots

Recently, NPTL has matured a lot in uClibc, and more and more
people are interested to at least give it a try. So enable it.
     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             if [ "${_t}" = "${t}" ]; then
    35                 CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
    36             else
    37                 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    38             fi
    39         fi
    40     done
    41     CT_Popd
    42 
    43     # If using the companion libraries, we need a wrapper
    44     # that will set LD_LIBRARY_PATH approriately
    45     if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
    46         CT_DoLog EXTRA "Installing toolchain wrappers"
    47         CT_Pushd "${CT_PREFIX_DIR}/bin"
    48 
    49         case "$CT_SYS_OS" in
    50             Darwin|FreeBSD)
    51                 # wrapper does not work (when using readlink -m)
    52                 CT_DoLog WARN "Forcing usage of binary tool wrapper"
    53                 CT_TOOLS_WRAPPER="exec"
    54                 ;;
    55         esac
    56         # Install the wrapper
    57         case "${CT_TOOLS_WRAPPER}" in
    58             script)
    59                 CT_DoExecLog DEBUG install                              \
    60                                    -m 0755                              \
    61                                    "${CT_LIB_DIR}/scripts/wrapper.in"   \
    62                                    ".${CT_TARGET}-wrapper"
    63                 ;;
    64             exec)
    65                 CT_DoExecLog DEBUG "${CT_HOST}-gcc"                           \
    66                                    -Wall -Wextra -Werror                      \
    67                                    -Os                                        \
    68                                    "${CT_LIB_DIR}/scripts/wrapper.c"          \
    69                                    -o ".${CT_TARGET}-wrapper"
    70                 if [ "${CT_DEBUG_CT}" != "y" ]; then
    71                     # If not debugging crosstool-NG, strip the wrapper
    72                     CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
    73                 fi
    74                 ;;
    75         esac
    76 
    77         # Replace every tools with the wrapper
    78         # Do it unconditionally, even for those tools that happen to be shell
    79         # scripts, we don't know if they would in the end spawn a binary...
    80         # Just skip symlinks
    81         for _t in "${CT_TARGET}-"*; do
    82             if [ ! -L "${_t}" ]; then
    83                 CT_DoExecLog ALL mv "${_t}" ".${_t}"
    84                 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
    85             fi
    86         done
    87 
    88         # Get rid of the wrapper, we're using hardlinks
    89         CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
    90         CT_Popd
    91     fi
    92 
    93     CT_DoLog EXTRA "Removing access to the build system tools"
    94     CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
    95 
    96     # Remove the generated documentation files
    97     if [ "${CT_REMOVE_DOCS}" = "y" ]; then
    98         CT_DoLog EXTRA "Removing installed documentation"
    99         CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
   100         CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
   101         CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
   102     fi
   103 
   104     # Remove headers installed by native companion libraries
   105     CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
   106 
   107     CT_EndStep
   108 }