scripts/build/libc/newlib.sh
author David Holsgrove <david.holsgrove@xilinx.com>
Thu Oct 11 14:39:45 2012 +1000 (2012-10-11)
changeset 3094 07a87075fa2d
parent 2895 86ea5204e9ce
child 3095 ee3bc44bf7f9
permissions -rw-r--r--
libc/newlib: Add CUSTOM version and CUSTOM_LOCATION config options and GetCustom

CUSTOM_LOCATION config options only presented in menuconfig if component
CUSTOM version selected.

Signed-off-by: "David Holsgrove" <david.holsgrove@xilinx.com>
[yann.morin.1998@free.fr: fix indentation]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <d02252752d4dc5e68ae3.1349931202@localhost.localdomain>
PatchWork-Id: 190795
     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_version() {
     9     if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
    10         echo "${CT_LIBC_VERSION}"
    11     else
    12         echo "cvs${CT_LIBC_VERSION:+-${CT_LIBC_VERSION}}"
    13     fi
    14 }
    15 
    16 do_libc_get() {
    17     local libc_src
    18     local avr32headers_src
    19 
    20     libc_src="ftp://sources.redhat.com/pub/newlib"
    21     avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
    22 
    23     if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
    24         CT_GetCustom "newlib" "${CT_LIBC_VERSION}"      \
    25                      "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
    26     elif [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
    27         CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
    28     else
    29         CT_GetCVS "newlib-$(libc_newlib_version)"                   \
    30                   ":pserver:anoncvs@sources.redhat.com:/cvs/src"    \
    31                   "newlib"                                          \
    32                   "${CT_LIBC_VERSION}"                              \
    33                   "newlib-$(libc_newlib_version)=src"
    34     fi
    35 
    36     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    37         CT_GetFile "avr32headers" ${avr32headers_src}
    38     fi
    39 }
    40 
    41 do_libc_extract() {
    42     # If using custom directory location, nothing to do
    43     if [    "${CT_LIBC_NEWLIB_CUSTOM}" != "y"                \
    44          -a -d "${CT_SRC_DIR}/newlib-$(libc_newlib_version)" ]; then
    45         return 0
    46     fi
    47 
    48     CT_Extract "newlib-$(libc_newlib_version)"
    49     CT_Patch "newlib" "$(libc_newlib_version)"
    50 
    51     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    52         CT_Extract "avr32headers"
    53     fi
    54 }
    55 
    56 do_libc_check_config() {
    57     :
    58 }
    59 
    60 do_libc_start_files() {
    61     :
    62 }
    63 
    64 do_libc() {
    65     local -a newlib_opts
    66 
    67     CT_DoStep INFO "Installing C library"
    68 
    69     mkdir -p "${CT_BUILD_DIR}/build-libc"
    70     cd "${CT_BUILD_DIR}/build-libc"
    71 
    72     CT_DoLog EXTRA "Configuring C library"
    73 
    74     if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
    75         newlib_opts+=( "--enable-newlib-io-c99-formats" )
    76     else
    77         newlib_opts+=( "--disable-newlib-io-c99-formats" )
    78     fi
    79     if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
    80         newlib_opts+=( "--enable-newlib-io-long-long" )
    81     else
    82         newlib_opts+=( "--disable-newlib-io-long-long" )
    83     fi
    84     if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
    85         newlib_opts+=( "--enable-newlib-io-float" )
    86         if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
    87             newlib_opts+=( "--enable-newlib-io-long-double" )
    88         else
    89             newlib_opts+=( "--disable-newlib-io-long-double" )
    90         fi
    91     else
    92         newlib_opts+=( "--disable-newlib-io-float" )
    93         newlib_opts+=( "--disable-newlib-io-long-double" )
    94     fi
    95     if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
    96         newlib_opts+=( "--disable-newlib-supplied-syscalls" )
    97     else
    98         newlib_opts+=( "--enable-newlib-supplied-syscalls" )
    99     fi
   100 
   101     [ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
   102 
   103     # Note: newlib handles the build/host/target a little bit differently
   104     # than one would expect:
   105     #   build  : not used
   106     #   host   : the machine building newlib
   107     #   target : the machine newlib runs on
   108     CT_DoExecLog CFG                                    \
   109     CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
   110     CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"             \
   111     AR=${CT_TARGET}-ar                                  \
   112     RANLIB=${CT_TARGET}-ranlib                          \
   113     "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
   114         --host=${CT_BUILD}                              \
   115         --target=${CT_TARGET}                           \
   116         --prefix=${CT_PREFIX_DIR}                       \
   117         "${newlib_opts[@]}"                             \
   118         "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
   119 
   120     CT_DoLog EXTRA "Building C library"
   121     CT_DoExecLog ALL make ${JOBSFLAGS}
   122 
   123     CT_DoLog EXTRA "Installing C library"
   124     CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
   125 
   126     if [ "${CT_BUILD_MANUALS}" = "y" ]; then
   127         local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
   128 
   129         CT_DoLog EXTRA "Building and installing the C library manual"
   130         CT_DoExecLog ALL make pdf html
   131 
   132         # NEWLIB install-{pdf.html} fail for some versions
   133         CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
   134         CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf"   \
   135                                 "${doc_dir}/newlib/libm/libm.pdf"   \
   136                                 "${doc_dir}/newlib/libc/libc.html"  \
   137                                 "${doc_dir}/newlib/libm/libm.html"  \
   138                                 "${CT_PREFIX_DIR}/share/doc/newlib"
   139     fi
   140 
   141     CT_EndStep
   142 }
   143 
   144 do_libc_finish() {
   145     CT_DoStep INFO "Finishing C library"
   146     
   147     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
   148         CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
   149         CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"
   150     fi
   151 
   152     CT_EndStep
   153 }