yann@1225: # This file contains crosstool-NG internal steps yann@1225: yann@1225: # This step is called once all components were built, to remove yann@1225: # un-wanted files, to add tuple aliases, and to add the final yann@1225: # crosstool-NG-provided files. yann@1225: do_finish() { yann@1401: local _t yann@1401: yann@1225: CT_DoStep INFO "Cleaning-up the toolchain's directory" yann@1225: yann@1225: if [ "${CT_BARE_METAL}" != "y" ]; then yann@1225: CT_DoLog EXTRA "Installing the populate helper" yann@1225: sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \ yann@1225: -e 's|@@CT_install@@|'"${install}"'|g;' \ yann@1225: -e 's|@@CT_bash@@|'"${bash}"'|g;' \ yann@1225: -e 's|@@CT_grep@@|'"${grep}"'|g;' \ yann@1225: -e 's|@@CT_make@@|'"${make}"'|g;' \ yann@1225: -e 's|@@CT_sed@@|'"${sed}"'|g;' \ yann@1225: "${CT_LIB_DIR}/scripts/populate.in" \ yann@1225: >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate" yann@1225: CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate" yann@1225: fi yann@1225: yann@1225: # Create the aliases to the target tools yann@1225: CT_DoLog EXTRA "Creating toolchain aliases" yann@1225: CT_Pushd "${CT_PREFIX_DIR}/bin" yann@1225: for t in "${CT_TARGET}-"*; do yann@1225: if [ -n "${CT_TARGET_ALIAS}" ]; then yann@1225: _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;') yann@1225: CT_DoExecLog ALL ln -sv "${t}" "${_t}" yann@1225: fi yann@1225: if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then yann@1225: _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}") yann@1225: CT_DoExecLog ALL ln -sv "${t}" "${_t}" yann@1225: fi yann@1225: done yann@1225: CT_Popd yann@1225: yann@1401: # If using the companion libraries, we need a wrapper yann@1401: # that will set LD_LIBRARY_PATH approriately yann@1495: if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then yann@1401: CT_DoLog EXTRA "Installing toolchain wrappers" yann@1401: CT_Pushd "${CT_PREFIX_DIR}/bin" yann@1402: yann@1493: # Install the wrapper yann@1493: case "${CT_TOOLS_WRAPPER}" in yann@1493: script) yann@1493: CT_DoExecLog DEBUG install \ yann@1493: -m 0755 \ yann@1493: "${CT_LIB_DIR}/scripts/wrapper.in" \ yann@1493: ".${CT_TARGET}-wrapper" yann@1493: ;; yann@1493: exec) yann@1493: _t="-s" yann@1493: if [ "${CT_DEBUG_CT}" = "y" ]; then yann@1493: _t="" # If debugging crosstool-NG, don't strip the wrapper yann@1493: fi yann@1518: CT_DoExecLog DEBUG "${CT_HOST}-gcc" \ yann@1518: -Wall -Wextra -Wunreachable-code -Werror \ yann@1518: -O3 -static ${_t} \ yann@1518: "${CT_LIB_DIR}/scripts/wrapper.c" \ yann@1518: -o ".${CT_TARGET}-wrapper" yann@1493: ;; yann@1493: esac yann@1402: yann@1402: # Replace every tools with the wrapper yann@1402: # Do it unconditionally, even for those tools that happen to be shell yann@1402: # scripts, we don't know if they would in the end spawn a binary... yann@1402: # Just skip symlinks Yann@1408: for _t in "${CT_TARGET}-"*; do Yann@1408: if [ "$( LANG=C stat -c '%F' "${_t}" )" != "symbolic link" ]; then yann@1413: CT_DoExecLog ALL mv "${_t}" ".${_t}" Yann@1408: CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}" yann@1402: fi yann@1401: done yann@1402: yann@1402: # Get rid of the wrapper, we're using hardlinks yann@1402: CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper" yann@1401: CT_Popd yann@1401: fi yann@1401: yann@1518: CT_DoLog EXTRA "Removing access to the build system tools" yann@1518: CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools" yann@1518: yann@1225: # Remove the generated documentation files yann@1225: if [ "${CT_REMOVE_DOCS}" = "y" ]; then yann@1225: CT_DoLog EXTRA "Removing installed documentation" yann@1225: CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info} yann@1225: CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info} yann@1225: CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info} yann@1225: fi yann@1225: yann@1817: # Remove headers installed by native companion libraries yann@1817: CT_DoForceRmdir "${CT_PREFIX_DIR}/include" yann@1817: yann@1225: CT_EndStep yann@1225: }