2009-05-22 14:46:18 +00:00
|
|
|
# This file adds functions to build the Newlib C library
|
2009-06-14 20:43:33 +00:00
|
|
|
# Copyright 2009 DoréDevelopment
|
2009-05-22 14:46:18 +00:00
|
|
|
# Licensed under the GPL v2. See COPYING in the root of this package
|
|
|
|
#
|
2009-06-14 20:43:33 +00:00
|
|
|
# Edited by Martin Lund <mgl@doredevelopment.dk>
|
2009-05-22 14:46:18 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
do_libc_get() {
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_Fetch NEWLIB
|
2009-05-22 14:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_libc_extract() {
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_ExtractPatch NEWLIB
|
2009-05-22 14:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_libc_start_files() {
|
2013-03-12 05:14:38 +00:00
|
|
|
CT_DoStep INFO "Installing C library headers & start files"
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." \
|
2013-03-12 05:14:38 +00:00
|
|
|
"${CT_HEADERS_DIR}"
|
2017-07-06 07:13:03 +00:00
|
|
|
if [ "${CT_ARCH_XTENSA}" = "y" ]; then
|
2013-07-24 22:10:47 +00:00
|
|
|
CT_DoLog EXTRA "Installing Xtensa headers"
|
2017-05-30 05:32:38 +00:00
|
|
|
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib/newlib/libc/sys/xtensa/include/." \
|
2013-07-24 22:10:47 +00:00
|
|
|
"${CT_HEADERS_DIR}"
|
|
|
|
fi
|
2013-03-12 05:14:38 +00:00
|
|
|
CT_EndStep
|
2011-07-17 16:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_libc() {
|
2010-10-22 22:54:46 +00:00
|
|
|
local -a newlib_opts
|
2015-09-06 11:54:46 +00:00
|
|
|
local cflags_for_target
|
2010-10-22 22:54:46 +00:00
|
|
|
|
2009-05-22 14:46:18 +00:00
|
|
|
CT_DoStep INFO "Installing C library"
|
|
|
|
|
|
|
|
mkdir -p "${CT_BUILD_DIR}/build-libc"
|
|
|
|
cd "${CT_BUILD_DIR}/build-libc"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Configuring C library"
|
|
|
|
|
2016-01-13 14:20:35 +00:00
|
|
|
# Multilib is the default, so if it is not enabled, disable it.
|
|
|
|
if [ "${CT_MULTILIB}" != "y" ]; then
|
|
|
|
extra_config+=("--disable-multilib")
|
|
|
|
fi
|
|
|
|
|
2010-10-22 22:54:46 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-newlib-io-float" )
|
|
|
|
if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-newlib-io-long-double" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-newlib-io-long-double" )
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-newlib-io-float" )
|
|
|
|
newlib_opts+=( "--disable-newlib-io-long-double" )
|
|
|
|
fi
|
2016-12-23 01:02:42 +00:00
|
|
|
|
2011-08-28 18:12:26 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--disable-newlib-supplied-syscalls" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--enable-newlib-supplied-syscalls" )
|
|
|
|
fi
|
2016-12-23 01:02:42 +00:00
|
|
|
|
|
|
|
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
|
2018-06-11 19:42:20 +00:00
|
|
|
ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc
|
2016-12-23 01:02:42 +00:00
|
|
|
GLOBAL_ATEXIT:newlib-global-atexit
|
|
|
|
LITE_EXIT:lite-exit
|
2018-06-11 19:42:20 +00:00
|
|
|
REENT_SMALL:newlib-reent-small
|
|
|
|
MULTITHREAD:newlib-multithread
|
2016-12-23 01:02:42 +00:00
|
|
|
WIDE_ORIENT:newlib-wide-orient
|
2018-06-11 19:42:20 +00:00
|
|
|
UNBUF_STREAM_OPT:newlib-unbuf-stream-opt
|
2016-12-23 01:02:42 +00:00
|
|
|
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"
|
2010-10-22 22:54:46 +00:00
|
|
|
|
2016-12-23 14:26:05 +00:00
|
|
|
[ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \
|
|
|
|
CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto"
|
|
|
|
|
2018-05-26 06:57:29 +00:00
|
|
|
cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}"
|
2015-09-06 11:54:46 +00:00
|
|
|
|
2009-10-25 22:35:55 +00:00
|
|
|
# Note: newlib handles the build/host/target a little bit differently
|
|
|
|
# than one would expect:
|
|
|
|
# build : not used
|
|
|
|
# host : the machine building newlib
|
|
|
|
# target : the machine newlib runs on
|
2016-12-23 14:26:05 +00:00
|
|
|
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`" \
|
2017-01-25 08:06:28 +00:00
|
|
|
${CONFIG_SHELL} \
|
2017-05-30 05:32:38 +00:00
|
|
|
"${CT_SRC_DIR}/newlib/configure" \
|
2016-12-23 14:26:05 +00:00
|
|
|
--host=${CT_BUILD} \
|
|
|
|
--target=${CT_TARGET} \
|
|
|
|
--prefix=${CT_PREFIX_DIR} \
|
|
|
|
"${newlib_opts[@]}" \
|
2011-11-18 03:47:30 +00:00
|
|
|
"${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2010-06-13 21:45:29 +00:00
|
|
|
CT_DoLog EXTRA "Building C library"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make ${JOBSFLAGS}
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2010-06-13 21:45:29 +00:00
|
|
|
CT_DoLog EXTRA "Installing C library"
|
2017-01-11 18:24:06 +00:00
|
|
|
CT_DoExecLog ALL make install
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2011-12-15 07:20:33 +00:00
|
|
|
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
|
|
|
|
local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Building and installing the C library manual"
|
2016-11-21 07:50:17 +00:00
|
|
|
CT_DoExecLog ALL make pdf html
|
2011-12-15 07:20:33 +00:00
|
|
|
|
|
|
|
# NEWLIB install-{pdf.html} fail for some versions
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
|
|
|
|
CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf" \
|
|
|
|
"${doc_dir}/newlib/libm/libm.pdf" \
|
|
|
|
"${doc_dir}/newlib/libc/libc.html" \
|
|
|
|
"${doc_dir}/newlib/libm/libm.html" \
|
|
|
|
"${CT_PREFIX_DIR}/share/doc/newlib"
|
|
|
|
fi
|
|
|
|
|
2009-05-22 14:46:18 +00:00
|
|
|
CT_EndStep
|
|
|
|
}
|
2015-06-21 23:53:06 +00:00
|
|
|
|
|
|
|
do_libc_post_cc() {
|
|
|
|
:
|
|
|
|
}
|