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}"
27 if [ "${CT_GDB_GDBSERVER}" = "y" ]; then
28 CT_DoExecLog ALL "${CT_TARGET}-strip" ${strip_args} \
29 "${CT_TARGET}/debug-root/usr/bin/gdbserver"
31 # We can not use the version in CT_CC_VERSION because
32 # of the Linaro stuff. So, harvest the version string
33 # directly from the gcc sources...
34 # All gcc 4.x seem to have the version in gcc/BASE-VER
35 # while version prior to 4.x have the version in gcc/version.c
36 # Of course, here is not the better place to do that...
37 if [ -f "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" ]; then
38 gcc_version=$( cat "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/BASE-VER" )
40 gcc_version=$( sed -r -e '/version_string/!d; s/^.+= "([^"]+)".*$/\1/;' \
41 "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/gcc/version.c" \
44 for _t in "bin/${CT_TARGET}-"* \
45 "${CT_TARGET}/bin/"* \
46 "libexec/gcc/${CT_TARGET}/${gcc_version}/"* \
47 "libexec/gcc/${CT_TARGET}/${gcc_version}/install-tools/"* \
49 _type="$( file "${_t}" |cut -d ' ' -f 2- )"
54 CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
61 if [ "${CT_BARE_METAL}" != "y" ]; then
62 CT_DoLog EXTRA "Installing the populate helper"
63 sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
64 -e 's|@@CT_install@@|'"${install}"'|g;' \
65 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
66 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
67 -e 's|@@CT_make@@|'"${make}"'|g;' \
68 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
69 "${CT_LIB_DIR}/scripts/populate.in" \
70 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
71 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
74 if [ "${CT_LIBC_XLDD}" = "y" ]; then
75 CT_DoLog EXTRA "Installing a cross-ldd helper"
76 sed -r -e 's|@@CT_VERSION@@|'"${CT_VERSION}"'|g;' \
77 -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
78 -e 's|@@CT_BITS@@|'"${CT_ARCH_BITNESS}"'|g;' \
79 -e 's|@@CT_install@@|'"${install}"'|g;' \
80 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
81 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
82 -e 's|@@CT_make@@|'"${make}"'|g;' \
83 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
84 "${CT_LIB_DIR}/scripts/xldd.in" \
85 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
86 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
89 # Create the aliases to the target tools
90 CT_DoLog EXTRA "Creating toolchain aliases"
91 CT_Pushd "${CT_PREFIX_DIR}/bin"
92 for t in "${CT_TARGET}-"*; do
93 if [ -n "${CT_TARGET_ALIAS}" ]; then
94 _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
95 CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
97 if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
98 _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
99 if [ "${_t}" = "${t}" ]; then
100 CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
102 CT_DoExecLog ALL ln -sfv "${t}" "${_t}"
108 CT_DoLog EXTRA "Removing access to the build system tools"
109 CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
111 # Remove the generated documentation files
112 if [ "${CT_REMOVE_DOCS}" = "y" ]; then
113 CT_DoLog EXTRA "Removing installed documentation"
114 CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{,share/}{man,info}
115 CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{,share/}{man,info}
116 CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info}
119 # Remove the lib* symlinks, now:
120 # The symlinks are needed only during the build process.
121 # The final gcc will still search those dirs, but will also search
122 # the standard lib/ dirs, so we can get rid of the symlinks
123 CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/lib32"
124 CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/lib64"