1 # This file adds functions to build the Newlib C library
2 # Copyright 2009 DoréDevelopment
3 # Licensed under the GPL v2. See COPYING in the root of this package
5 # Edited by Martin Lund <mgl@doredevelopment.dk>
8 libc_newlib_version() {
9 if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
10 echo "${CT_LIBC_VERSION}"
12 echo "cvs${CT_LIBC_VERSION:+-${CT_LIBC_VERSION}}"
18 local avr32headers_src
21 libc_src="ftp://sources.redhat.com/pub/newlib"
22 avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
24 save_chunks="${CT_DOWNLOAD_MAX_CHUNKS}"
25 CT_DOWNLOAD_MAX_CHUNKS=1
27 if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
28 CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
30 CT_GetCVS "newlib-$(libc_newlib_version)" \
31 ":pserver:anoncvs@sources.redhat.com:/cvs/src" \
33 "${CT_LIBC_VERSION}" \
34 "newlib-$(libc_newlib_version)=src"
37 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
38 CT_GetFile "avr32headers" ${avr32headers_src}
41 CT_DOWNLOAD_MAX_CHUNKS="${save_chunks}"
45 CT_Extract "newlib-$(libc_newlib_version)"
46 CT_Patch "newlib" "$(libc_newlib_version)"
48 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
49 CT_Extract "avr32headers"
53 do_libc_check_config() {
61 do_libc_start_files() {
62 CT_DoStep INFO "Installing C library"
64 mkdir -p "${CT_BUILD_DIR}/build-libc"
65 cd "${CT_BUILD_DIR}/build-libc"
67 CT_DoLog EXTRA "Configuring C library"
69 # Note: newlib handles the build/host/target a little bit differently
70 # than one would expect:
72 # host : the machine building newlib
73 # target : the machine newlib runs on
74 CC_FOR_BUILD="${CT_BUILD}-gcc" \
75 CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O" \
77 RANLIB=${CT_TARGET}-ranlib \
79 "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
81 --target=${CT_TARGET} \
82 --prefix=${CT_PREFIX_DIR}
84 CT_DoLog EXTRA "Building C library"
85 CT_DoExecLog ALL make ${PARALLELMFLAGS}
87 CT_DoLog EXTRA "Installing C library"
88 CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
98 CT_DoStep INFO "Finishing C library"
100 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
101 CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
102 CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"