newlib-nano: Add option to copy libs into target

Add an option that will install a copy of newlib-nano lib*.a file in
the target dir but renamed with a nano.a suffix (eg: libc_nano.a) as
some default nano.spec files from newlib expect this setup.

Additionally the newlib-nano version of newlib.h will get copied to
include/newlib-nano/newlib.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2021-04-15 09:31:08 -05:00
parent 2816a97a25
commit 8e99639419
2 changed files with 36 additions and 0 deletions

View File

@ -18,6 +18,17 @@ config NEWLIB_NANO_GCC_LIBSTDCXX
This option compiles an additional target libstdc++ for use with
newlib-nano.
config NEWLIB_NANO_INSTALL_IN_TARGET
bool
prompt "Additionally install newlib-nano libs into TARGET dir"
help
This option will install a copy of newlib-nano lib*.a file in the target
dir but renamed with a nano.a suffix (eg: libc_nano.a) as some default
nano.spec files from newlib expect this setup.
Additionally the newlib-nano version of newlib.h will get copied to
include/newlib-nano/newlib.h.
# maybe older versions of newlib will support it too, but this
# needs to be checked
config NEWLIB_NANO_CXA_ATEXIT

View File

@ -216,6 +216,31 @@ EOF
CT_EndStep
do_cc_libstdcxx_newlib_nano
if [ "${CT_NEWLIB_NANO_INSTALL_IN_TARGET}" = "y" ]; then
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano"
CT_DoExecLog ALL cp -f "${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include/newlib.h" \
"${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano/newlib.h"
CT_IterateMultilibs newlib_nano_copy_multilibs copylibs
fi
}
newlib_nano_copy_multilibs()
{
local nano_lib_dir="${CT_PREFIX_DIR}/newlib-nano"
local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count
for arg in "$@"; do
eval "${arg// /\\ }"
done
for lib_a in "${nano_lib_dir}/${CT_TARGET}/lib/${multi_dir}/"*.a; do
if [ -f ${lib_a} ] && [ ! -L ${lib_a} ]; then
_f=$(basename "${lib_a}")
CT_DoExecLog ALL cp -f "${lib_a}" \
"${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/${_f%.*}_nano.a"
fi
done
}
fi