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 titus@2089: local strip_args yann@1401: yann@1225: CT_DoStep INFO "Cleaning-up the toolchain's directory" yann@1225: linux@2060: if [ "${CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES}" = "y" ]; then titus@2089: case "$CT_HOST" in titus@2089: *darwin*) titus@2089: strip_args="" titus@2089: ;; titus@2089: *) titus@2089: strip_args="--strip-all -v" titus@2089: ;; titus@2089: esac linux@2060: CT_DoLog INFO "Stripping all toolchain executables" linux@2060: CT_Pushd "${CT_PREFIX_DIR}" titus@2089: 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: [ -x bin/${CT_TARGET}-${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip ${strip_args} bin/${CT_TARGET}-${t}${CT_HOST_SUFFIX} titus@2089: [ -x ${CT_TARGET}/bin/${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip ${strip_args} ${CT_TARGET}/bin/${t}${CT_HOST_SUFFIX} linux@2060: done linux@2060: CT_Popd linux@2060: CT_Pushd "${CT_PREFIX_DIR}/libexec/gcc/${CT_TARGET}/${CT_CC_VERSION}" titus@2089: for t in cc1 cc1plus collect2; do titus@2089: [ -x ${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip ${strip_args} ${t}${CT_HOST_SUFFIX} linux@2060: done linux@2060: CT_Popd linux@2060: fi linux@2060: 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@2034: if [ "${CT_LIBC_XLDD}" = "y" ]; then yann@2034: CT_DoLog EXTRA "Installing a cross-ldd helper" yann@2184: sed -r -e 's|@@CT_VERSION@@|'"${CT_VERSION}"'|g;' \ yann@2184: -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \ yann@2034: -e 's|@@CT_install@@|'"${install}"'|g;' \ yann@2034: -e 's|@@CT_bash@@|'"${bash}"'|g;' \ yann@2034: -e 's|@@CT_grep@@|'"${grep}"'|g;' \ yann@2034: -e 's|@@CT_make@@|'"${make}"'|g;' \ yann@2034: -e 's|@@CT_sed@@|'"${sed}"'|g;' \ yann@2034: "${CT_LIB_DIR}/scripts/xldd.in" \ yann@2034: >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd" yann@2034: CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd" yann@2034: fi yann@2034: 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@2004: if [ "${_t}" = "${t}" ]; then yann@2004: CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'" yann@2004: else yann@2004: CT_DoExecLog ALL ln -sv "${t}" "${_t}" yann@2004: fi 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: titus@1961: case "$CT_SYS_OS" in titus@1961: Darwin|FreeBSD) titus@1961: # wrapper does not work (when using readlink -m) titus@1961: CT_DoLog WARN "Forcing usage of binary tool wrapper" titus@1961: CT_TOOLS_WRAPPER="exec" titus@1961: ;; titus@1961: esac 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@1518: CT_DoExecLog DEBUG "${CT_HOST}-gcc" \ titus@1970: -Wall -Wextra -Werror \ titus@1970: -Os \ yann@1518: "${CT_LIB_DIR}/scripts/wrapper.c" \ yann@1518: -o ".${CT_TARGET}-wrapper" titus@1970: if [ "${CT_DEBUG_CT}" != "y" ]; then titus@1970: # If not debugging crosstool-NG, strip the wrapper titus@1970: CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper" titus@1970: fi 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 titus@1955: if [ ! -L "${_t}" ]; 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@2254: CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{,share/}{man,info} yann@2254: CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{,share/}{man,info} yann@2254: CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{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@2117: # Remove the lib* symlinks, now: yann@2117: # The symlinks are needed only during the build process. yann@2117: # The final gcc will still search those dirs, but will also search yann@2117: # the standard lib/ dirs, so we can get rid of the symlinks yann@2117: for d in \ yann@2117: "${CT_PREFIX_DIR}" \ yann@2117: "${CT_SYSROOT_DIR}" \ yann@2117: "${CT_SYSROOT_DIR}/usr" \ yann@2117: "${CT_PREFIX_DIR}/${CT_TARGET}" \ yann@2117: ; do yann@2117: CT_DoExecLog ALL rm -f "${d}/lib32" yann@2117: CT_DoExecLog ALL rm -f "${d}/lib64" yann@2117: done yann@2117: yann@2163: # Also remove the lib/ symlink out-side of sysroot yann@2117: if [ "${CT_USE_SYSROOT}" = "y" ]; then yann@2117: CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/${CT_TARGET}/lib" yann@2117: fi yann@2117: yann@1225: CT_EndStep yann@1225: }