scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Oct 23 01:21:20 2010 +0200 (2010-10-23)
changeset 2167 9cd8ee461fd0
parent 2166 c1fe0639585a
child 2203 ac3e215141a1
permissions -rw-r--r--
libc/newlib: add option to compile support for IOs on C99 formats

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
mgl@1371
     1
# This file adds functions to build the Newlib C library
mgl@1467
     2
# Copyright 2009 DoréDevelopment
mgl@1371
     3
# Licensed under the GPL v2. See COPYING in the root of this package
mgl@1371
     4
#
mgl@1467
     5
# Edited by Martin Lund <mgl@doredevelopment.dk>
mgl@1371
     6
#
mgl@1371
     7
yann@1900
     8
libc_newlib_version() {
yann@1593
     9
    if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
yann@1900
    10
        echo "${CT_LIBC_VERSION}"
yann@1593
    11
    else
yann@1900
    12
        echo "cvs${CT_LIBC_VERSION:+-${CT_LIBC_VERSION}}"
yann@1593
    13
    fi
yann@1593
    14
}
mgl@1371
    15
mgl@1371
    16
do_libc_get() {
yann@1930
    17
    local libc_src
yann@1930
    18
    local avr32headers_src
yann@1930
    19
    local save_chunks
yann@1930
    20
mgl@1371
    21
    libc_src="ftp://sources.redhat.com/pub/newlib"
mgl@1373
    22
    avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
yann@1593
    23
yann@1930
    24
    save_chunks="${CT_DOWNLOAD_MAX_CHUNKS}"
yann@1930
    25
    CT_DOWNLOAD_MAX_CHUNKS=1
yann@1930
    26
yann@1593
    27
    if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
yann@1593
    28
        CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
yann@1593
    29
    else
yann@1900
    30
        CT_GetCVS "newlib-$(libc_newlib_version)"                   \
yann@1593
    31
                  ":pserver:anoncvs@sources.redhat.com:/cvs/src"    \
yann@1593
    32
                  "newlib"                                          \
yann@1593
    33
                  "${CT_LIBC_VERSION}"                              \
yann@1900
    34
                  "newlib-$(libc_newlib_version)=src"
yann@1593
    35
    fi
mgl@1371
    36
mgl@1373
    37
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
mgl@1373
    38
        CT_GetFile "avr32headers" ${avr32headers_src}
mgl@1373
    39
    fi
yann@1930
    40
yann@1930
    41
    CT_DOWNLOAD_MAX_CHUNKS="${save_chunks}"
mgl@1371
    42
}
mgl@1371
    43
mgl@1371
    44
do_libc_extract() {
yann@1900
    45
    CT_Extract "newlib-$(libc_newlib_version)"
yann@1901
    46
    CT_Patch "newlib" "$(libc_newlib_version)"
mgl@1371
    47
mgl@1373
    48
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
mgl@1373
    49
        CT_Extract "avr32headers"
mgl@1373
    50
    fi
mgl@1371
    51
}
mgl@1371
    52
mgl@1371
    53
do_libc_check_config() {
mgl@1371
    54
    :
mgl@1371
    55
}
mgl@1371
    56
mgl@1371
    57
do_libc_headers() {
mgl@1371
    58
    :
mgl@1371
    59
}
mgl@1371
    60
mgl@1371
    61
do_libc_start_files() {
yann@2165
    62
    local -a newlib_opts
yann@2165
    63
mgl@1371
    64
    CT_DoStep INFO "Installing C library"
mgl@1371
    65
mgl@1371
    66
    mkdir -p "${CT_BUILD_DIR}/build-libc"
mgl@1371
    67
    cd "${CT_BUILD_DIR}/build-libc"
mgl@1371
    68
mgl@1371
    69
    CT_DoLog EXTRA "Configuring C library"
mgl@1371
    70
yann@2167
    71
    if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
yann@2167
    72
        newlib_opts+=( "--enable-newlib-io-c99-formats" )
yann@2167
    73
    else
yann@2167
    74
        newlib_opts+=( "--disable-newlib-io-c99-formats" )
yann@2167
    75
    fi
yann@2166
    76
    if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
yann@2166
    77
        newlib_opts+=( "--enable-newlib-io-long-long" )
yann@2166
    78
    else
yann@2166
    79
        newlib_opts+=( "--disable-newlib-io-long-long" )
yann@2166
    80
    fi
yann@2165
    81
    if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
yann@2165
    82
        newlib_opts+=( "--enable-newlib-io-float" )
yann@2165
    83
        if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
yann@2165
    84
            newlib_opts+=( "--enable-newlib-io-long-double" )
yann@2165
    85
        else
yann@2165
    86
            newlib_opts+=( "--disable-newlib-io-long-double" )
yann@2165
    87
        fi
yann@2165
    88
    else
yann@2165
    89
        newlib_opts+=( "--disable-newlib-io-float" )
yann@2165
    90
        newlib_opts+=( "--disable-newlib-io-long-double" )
yann@2165
    91
    fi
yann@2165
    92
yann@1588
    93
    # Note: newlib handles the build/host/target a little bit differently
yann@1588
    94
    # than one would expect:
yann@1588
    95
    #   build  : not used
yann@1588
    96
    #   host   : the machine building newlib
yann@1588
    97
    #   target : the machine newlib runs on
yann@1593
    98
    CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
yann@1593
    99
    CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O"          \
yann@1593
   100
    AR=${CT_TARGET}-ar                                  \
yann@1593
   101
    RANLIB=${CT_TARGET}-ranlib                          \
anthony@2154
   102
    CT_DoExecLog CFG                                    \
yann@1900
   103
    "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
yann@1593
   104
        --host=${CT_BUILD}                              \
yann@1593
   105
        --target=${CT_TARGET}                           \
yann@2165
   106
        --prefix=${CT_PREFIX_DIR}                       \
yann@2165
   107
        "${newlib_opts[@]}"
yann@1982
   108
mgl@1371
   109
    CT_DoLog EXTRA "Building C library"
yann@1982
   110
    CT_DoExecLog ALL make ${PARALLELMFLAGS}
mgl@1371
   111
mgl@1371
   112
    CT_DoLog EXTRA "Installing C library"
mgl@1371
   113
    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
mgl@1371
   114
mgl@1371
   115
    CT_EndStep
mgl@1371
   116
}
mgl@1371
   117
yann@1982
   118
do_libc() {
yann@1982
   119
    :
yann@1982
   120
}
yann@1982
   121
mgl@1371
   122
do_libc_finish() {
yann@1589
   123
    CT_DoStep INFO "Finishing C library"
mgl@1373
   124
    
mgl@1373
   125
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
yann@1589
   126
        CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
mgl@1373
   127
        CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"
mgl@1373
   128
    fi
mgl@1373
   129
mgl@1373
   130
    CT_EndStep
mgl@1371
   131
}