diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build/libc/newlib.sh | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh index 6ae579ba..0a87581e 100644 --- a/scripts/build/libc/newlib.sh +++ b/scripts/build/libc/newlib.sh @@ -66,16 +66,6 @@ do_libc() { extra_config+=("--disable-multilib") fi - if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then - newlib_opts+=( "--enable-newlib-io-c99-formats" ) - else - newlib_opts+=( "--disable-newlib-io-c99-formats" ) - fi - if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then - newlib_opts+=( "--enable-newlib-io-long-long" ) - else - newlib_opts+=( "--disable-newlib-io-long-long" ) - fi if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then newlib_opts+=( "--enable-newlib-io-float" ) if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then @@ -87,17 +77,47 @@ do_libc() { newlib_opts+=( "--disable-newlib-io-float" ) newlib_opts+=( "--disable-newlib-io-long-double" ) fi + if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then newlib_opts+=( "--disable-newlib-supplied-syscalls" ) else newlib_opts+=( "--enable-newlib-supplied-syscalls" ) fi - if [ "${CT_LIBC_NEWLIB_NANO_MALLOC}" = "y" ]; then - newlib_opts+=( "--enable-newlib-nano-malloc" ) - fi - if [ "${CT_LIBC_NEWLIB_NANO_FORMATTED_IO}" = "y" ]; then - newlib_opts+=( "--enable-newlib-nano-formatted-io" ) - fi + + yn_args="IO_POS_ARGS:newlib-io-pos-args +IO_C99FMT:newlib-io-c99-formats +IO_LL:newlib-io-long-long +NEWLIB_REGISTER_FINI:newlib-register-fini +NANO_MALLOC:newlib-nano-malloc +NANO_FORMATTED_IO:newlib-nano-formatted-io +ATEXIT_DYNAMIC_ALLOC:atexit-dynamic-alloc +GLOBAL_ATEXIT:newlib-global-atexit +LITE_EXIT:lite-exit +REENT_SMALL:reent-small +MULTITHREAD:multithread +WIDE_ORIENT:newlib-wide-orient +UNBUF_STREAM_OPT:unbuf-stream-opt +ENABLE_TARGET_OPTSPACE:target-optspace + " + + for ynarg in $yn_args; do + var="CT_LIBC_NEWLIB_${ynarg%:*}" + eval var=\$${var} + argument=${ynarg#*:} + + + if [ "${var}" = "y" ]; then + newlib_opts+=( "--enable-$argument" ) + else + newlib_opts+=( "--disable-$argument" ) + fi + done + + [ "${CT_LIBC_NEWLIB_EXTRA_SECTIONS}" = "y" ] && \ + CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -ffunction-sections -fdata-sections" + + [ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \ + CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto" [ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace") @@ -108,16 +128,16 @@ do_libc() { # build : not used # host : the machine building newlib # target : the machine newlib runs on - CT_DoExecLog CFG \ - CC_FOR_BUILD="${CT_BUILD}-gcc" \ - CFLAGS_FOR_TARGET="${cflags_for_target}" \ - AR=${CT_TARGET}-ar \ - RANLIB=${CT_TARGET}-ranlib \ - "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \ - --host=${CT_BUILD} \ - --target=${CT_TARGET} \ - --prefix=${CT_PREFIX_DIR} \ - "${newlib_opts[@]}" \ + CT_DoExecLog CFG \ + CC_FOR_BUILD="${CT_BUILD}-gcc" \ + CFLAGS_FOR_TARGET="${cflags_for_target}" \ + AR_FOR_TARGET="`which ${CT_TARGET}-gcc-ar`" \ + RANLIB_FOR_TARGET="`which ${CT_TARGET}-gcc-ranlib`" \ + "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \ + --host=${CT_BUILD} \ + --target=${CT_TARGET} \ + --prefix=${CT_PREFIX_DIR} \ + "${newlib_opts[@]}" \ "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}" CT_DoLog EXTRA "Building C library" |