scripts/build/libc/newlib.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Thu Jan 10 19:06:46 2013 +0100 (2013-01-10)
changeset 3161 3ecd4bbfecc5
parent 3095 ee3bc44bf7f9
child 3162 e51eb0a614c7
permissions -rw-r--r--
libc/newlib: install AVR32 headers during the start-files-and-headers phase

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