scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Sun May 05 00:01:05 2013 +0200 (2013-05-05)
changeset 3218 3709e61ad85b
parent 3186 fb0aa58be2c5
child 3229 b9bd01c4dc61
permissions -rw-r--r--
complibs/cloog: add support for the ISL backend

CLooG 0.18+ will use ISL instead of PPL, so we have to configure
adequately depending of which backend is in use.

The Kconfig entries will decide for us which is selected, so we
can rely on either PPL xor ISL to be selected, not both.

Reported-by: "Plotnikov Dmitry" <leitz@ispras.ru>
[Dmitry did a preliminray patch to add ISL support,
which this patch is inspired from]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.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
mgl@1371
     8
do_libc_get() {
martinwguy@3203
     9
    local libc_src="ftp://sourceware.org/pub/newlib"
martinwguy@3203
    10
    local avr32headers_src="http://www.atmel.com/Images"
martinwguy@3203
    11
          avr32headers_base="avr-headers-3.2.3.970"    # used below
martinwguy@3203
    12
    local avr32headers_ext=".zip"
yann@1593
    13
david@3094
    14
    if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
david@3094
    15
        CT_GetCustom "newlib" "${CT_LIBC_VERSION}"      \
david@3094
    16
                     "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
yann@3095
    17
    else # ! custom location
yann@1593
    18
        CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
yann@3095
    19
    fi # ! custom location
mgl@1371
    20
mgl@1373
    21
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
martinwguy@3203
    22
        CT_GetFile ${avr32headers_base} ${avr32headers_ext} ${avr32headers_src}
mgl@1373
    23
    fi
mgl@1371
    24
}
mgl@1371
    25
mgl@1371
    26
do_libc_extract() {
david@3094
    27
    # If using custom directory location, nothing to do
yann@3095
    28
    if [    "${CT_LIBC_NEWLIB_CUSTOM}" != "y"            \
yann@3095
    29
         -a -d "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}" ]; then
david@3094
    30
        return 0
david@3094
    31
    fi
david@3094
    32
yann@3095
    33
    CT_Extract "newlib-${CT_LIBC_VERSION}"
yann@3095
    34
    CT_Patch "newlib" "${CT_LIBC_VERSION}"
mgl@1371
    35
mgl@1373
    36
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
martinwguy@3203
    37
        # The avr32header zip file extracts to avr32/*.h
martinwguy@3203
    38
        # Put that in its directory, the same as normal tarballs
martinwguy@3203
    39
        CT_Extract ${avr32headers_base} -d ${CT_SRC_DIR}/${avr32headers_base}
mgl@1373
    40
    fi
mgl@1371
    41
}
mgl@1371
    42
mgl@1371
    43
do_libc_check_config() {
mgl@1371
    44
    :
mgl@1371
    45
}
mgl@1371
    46
mgl@1371
    47
do_libc_start_files() {
yann@3161
    48
    if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
yann@3161
    49
        CT_DoStep INFO "Installing C library headers & start files"
yann@3161
    50
yann@3161
    51
        CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
yann@3161
    52
        CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include"
martinwguy@3203
    53
        CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/${avr32headers_base}/avr32"     \
martinwguy@3203
    54
                               "${CT_PREFIX_DIR}/${CT_TARGET}/include/"
yann@3161
    55
yann@3161
    56
        CT_EndStep
yann@3161
    57
    fi
yann@2895
    58
}
yann@2895
    59
yann@2895
    60
do_libc() {
yann@2165
    61
    local -a newlib_opts
yann@2165
    62
mgl@1371
    63
    CT_DoStep INFO "Installing C library"
mgl@1371
    64
mgl@1371
    65
    mkdir -p "${CT_BUILD_DIR}/build-libc"
mgl@1371
    66
    cd "${CT_BUILD_DIR}/build-libc"
mgl@1371
    67
mgl@1371
    68
    CT_DoLog EXTRA "Configuring C library"
mgl@1371
    69
yann@2167
    70
    if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
yann@2167
    71
        newlib_opts+=( "--enable-newlib-io-c99-formats" )
yann@2167
    72
    else
yann@2167
    73
        newlib_opts+=( "--disable-newlib-io-c99-formats" )
yann@2167
    74
    fi
yann@2166
    75
    if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
yann@2166
    76
        newlib_opts+=( "--enable-newlib-io-long-long" )
yann@2166
    77
    else
yann@2166
    78
        newlib_opts+=( "--disable-newlib-io-long-long" )
yann@2166
    79
    fi
yann@2165
    80
    if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
yann@2165
    81
        newlib_opts+=( "--enable-newlib-io-float" )
yann@2165
    82
        if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
yann@2165
    83
            newlib_opts+=( "--enable-newlib-io-long-double" )
yann@2165
    84
        else
yann@2165
    85
            newlib_opts+=( "--disable-newlib-io-long-double" )
yann@2165
    86
        fi
yann@2165
    87
    else
yann@2165
    88
        newlib_opts+=( "--disable-newlib-io-float" )
yann@2165
    89
        newlib_opts+=( "--disable-newlib-io-long-double" )
yann@2165
    90
    fi
kpet@2647
    91
    if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
kpet@2647
    92
        newlib_opts+=( "--disable-newlib-supplied-syscalls" )
kpet@2647
    93
    else
kpet@2647
    94
        newlib_opts+=( "--enable-newlib-supplied-syscalls" )
kpet@2647
    95
    fi
yann@2165
    96
zhenqiang@2783
    97
    [ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
zhenqiang@2783
    98
yann@1588
    99
    # Note: newlib handles the build/host/target a little bit differently
yann@1588
   100
    # than one would expect:
yann@1588
   101
    #   build  : not used
yann@1588
   102
    #   host   : the machine building newlib
yann@1588
   103
    #   target : the machine newlib runs on
yann@2352
   104
    CT_DoExecLog CFG                                    \
yann@1593
   105
    CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
zhenqiang@2787
   106
    CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"             \
yann@1593
   107
    AR=${CT_TARGET}-ar                                  \
yann@1593
   108
    RANLIB=${CT_TARGET}-ranlib                          \
yann@3095
   109
    "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
yann@1593
   110
        --host=${CT_BUILD}                              \
yann@1593
   111
        --target=${CT_TARGET}                           \
yann@2165
   112
        --prefix=${CT_PREFIX_DIR}                       \
zhenqiang@2781
   113
        "${newlib_opts[@]}"                             \
zhenqiang@2781
   114
        "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
yann@1982
   115
mgl@1371
   116
    CT_DoLog EXTRA "Building C library"
yann@2275
   117
    CT_DoExecLog ALL make ${JOBSFLAGS}
mgl@1371
   118
mgl@1371
   119
    CT_DoLog EXTRA "Installing C library"
mgl@1371
   120
    CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
mgl@1371
   121
zhenqiang@2808
   122
    if [ "${CT_BUILD_MANUALS}" = "y" ]; then
zhenqiang@2808
   123
        local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
zhenqiang@2808
   124
zhenqiang@2808
   125
        CT_DoLog EXTRA "Building and installing the C library manual"
zhenqiang@2808
   126
        CT_DoExecLog ALL make pdf html
zhenqiang@2808
   127
zhenqiang@2808
   128
        # NEWLIB install-{pdf.html} fail for some versions
zhenqiang@2808
   129
        CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
zhenqiang@2808
   130
        CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf"   \
zhenqiang@2808
   131
                                "${doc_dir}/newlib/libm/libm.pdf"   \
zhenqiang@2808
   132
                                "${doc_dir}/newlib/libc/libc.html"  \
zhenqiang@2808
   133
                                "${doc_dir}/newlib/libm/libm.html"  \
zhenqiang@2808
   134
                                "${CT_PREFIX_DIR}/share/doc/newlib"
zhenqiang@2808
   135
    fi
zhenqiang@2808
   136
mgl@1371
   137
    CT_EndStep
mgl@1371
   138
}