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.
9 CT_DoStep INFO "Cleaning-up the toolchain's directory"
11 if [ "${CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES}" = "y" ]; then
12 CT_DoLog INFO "Stripping all toolchain executables"
13 CT_Pushd "${CT_PREFIX_DIR}"
14 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
15 [ -x bin/${CT_TARGET}-${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip --strip-all -v bin/${CT_TARGET}-${t}${CT_HOST_SUFFIX}
16 [ -x ${CT_TARGET}/bin/${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip --strip-all -v ${CT_TARGET}/bin/${t}${CT_HOST_SUFFIX}
19 CT_Pushd "${CT_PREFIX_DIR}/libexec/gcc/${CT_TARGET}/${CT_CC_VERSION}"
20 for t in cc1 cc1plus collect2; do
21 [ -x ${t}${CT_HOST_SUFFIX} ] && ${CT_HOST}-strip --strip-all -v ${t}${CT_HOST_SUFFIX}
26 if [ "${CT_BARE_METAL}" != "y" ]; then
27 CT_DoLog EXTRA "Installing the populate helper"
28 sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
29 -e 's|@@CT_install@@|'"${install}"'|g;' \
30 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
31 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
32 -e 's|@@CT_make@@|'"${make}"'|g;' \
33 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
34 "${CT_LIB_DIR}/scripts/populate.in" \
35 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
36 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
39 if [ "${CT_LIBC_XLDD}" = "y" ]; then
40 CT_DoLog EXTRA "Installing a cross-ldd helper"
41 sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
42 -e 's|@@CT_install@@|'"${install}"'|g;' \
43 -e 's|@@CT_bash@@|'"${bash}"'|g;' \
44 -e 's|@@CT_grep@@|'"${grep}"'|g;' \
45 -e 's|@@CT_make@@|'"${make}"'|g;' \
46 -e 's|@@CT_sed@@|'"${sed}"'|g;' \
47 "${CT_LIB_DIR}/scripts/xldd.in" \
48 >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
49 CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-ldd"
52 # Create the aliases to the target tools
53 CT_DoLog EXTRA "Creating toolchain aliases"
54 CT_Pushd "${CT_PREFIX_DIR}/bin"
55 for t in "${CT_TARGET}-"*; do
56 if [ -n "${CT_TARGET_ALIAS}" ]; then
57 _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
58 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
60 if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
61 _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
62 if [ "${_t}" = "${t}" ]; then
63 CT_DoLog WARN "The sed expression '${CT_TARGET_ALIAS_SED_EXPR}' has no effect on '${t}'"
65 CT_DoExecLog ALL ln -sv "${t}" "${_t}"
71 # If using the companion libraries, we need a wrapper
72 # that will set LD_LIBRARY_PATH approriately
73 if [ "${CT_WRAPPER_NEEDED}" = "y" ]; then
74 CT_DoLog EXTRA "Installing toolchain wrappers"
75 CT_Pushd "${CT_PREFIX_DIR}/bin"
79 # wrapper does not work (when using readlink -m)
80 CT_DoLog WARN "Forcing usage of binary tool wrapper"
81 CT_TOOLS_WRAPPER="exec"
85 case "${CT_TOOLS_WRAPPER}" in
87 CT_DoExecLog DEBUG install \
89 "${CT_LIB_DIR}/scripts/wrapper.in" \
90 ".${CT_TARGET}-wrapper"
93 CT_DoExecLog DEBUG "${CT_HOST}-gcc" \
94 -Wall -Wextra -Werror \
96 "${CT_LIB_DIR}/scripts/wrapper.c" \
97 -o ".${CT_TARGET}-wrapper"
98 if [ "${CT_DEBUG_CT}" != "y" ]; then
99 # If not debugging crosstool-NG, strip the wrapper
100 CT_DoExecLog DEBUG "${CT_HOST}-strip" ".${CT_TARGET}-wrapper"
105 # Replace every tools with the wrapper
106 # Do it unconditionally, even for those tools that happen to be shell
107 # scripts, we don't know if they would in the end spawn a binary...
109 for _t in "${CT_TARGET}-"*; do
110 if [ ! -L "${_t}" ]; then
111 CT_DoExecLog ALL mv "${_t}" ".${_t}"
112 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
116 # Get rid of the wrapper, we're using hardlinks
117 CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
121 CT_DoLog EXTRA "Removing access to the build system tools"
122 CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
124 # Remove the generated documentation files
125 if [ "${CT_REMOVE_DOCS}" = "y" ]; then
126 CT_DoLog EXTRA "Removing installed documentation"
127 CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
128 CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
129 CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
132 # Remove headers installed by native companion libraries
133 CT_DoForceRmdir "${CT_PREFIX_DIR}/include"