scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Oct 26 22:00:30 2009 +0100 (2009-10-26)
changeset 1593 66b2463743af
parent 1589 c8619ad47c6d
child 1900 835379d47869
permissions -rw-r--r--
libc/newlib: allow using CVS snapshots

The newlib "team" rolls new releases about once a year (december).
This is quite a long time between releases, in case code was fixed.
So, allow user to use a CVS snapshot to benefit early from fixes
and enhancements to newlib.
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@1593
     8
libc_newlib_basename() {
yann@1593
     9
    if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
yann@1593
    10
        echo "newlib-${CT_LIBC_VERSION}"
yann@1593
    11
    else
yann@1593
    12
        echo "newlib-cvs${CT_LIBC_VERSION:+-${CT_LIBC_VERSION}}"
yann@1593
    13
    fi
yann@1593
    14
}
mgl@1371
    15
mgl@1371
    16
do_libc_get() {
mgl@1371
    17
    libc_src="ftp://sources.redhat.com/pub/newlib"
mgl@1373
    18
    avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
yann@1593
    19
yann@1593
    20
    if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
yann@1593
    21
        CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
yann@1593
    22
    else
yann@1593
    23
        CT_GetCVS "$(libc_newlib_basename)"                         \
yann@1593
    24
                  ":pserver:anoncvs@sources.redhat.com:/cvs/src"    \
yann@1593
    25
                  "newlib"                                          \
yann@1593
    26
                  "${CT_LIBC_VERSION}"                              \
yann@1593
    27
                  "$(libc_newlib_basename)=src"
yann@1593
    28
    fi
mgl@1371
    29
mgl@1373
    30
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
mgl@1373
    31
        CT_GetFile "avr32headers" ${avr32headers_src}
mgl@1373
    32
    fi
mgl@1371
    33
}
mgl@1371
    34
mgl@1371
    35
do_libc_extract() {
yann@1593
    36
    CT_Extract "$(libc_newlib_basename)"
yann@1593
    37
    CT_Patch "$(libc_newlib_basename)"
mgl@1371
    38
mgl@1373
    39
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
mgl@1373
    40
        CT_Extract "avr32headers"
mgl@1373
    41
    fi
mgl@1371
    42
}
mgl@1371
    43
mgl@1371
    44
do_libc_check_config() {
mgl@1371
    45
    :
mgl@1371
    46
}
mgl@1371
    47
mgl@1371
    48
do_libc_headers() {
mgl@1371
    49
    :
mgl@1371
    50
}
mgl@1371
    51
mgl@1371
    52
do_libc_start_files() {
mgl@1371
    53
    :
mgl@1371
    54
}
mgl@1371
    55
mgl@1371
    56
do_libc() {
mgl@1371
    57
    CT_DoStep INFO "Installing C library"
mgl@1371
    58
mgl@1371
    59
    mkdir -p "${CT_BUILD_DIR}/build-libc"
mgl@1371
    60
    cd "${CT_BUILD_DIR}/build-libc"
mgl@1371
    61
mgl@1371
    62
    CT_DoLog EXTRA "Configuring C library"
mgl@1371
    63
yann@1588
    64
    # Note: newlib handles the build/host/target a little bit differently
yann@1588
    65
    # than one would expect:
yann@1588
    66
    #   build  : not used
yann@1588
    67
    #   host   : the machine building newlib
yann@1588
    68
    #   target : the machine newlib runs on
yann@1593
    69
    CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
yann@1593
    70
    CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O"          \
yann@1593
    71
    AR=${CT_TARGET}-ar                                  \
yann@1593
    72
    RANLIB=${CT_TARGET}-ranlib                          \
yann@1593
    73
    CT_DoExecLog ALL                                    \
yann@1593
    74
    "${CT_SRC_DIR}/$(libc_newlib_basename)/configure"   \
yann@1593
    75
        --host=${CT_BUILD}                              \
yann@1593
    76
        --target=${CT_TARGET}                           \
yann@1589
    77
        --prefix=${CT_PREFIX_DIR}
mgl@1371
    78
    
mgl@1371
    79
    CT_DoLog EXTRA "Building C library"
mgl@1371
    80
yann@1589
    81
    CT_DoExecLog ALL make ${PARALLELMFLAGS}
mgl@1371
    82
    
mgl@1371
    83
    CT_DoLog EXTRA "Installing C library"
mgl@1371
    84
mgl@1371
    85
    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
mgl@1371
    86
mgl@1371
    87
    CT_EndStep
mgl@1371
    88
}
mgl@1371
    89
mgl@1371
    90
do_libc_finish() {
yann@1589
    91
    CT_DoStep INFO "Finishing C library"
mgl@1373
    92
    
mgl@1373
    93
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
yann@1589
    94
        CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
mgl@1373
    95
        CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"
mgl@1373
    96
    fi
mgl@1373
    97
mgl@1373
    98
    CT_EndStep
mgl@1371
    99
}