scripts/build/libc/newlib.sh
author Michael Hope <michael.hope@linaro.org>
Wed Oct 19 15:27:32 2011 +1300 (2011-10-19)
changeset 2739 f320e22f2cba
parent 2352 3e4197f32a07
child 2781 504b0759c149
permissions -rw-r--r--
arch: add softfp support

Some architectures support a mixed hard/soft floating point, where
the compiler emits hardware floating point instructions, but passes
the operands in core (aka integer) registers.

For example, ARM supports this mode (to come in the next changeset).

Add support for softfp cross compilers to the GCC and GLIBC
configuration. Needed for Ubuntu and other distros that are softfp.

Signed-off-by: Michael Hope <michael.hope@linaro.org>
[yann.morin.1998@anciens.enib.fr: split the original patch]
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
mgl@1371
    20
    libc_src="ftp://sources.redhat.com/pub/newlib"
mgl@1373
    21
    avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
yann@1593
    22
yann@1593
    23
    if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
yann@1593
    24
        CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
yann@1593
    25
    else
yann@1900
    26
        CT_GetCVS "newlib-$(libc_newlib_version)"                   \
yann@1593
    27
                  ":pserver:anoncvs@sources.redhat.com:/cvs/src"    \
yann@1593
    28
                  "newlib"                                          \
yann@1593
    29
                  "${CT_LIBC_VERSION}"                              \
yann@1900
    30
                  "newlib-$(libc_newlib_version)=src"
yann@1593
    31
    fi
mgl@1371
    32
mgl@1373
    33
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
mgl@1373
    34
        CT_GetFile "avr32headers" ${avr32headers_src}
mgl@1373
    35
    fi
mgl@1371
    36
}
mgl@1371
    37
mgl@1371
    38
do_libc_extract() {
yann@1900
    39
    CT_Extract "newlib-$(libc_newlib_version)"
yann@1901
    40
    CT_Patch "newlib" "$(libc_newlib_version)"
mgl@1371
    41
mgl@1373
    42
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
mgl@1373
    43
        CT_Extract "avr32headers"
mgl@1373
    44
    fi
mgl@1371
    45
}
mgl@1371
    46
mgl@1371
    47
do_libc_check_config() {
mgl@1371
    48
    :
mgl@1371
    49
}
mgl@1371
    50
mgl@1371
    51
do_libc_start_files() {
yann@2165
    52
    local -a newlib_opts
yann@2165
    53
mgl@1371
    54
    CT_DoStep INFO "Installing C library"
mgl@1371
    55
mgl@1371
    56
    mkdir -p "${CT_BUILD_DIR}/build-libc"
mgl@1371
    57
    cd "${CT_BUILD_DIR}/build-libc"
mgl@1371
    58
mgl@1371
    59
    CT_DoLog EXTRA "Configuring C library"
mgl@1371
    60
yann@2167
    61
    if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
yann@2167
    62
        newlib_opts+=( "--enable-newlib-io-c99-formats" )
yann@2167
    63
    else
yann@2167
    64
        newlib_opts+=( "--disable-newlib-io-c99-formats" )
yann@2167
    65
    fi
yann@2166
    66
    if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
yann@2166
    67
        newlib_opts+=( "--enable-newlib-io-long-long" )
yann@2166
    68
    else
yann@2166
    69
        newlib_opts+=( "--disable-newlib-io-long-long" )
yann@2166
    70
    fi
yann@2165
    71
    if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
yann@2165
    72
        newlib_opts+=( "--enable-newlib-io-float" )
yann@2165
    73
        if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
yann@2165
    74
            newlib_opts+=( "--enable-newlib-io-long-double" )
yann@2165
    75
        else
yann@2165
    76
            newlib_opts+=( "--disable-newlib-io-long-double" )
yann@2165
    77
        fi
yann@2165
    78
    else
yann@2165
    79
        newlib_opts+=( "--disable-newlib-io-float" )
yann@2165
    80
        newlib_opts+=( "--disable-newlib-io-long-double" )
yann@2165
    81
    fi
kpet@2647
    82
    if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
kpet@2647
    83
        newlib_opts+=( "--disable-newlib-supplied-syscalls" )
kpet@2647
    84
    else
kpet@2647
    85
        newlib_opts+=( "--enable-newlib-supplied-syscalls" )
kpet@2647
    86
    fi
yann@2165
    87
yann@1588
    88
    # Note: newlib handles the build/host/target a little bit differently
yann@1588
    89
    # than one would expect:
yann@1588
    90
    #   build  : not used
yann@1588
    91
    #   host   : the machine building newlib
yann@1588
    92
    #   target : the machine newlib runs on
yann@2352
    93
    CT_DoExecLog CFG                                    \
yann@1593
    94
    CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
yann@1593
    95
    CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O"          \
yann@1593
    96
    AR=${CT_TARGET}-ar                                  \
yann@1593
    97
    RANLIB=${CT_TARGET}-ranlib                          \
yann@1900
    98
    "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
yann@1593
    99
        --host=${CT_BUILD}                              \
yann@1593
   100
        --target=${CT_TARGET}                           \
yann@2165
   101
        --prefix=${CT_PREFIX_DIR}                       \
yann@2165
   102
        "${newlib_opts[@]}"
yann@1982
   103
mgl@1371
   104
    CT_DoLog EXTRA "Building C library"
yann@2275
   105
    CT_DoExecLog ALL make ${JOBSFLAGS}
mgl@1371
   106
mgl@1371
   107
    CT_DoLog EXTRA "Installing C library"
mgl@1371
   108
    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
mgl@1371
   109
mgl@1371
   110
    CT_EndStep
mgl@1371
   111
}
mgl@1371
   112
yann@1982
   113
do_libc() {
yann@1982
   114
    :
yann@1982
   115
}
yann@1982
   116
mgl@1371
   117
do_libc_finish() {
yann@1589
   118
    CT_DoStep INFO "Finishing C library"
mgl@1373
   119
    
mgl@1373
   120
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
yann@1589
   121
        CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
mgl@1373
   122
        CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"
mgl@1373
   123
    fi
mgl@1373
   124
mgl@1373
   125
    CT_EndStep
mgl@1371
   126
}