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.
11 CT_DoStep INFO "Cleaning-up the toolchain's directory"
13 if [ "${CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
19 strip_args="--strip-all -v"
22 CT_DoLog INFO "Stripping all toolchain executables"
23 CT_Pushd "${CT_PREFIX_DIR}"
24 for _t in "bin/${CT_TARGET}-"* \
25 "${CT_TARGET}/bin/"* \
26 "libexec/gcc/${CT_TARGET}/${CT_CC_VERSION}/"* \
27 "libexec/gcc/${CT_TARGET}/${CT_CC_VERSION}/install-tools/"* \
29 _type="$( file "${_t}" |cut -d ' ' -f 2- )"
31 *"script text executable")
34 CT_DoExecLog ALL ${CT_HOST}-strip ${strip_args} "${_t}"
41 if [ "${CT_BARE_METAL}" != "y" ]; then
42 CT_DoLog EXTRA "Installing the populate helper"
43 sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
44 -e 's|@@CT_install@@|'"${install}"'|g;' \
45 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
46 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
47 -e 's|@@CT_make@@|'"${make}"'|g;' \
48 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
49 "${CT_LIB_DIR}/scripts/populate.in" \
50 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
51 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
54 if [ "${CT_LIBC_XLDD}" = "y" ]; then
55 CT_DoLog EXTRA "Installing a cross-ldd helper"
56 sed -r -e 's|@@CT_VERSION@@|'"${CT_VERSION}"'|g;' \
57 -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
58 -e 's|@@CT_BITS@@|'"${CT_ARCH_BITNESS}"'|g;' \
59 -e 's|@@CT_install@@|'"${install}"'|g;' \
60 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
61 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
62 -e 's|@@CT_make@@|'"${make}"'|g;' \
63 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
64 "${CT_LIB_DIR}/scripts/xldd.in" \
65 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
66 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
69 # Create the aliases to the target tools
70 CT_DoLog EXTRA "Creating toolchain aliases"
71 CT_Pushd "${CT_PREFIX_DIR}/bin"
72 for t in "${CT_TARGET}-"*; do
73 if [ -n "${CT_TARGET_ALIAS}" ]; then
74 _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
75 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
77 if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
78 _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
79 if [ "${_t}" = "${t}" ]; then
80 CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
82 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
88 # If using the companion libraries, we need a wrapper
89 # that will set LD_LIBRARY_PATH approriately
90 if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
91 CT_DoLog EXTRA "Installing toolchain wrappers"
92 CT_Pushd "${CT_PREFIX_DIR}/bin"
96 # wrapper does not work (when using readlink -m)
97 CT_DoLog WARN "Forcing usage of binary tool wrapper"
98 CT_TOOLS_WRAPPER="exec"
101 # Install the wrapper
102 case "${CT_TOOLS_WRAPPER}" in
104 CT_DoExecLog DEBUG install \
106 "${CT_LIB_DIR}/scripts/wrapper.in" \
107 ".${CT_TARGET}-wrapper"
110 CT_DoExecLog DEBUG "${CT_HOST}-gcc" \
111 -Wall -Wextra -Werror \
113 "${CT_LIB_DIR}/scripts/wrapper.c" \
114 -o ".${CT_TARGET}-wrapper"
115 if [ "${CT_DEBUG_CT}" != "y" ]; then
116 # If not debugging crosstool-NG, strip the wrapper
117 CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
122 # Replace every tools with the wrapper
123 # Do it unconditionally, even for those tools that happen to be shell
124 # scripts, we don't know if they would in the end spawn a binary...
126 for _t in "${CT_TARGET}-"*; do
127 if [ ! -L "${_t}" ]; then
128 CT_DoExecLog ALL mv "${_t}" ".${_t}"
129 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
133 # Get rid of the wrapper, we're using hardlinks
134 CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
138 CT_DoLog EXTRA "Removing access to the build system tools"
139 CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
141 # Remove the generated documentation files
142 if [ "${CT_REMOVE_DOCS}" = "y" ]; then
143 CT_DoLog EXTRA "Removing installed documentation"
144 CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{,share/}{man,info}
145 CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{,share/}{man,info}
146 CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{,share/}{man,info}
149 # Remove headers installed by native companion libraries
150 CT_DoForceRmdir "${CT_PREFIX_DIR}/include"
152 # Remove the lib* symlinks, now:
153 # The symlinks are needed only during the build process.
154 # The final gcc will still search those dirs, but will also search
155 # the standard lib/ dirs, so we can get rid of the symlinks
158 "${CT_SYSROOT_DIR}" \
159 "${CT_SYSROOT_DIR}/usr" \
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"