summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_world_install.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/ptxd_make_world_install.sh')
-rw-r--r--scripts/lib/ptxd_make_world_install.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_world_install.sh b/scripts/lib/ptxd_make_world_install.sh
index 0e02c5d..28a9e72 100644
--- a/scripts/lib/ptxd_make_world_install.sh
+++ b/scripts/lib/ptxd_make_world_install.sh
@@ -21,6 +21,11 @@ ptxd_make_world_install_pack() {
return
fi &&
+ # created during install but not needed here
+ if [ "${pkg_type}" = "cross" ]; then
+ rm "${pkg_pkg_dir}/lib64"
+ fi &&
+
# remove empty dirs
test \! -e "${pkg_pkg_dir}" || \
find "${pkg_pkg_dir}" -depth -type d -print0 | xargs -r -0 -- \
@@ -37,5 +42,79 @@ ptxd_make_world_install_pack() {
# remove la files. They are not needed
find "${pkg_pkg_dir}" \( -type f -o -type l \) -name "*.la" -print0 | xargs -r -0 rm &&
check_pipe_status
+
+ # ensure PATH is set correctly to find cross tools if necessary
+ eval "${pkg_path}"
+
+ local ptxconf_gnu_target="$(ptxd_get_ptxconf PTXCONF_GNU_TARGET)"
+ local ptxconf_prefix="$(ptxd_get_ptxconf PTXCONF_PREFIX_CROSS)"
+ if [ "${pkg_type}" = "cross" ]; then
+ local -a host_dirs
+ for dir in \
+ "${pkg_pkg_dir}${ptxconf_prefix}/lib" \
+ "${pkg_pkg_dir}${ptxconf_prefix}/libexec" \
+ "${pkg_pkg_dir}${ptxconf_prefix}/bin" \
+ "${pkg_pkg_dir}${ptxconf_prefix}/${ptxconf_gnu_target}/bin"; do
+ if [ -d "${dir}" ]; then
+ host_dirs[${#host_dirs[*]}]="${dir}"
+ fi
+ done
+ if [ ${#host_dirs[*]} -eq 0 ]; then
+ ptxd_bailout "cross package '${pkg_pkg}' not properly installed"
+ fi
+ # remove all static host libraries
+ find "${host_dirs[@]}" \
+ -wholename "${pkg_pkg_dir}${ptxconf_prefix}/lib/gcc" -prune -o \
+ -type f -name "*.a" -print0 | xargs -0 -r rm -v
+ fi
+ local -a strip_dirs
+ case "${pkg_type}" in
+ target)
+ strip_dirs=( "${pkg_pkg_dir}" )
+ ;;
+ cross)
+ if [ -d "${pkg_pkg_dir}${ptxconf_prefix}/lib/gcc" ]; then
+ strip_dirs[${#strip_dirs[*]}]="${pkg_pkg_dir}${ptxconf_prefix}/lib/gcc"
+ fi
+ if [ -d "${pkg_pkg_dir}${ptxconf_prefix}/${ptxconf_gnu_target}/lib" ]; then
+ strip_dirs[${#strip_dirs[*]}]="${pkg_pkg_dir}${ptxconf_prefix}/${ptxconf_gnu_target}/lib"
+ fi
+ ;;
+ esac
+ if [ ${#strip_dirs[*]} -gt 0 ]; then
+ local objcopy="$(ptxd_get_ptxconf PTXCONF_COMPILER_PREFIX)objcopy"
+ find "${strip_dirs[@]}" \
+ -wholename "${pkg_pkg_dir}${ptxconf_prefix}/lib/gcc/${ptxconf_gnu_target}/*/plugin" -prune -o \
+ -name "*.py" -prune -o \
+ -type f ! -type l \
+ \( -executable -o -name "*.so*" -o -name "*.a" -o -name "*.o" \) -print \
+ | while read f; do
+ # ignore ld scripts
+ case "$(file -b "${f}")" in
+ *ASCII*|*script*) continue ;;
+ esac
+ # size compromise: compressed debug sections in static libraries are too large
+ if [[ "${pkg_type}" = "target" && "${f}" =~ \.a$ ]]; then
+ echo "Stripping $(ptxd_print_path "${f}") ..."
+ ${objcopy} \
+ --preserve-dates --strip-debug --keep-file-symbols \
+ "${f}"
+ else
+ # compress debug sections and remove any bogus paths
+ echo "Compressing $(ptxd_print_path "${f}") ..."
+ ${objcopy} \
+ --wildcard \
+ --strip-symbol=${pkg_pkg_dir}${ptxconf_prefix}/usr/lib/*.o \
+ --strip-symbol=${PTXDIST_SYSROOT_TARGET}/usr/lib/*.o \
+ --strip-symbol=${pkg_build_dir}/*.o \
+ --strip-symbol=${pkg_build_dir}/*.os \
+ --preserve-dates --compress-debug-sections \
+ "${f}" &&
+ if [[ "$(file "${f}")" =~ "dynamically linked" ]]; then
+ chrpath -d "${f}"
+ fi
+ fi || exit 1
+ done
+ fi
}
export -f ptxd_make_world_install_pack