scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Mon Feb 25 21:19:31 2013 +0100 (2013-02-25)
changeset 3185 f89f8e6f8766
parent 3161 3ecd4bbfecc5
child 3186 fb0aa58be2c5
permissions -rw-r--r--
Makefile: fix parrallel (-j) installs

Currently, we would remove previously installed patches before
installing the new ones. Unfortunately, that does not play well
with heavily parallel installs.

Now, we consider it is the responsibility of the user to first
uninstall any previous version before installing a new one.

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