scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Fri Jan 03 17:10:09 2014 +0100 (2014-01-03)
changeset 3270 dff359adf15c
parent 3229 b9bd01c4dc61
child 3302 ea7e988e6244
permissions -rw-r--r--
libc/eglibc: fix downloading of localedef addon

For the versions of eglibc where the ports addon is not external (ie,
all versions after, and including 2.17), we would fail to download the
localedef addon, since the test did not care about the addon we were
about to download, only whether the ports addon was external or not.

Fix that by skipping the ports addon only if that's the addon we're
trying to download.

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