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
|
|
|
#
|
|
|
|
|
2013-12-31 11:55:21 +00:00
|
|
|
LIBC_NEWLIB_AVR_HDRS_URI="http://www.atmel.com/Images"
|
|
|
|
LIBC_NEWLIB_AVR_HDRS_BASE="avr-headers-3.2.3.970"
|
|
|
|
LIBC_NEWLIB_AVR_HDRS_EXT=".zip"
|
|
|
|
|
2009-05-22 14:46:18 +00:00
|
|
|
do_libc_get() {
|
2013-03-31 04:07:38 +00:00
|
|
|
local libc_src="ftp://sourceware.org/pub/newlib"
|
2009-10-26 21:00:30 +00:00
|
|
|
|
2012-10-11 04:39:45 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
|
|
|
|
CT_GetCustom "newlib" "${CT_LIBC_VERSION}" \
|
|
|
|
"${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
|
2012-10-30 21:40:48 +00:00
|
|
|
else # ! custom location
|
2013-08-01 20:24:35 +00:00
|
|
|
CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src} \
|
|
|
|
http://mirrors.kernel.org/sources.redhat.com/newlib
|
2012-10-30 21:40:48 +00:00
|
|
|
fi # ! custom location
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2009-05-23 18:46:42 +00:00
|
|
|
if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
|
2013-12-31 11:55:21 +00:00
|
|
|
CT_GetFile ${LIBC_NEWLIB_AVR_HDRS_BASE} \
|
|
|
|
${LIBC_NEWLIB_AVR_HDRS_EXT} \
|
|
|
|
${LIBC_NEWLIB_AVR_HDRS_URI}
|
2009-05-23 18:46:42 +00:00
|
|
|
fi
|
2009-05-22 14:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_libc_extract() {
|
2012-10-11 04:39:45 +00:00
|
|
|
# If using custom directory location, nothing to do
|
2014-02-25 18:34:48 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" \
|
2012-10-30 21:40:48 +00:00
|
|
|
-a -d "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}" ]; then
|
2012-10-11 04:39:45 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2012-10-30 21:40:48 +00:00
|
|
|
CT_Extract "newlib-${CT_LIBC_VERSION}"
|
|
|
|
CT_Patch "newlib" "${CT_LIBC_VERSION}"
|
2009-05-22 14:46:18 +00:00
|
|
|
|
2009-05-23 18:46:42 +00:00
|
|
|
if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
|
2013-03-31 04:07:38 +00:00
|
|
|
# The avr32header zip file extracts to avr32/*.h
|
|
|
|
# Put that in its directory, the same as normal tarballs
|
2013-12-31 11:55:21 +00:00
|
|
|
CT_Extract ${LIBC_NEWLIB_AVR_HDRS_BASE} \
|
|
|
|
-d ${CT_SRC_DIR}/${LIBC_NEWLIB_AVR_HDRS_BASE}
|
2009-05-23 18:46:42 +00:00
|
|
|
fi
|
2009-05-22 14:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_libc_check_config() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
|
|
|
|
do_libc_start_files() {
|
2013-01-10 18:06:46 +00:00
|
|
|
if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
|
|
|
|
CT_DoStep INFO "Installing C library headers & start files"
|
|
|
|
|
|
|
|
CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
|
|
|
|
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include"
|
2013-12-31 11:55:21 +00:00
|
|
|
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/${LIBC_NEWLIB_AVR_HDRS_BASE}/avr32" \
|
2013-03-31 04:07:38 +00:00
|
|
|
"${CT_PREFIX_DIR}/${CT_TARGET}/include/"
|
2013-01-10 18:06:46 +00:00
|
|
|
|
|
|
|
CT_EndStep
|
|
|
|
fi
|
2011-07-17 16:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_libc() {
|
2010-10-22 22:54:46 +00:00
|
|
|
local -a newlib_opts
|
|
|
|
|
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"
|
|
|
|
|
2010-10-22 23:21:20 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-newlib-io-c99-formats" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-newlib-io-c99-formats" )
|
|
|
|
fi
|
2010-10-22 22:53:41 +00:00
|
|
|
if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
|
|
|
|
newlib_opts+=( "--enable-newlib-io-long-long" )
|
|
|
|
else
|
|
|
|
newlib_opts+=( "--disable-newlib-io-long-long" )
|
|
|
|
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
|
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
|
2010-10-22 22:54:46 +00:00
|
|
|
|
2011-11-22 06:18:14 +00:00
|
|
|
[ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
|
|
|
|
|
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
|
2011-03-20 00:13:05 +00:00
|
|
|
CT_DoExecLog CFG \
|
2009-10-26 21:00:30 +00:00
|
|
|
CC_FOR_BUILD="${CT_BUILD}-gcc" \
|
2011-11-28 08:05:23 +00:00
|
|
|
CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
|
2009-10-26 21:00:30 +00:00
|
|
|
AR=${CT_TARGET}-ar \
|
|
|
|
RANLIB=${CT_TARGET}-ranlib \
|
2012-10-30 21:40:48 +00:00
|
|
|
"${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
|
2009-10-26 21:00:30 +00:00
|
|
|
--host=${CT_BUILD} \
|
|
|
|
--target=${CT_TARGET} \
|
2010-10-22 22:54:46 +00:00
|
|
|
--prefix=${CT_PREFIX_DIR} \
|
2011-11-18 03:47:30 +00:00
|
|
|
"${newlib_opts[@]}" \
|
|
|
|
"${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"
|
2011-01-22 21:35:43 +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"
|
2009-05-22 14:46:18 +00:00
|
|
|
CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
|
|
|
|
|
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"
|
|
|
|
CT_DoExecLog ALL make pdf html
|
|
|
|
|
|
|
|
# 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
|
|
|
|
}
|