diff --git a/config/comp_libs/newlib-nano.in b/config/comp_libs/newlib-nano.in index 0138a7fb..0d80c893 100644 --- a/config/comp_libs/newlib-nano.in +++ b/config/comp_libs/newlib-nano.in @@ -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 diff --git a/scripts/build/companion_libs/350-newlib_nano.sh b/scripts/build/companion_libs/350-newlib_nano.sh index 28992c0e..16fb417c 100644 --- a/scripts/build/companion_libs/350-newlib_nano.sh +++ b/scripts/build/companion_libs/350-newlib_nano.sh @@ -202,7 +202,7 @@ ENABLE_TARGET_OPTSPACE:target-optspace -isystem ${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include %(newlib_nano_cpp) *cc1plus: --idirafter ${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include %(newlib_nano_cc1plus) +-idirafter ${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/include %(newlib_nano_cc1plus) *link: -L${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib/%M -L${CT_PREFIX_DIR}/newlib-nano/${CT_TARGET}/lib @@ -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