1 # This file contains crosstool-NG internal steps
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.
12 CT_DoStep INFO "Cleaning-up the toolchain's directory"
14 if [ "${CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
20 strip_args="--strip-all -v"
23 CT_DoLog INFO "Stripping all toolchain executables"
24 CT_Pushd "${CT_PREFIX_DIR}"
25 gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_GCC_VERSION}/gcc/BASE-VER" )
26 for _t in "bin/${CT_TARGET}-"* \
27 "${CT_TARGET}/bin/"* \
28 "libexec/gcc/${CT_TARGET}/${gcc_version}/"* \
29 "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \
31 _type="$( file "${_t}" |cut -d ' ' -f 2- )"
36 CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
43 if [ "${CT_BARE_METAL}" != "y" ]; then
44 CT_DoLog EXTRA "Installing the populate helper"
45 sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
46 -e 's|@@CT_install@@|'"${install}"'|g;' \
47 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
48 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
49 -e 's|@@CT_make@@|'"${make}"'|g;' \
50 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
51 "${CT_LIB_DIR}/scripts/populate.in" \
52 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
53 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
56 if [ "${CT_LIBC_XLDD}" = "y" ]; then
57 CT_DoLog EXTRA "Installing a cross-ldd helper"
58 sed -r -e 's|@@CT_VERSION@@|'"${CT_VERSION}"'|g;' \
59 -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
60 -e 's|@@CT_BITS@@|'"${CT_ARCH_BITNESS}"'|g;' \
61 -e 's|@@CT_install@@|'"${install}"'|g;' \
62 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
63 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
64 -e 's|@@CT_make@@|'"${make}"'|g;' \
65 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
66 "${CT_LIB_DIR}/scripts/xldd.in" \
67 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
68 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
71 # Create the aliases to the target tools
72 CT_DoLog EXTRA "Creating toolchain aliases"
73 CT_Pushd "${CT_PREFIX_DIR}/bin"
74 for t in "${CT_TARGET}-"*; do
75 if [ -n "${CT_TARGET_ALIAS}" ]; then
76 _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
77 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
79 if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
80 _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
81 if [ "${_t}" = "${t}" ]; then
82 CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
84 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
90 CT_DoLog EXTRA "Removing access to the build system tools"
91 CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
93 # Remove the generated documentation files
94 if [ "${CT_REMOVE_DOCS}" = "y" ]; then
95 CT_DoLog EXTRA "Removing installed documentation"
96 CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{,share/}{man,info}
97 CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{,share/}{man,info}
98 CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info}
101 # Remove the lib* symlinks, now:
102 # The symlinks are needed only during the build process.
103 # The final gcc will still search those dirs, but will also search
104 # the standard lib/ dirs, so we can get rid of the symlinks
107 "${CT_PREFIX_DIR}/${CT_TARGET}" \
109 CT_DoExecLog ALL rm -f "${d}/lib32"
110 CT_DoExecLog ALL rm -f "${d}/lib64"
113 # Also remove the lib/ symlink out-side of sysroot
114 if [ "${CT_USE_SYSROOT}" = "y" ]; then
115 CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/${CT_TARGET}/lib"