scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Sun May 11 23:43:52 2014 +0200 (2014-05-11)
changeset 3320 78af1c99bc6d
parent 3259 cff2f2d39e91
permissions -rw-r--r--
scripts/functions: add target_endian_le and target_endian_be

We currently define target_endian_el and target_endian_eb to be the
tuple extension depending on endianness, defined to be respectively
'el' or 'eb' according to the endianness.

Some architecture do not use 'el' or 'eb', but use 'le' or 'be'.

Provide that as well, as two new variables: target_endian_le and
target_endian_be.

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