mgl@1371: # This file adds functions to build the Newlib C library mgl@1467: # Copyright 2009 DoréDevelopment mgl@1371: # Licensed under the GPL v2. See COPYING in the root of this package mgl@1371: # mgl@1467: # Edited by Martin Lund mgl@1371: # mgl@1371: yann@1900: libc_newlib_version() { yann@1593: if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then yann@1900: echo "${CT_LIBC_VERSION}" yann@1593: else yann@1900: echo "cvs${CT_LIBC_VERSION:+-${CT_LIBC_VERSION}}" yann@1593: fi yann@1593: } mgl@1371: mgl@1371: do_libc_get() { yann@1930: local libc_src yann@1930: local avr32headers_src yann@1930: local save_chunks yann@1930: mgl@1371: libc_src="ftp://sources.redhat.com/pub/newlib" mgl@1373: avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources" yann@1593: yann@1930: save_chunks="${CT_DOWNLOAD_MAX_CHUNKS}" yann@1930: CT_DOWNLOAD_MAX_CHUNKS=1 yann@1930: yann@1593: if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then yann@1593: CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src} yann@1593: else yann@1900: CT_GetCVS "newlib-$(libc_newlib_version)" \ yann@1593: ":pserver:anoncvs@sources.redhat.com:/cvs/src" \ yann@1593: "newlib" \ yann@1593: "${CT_LIBC_VERSION}" \ yann@1900: "newlib-$(libc_newlib_version)=src" yann@1593: fi mgl@1371: mgl@1373: if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then mgl@1373: CT_GetFile "avr32headers" ${avr32headers_src} mgl@1373: fi yann@1930: yann@1930: CT_DOWNLOAD_MAX_CHUNKS="${save_chunks}" mgl@1371: } mgl@1371: mgl@1371: do_libc_extract() { yann@1900: CT_Extract "newlib-$(libc_newlib_version)" yann@1901: CT_Patch "newlib" "$(libc_newlib_version)" mgl@1371: mgl@1373: if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then mgl@1373: CT_Extract "avr32headers" mgl@1373: fi mgl@1371: } mgl@1371: mgl@1371: do_libc_check_config() { mgl@1371: : mgl@1371: } mgl@1371: mgl@1371: do_libc_headers() { mgl@1371: : mgl@1371: } mgl@1371: mgl@1371: do_libc_start_files() { yann@2165: local -a newlib_opts yann@2165: mgl@1371: CT_DoStep INFO "Installing C library" mgl@1371: mgl@1371: mkdir -p "${CT_BUILD_DIR}/build-libc" mgl@1371: cd "${CT_BUILD_DIR}/build-libc" mgl@1371: mgl@1371: CT_DoLog EXTRA "Configuring C library" mgl@1371: yann@2165: if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then yann@2165: newlib_opts+=( "--enable-newlib-io-float" ) yann@2165: if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then yann@2165: newlib_opts+=( "--enable-newlib-io-long-double" ) yann@2165: else yann@2165: newlib_opts+=( "--disable-newlib-io-long-double" ) yann@2165: fi yann@2165: else yann@2165: newlib_opts+=( "--disable-newlib-io-float" ) yann@2165: newlib_opts+=( "--disable-newlib-io-long-double" ) yann@2165: fi yann@2165: yann@1588: # Note: newlib handles the build/host/target a little bit differently yann@1588: # than one would expect: yann@1588: # build : not used yann@1588: # host : the machine building newlib yann@1588: # target : the machine newlib runs on yann@1593: CC_FOR_BUILD="${CT_BUILD}-gcc" \ yann@1593: CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O" \ yann@1593: AR=${CT_TARGET}-ar \ yann@1593: RANLIB=${CT_TARGET}-ranlib \ anthony@2154: CT_DoExecLog CFG \ yann@1900: "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \ yann@1593: --host=${CT_BUILD} \ yann@1593: --target=${CT_TARGET} \ yann@2165: --prefix=${CT_PREFIX_DIR} \ yann@2165: "${newlib_opts[@]}" yann@1982: mgl@1371: CT_DoLog EXTRA "Building C library" yann@1982: CT_DoExecLog ALL make ${PARALLELMFLAGS} mgl@1371: mgl@1371: CT_DoLog EXTRA "Installing C library" mgl@1371: CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}" mgl@1371: mgl@1371: CT_EndStep mgl@1371: } mgl@1371: yann@1982: do_libc() { yann@1982: : yann@1982: } yann@1982: mgl@1371: do_libc_finish() { yann@1589: CT_DoStep INFO "Finishing C library" mgl@1373: mgl@1373: if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then yann@1589: CT_DoLog EXTRA "Installing Atmel's AVR32 headers" mgl@1373: CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32" mgl@1373: fi mgl@1373: mgl@1373: CT_EndStep mgl@1371: }