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=$( "./bin/${CT_TARGET}-gcc" -dumpversion )
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 # If using the companion libraries, we need a wrapper
91 # that will set LD_LIBRARY_PATH approriately
92 if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
93 CT_DoLog EXTRA "Installing toolchain wrappers"
94 CT_Pushd "${CT_PREFIX_DIR}/bin"
98 # wrapper does not work (when using readlink -m)
99 CT_DoLog WARN "Forcing usage of binary tool wrapper"
100 CT_TOOLS_WRAPPER="exec"
103 # Install the wrapper
104 case "${CT_TOOLS_WRAPPER}" in
106 CT_DoExecLog DEBUG install \
108 "${CT_LIB_DIR}/scripts/wrapper.in" \
109 ".${CT_TARGET}-wrapper"
112 CT_DoExecLog DEBUG "${CT_HOST}-gcc" \
113 -Wall -Wextra -Werror \
115 "${CT_LIB_DIR}/scripts/wrapper.c" \
116 -o ".${CT_TARGET}-wrapper"
117 if [ "${CT_DEBUG_CT}" != "y" ]; then
118 # If not debugging crosstool-NG, strip the wrapper
119 CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
124 # Replace every tools with the wrapper
125 # Do it unconditionally, even for those tools that happen to be shell
126 # scripts, we don't know if they would in the end spawn a binary...
128 for _t in "${CT_TARGET}-"*; do
129 if [ ! -L "${_t}" ]; then
130 CT_DoExecLog ALL mv "${_t}" ".${_t}"
131 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
135 # Get rid of the wrapper, we're using hardlinks
136 CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
140 CT_DoLog EXTRA "Removing access to the build system tools"
141 CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
143 # Remove the generated documentation files
144 if [ "${CT_REMOVE_DOCS}" = "y" ]; then
145 CT_DoLog EXTRA "Removing installed documentation"
146 CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{,share/}{man,info}
147 CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{,share/}{man,info}
148 CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info}
151 # Remove headers installed by native companion libraries
152 CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
154 # Remove the lib* symlinks, now:
155 # The symlinks are needed only during the build process.
156 # The final gcc will still search those dirs, but will also search
157 # the standard lib/ dirs, so we can get rid of the symlinks
160 "${CT_PREFIX_DIR}/${CT_TARGET}" \
162 CT_DoExecLog ALL rm -f "${d}/lib32"
163 CT_DoExecLog ALL rm -f "${d}/lib64"
166 # Also remove the lib/ symlink out-side of sysroot
167 if [ "${CT_USE_SYSROOT}" = "y" ]; then
168 CT_DoExecLog ALL rm -f "${CT_PREFIX_DIR}/${CT_TARGET}/lib"