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
20 libc_src="ftp://sources.redhat.com/pub/newlib"
21 avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
23 if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
24 CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
26 CT_GetCVS "newlib-$(libc_newlib_version)" \
27 ":pserver:anoncvs@sources.redhat.com:/cvs/src" \
29 "${CT_LIBC_VERSION}" \
30 "newlib-$(libc_newlib_version)=src"
33 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
34 CT_GetFile "avr32headers" ${avr32headers_src}
39 CT_Extract "newlib-$(libc_newlib_version)"
40 CT_Patch "newlib" "$(libc_newlib_version)"
42 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
43 CT_Extract "avr32headers"
47 do_libc_check_config() {
55 do_libc_start_files() {
58 CT_DoStep INFO "Installing C library"
60 mkdir -p "${CT_BUILD_DIR}/build-libc"
61 cd "${CT_BUILD_DIR}/build-libc"
63 CT_DoLog EXTRA "Configuring C library"
65 if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
66 newlib_opts+=( "--enable-newlib-io-c99-formats" )
68 newlib_opts+=( "--disable-newlib-io-c99-formats" )
70 if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
71 newlib_opts+=( "--enable-newlib-io-long-long" )
73 newlib_opts+=( "--disable-newlib-io-long-long" )
75 if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
76 newlib_opts+=( "--enable-newlib-io-float" )
77 if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
78 newlib_opts+=( "--enable-newlib-io-long-double" )
80 newlib_opts+=( "--disable-newlib-io-long-double" )
83 newlib_opts+=( "--disable-newlib-io-float" )
84 newlib_opts+=( "--disable-newlib-io-long-double" )
87 # Note: newlib handles the build/host/target a little bit differently
88 # than one would expect:
90 # host : the machine building newlib
91 # target : the machine newlib runs on
92 CC_FOR_BUILD="${CT_BUILD}-gcc" \
93 CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O" \
95 RANLIB=${CT_TARGET}-ranlib \
97 "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
99 --target=${CT_TARGET} \
100 --prefix=${CT_PREFIX_DIR} \
103 CT_DoLog EXTRA "Building C library"
104 CT_DoExecLog ALL make ${PARALLELMFLAGS}
106 CT_DoLog EXTRA "Installing C library"
107 CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
117 CT_DoStep INFO "Finishing C library"
119 if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
120 CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
121 CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"