scripts/build/libc/newlib.sh
author Michael Hope <michaelh@juju.net.nz>
Thu Aug 01 20:24:35 2013 +0000 (2013-08-01)
changeset 3229 b9bd01c4dc61
parent 3203 74fd467be5aa
child 3259 cff2f2d39e91
permissions -rw-r--r--
libc/newlib: add HTTP mirror

Add well-known HTTP mirror as a fallback. This lets crosstool-ng
work when behind a HTTP/HTTPS only proxy.

Signed-off-by: Michael Hope <michaelh@juju.net.nz>
[yann.morin.1998@free.fr: split patch in two]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <aeb4a850d0786ee62dc2.1375559989@wanda>
Patchwork-Id: 264436
     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="ftp://sourceware.org/pub/newlib"
    10     local avr32headers_src="http://www.atmel.com/Images"
    11           avr32headers_base="avr-headers-3.2.3.970"    # used below
    12     local avr32headers_ext=".zip"
    13 
    14     if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
    15         CT_GetCustom "newlib" "${CT_LIBC_VERSION}"      \
    16                      "${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
    17     else # ! custom location
    18         CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src} \
    19             http://mirrors.kernel.org/sources.redhat.com/newlib
    20     fi # ! custom location
    21 
    22     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    23         CT_GetFile ${avr32headers_base} ${avr32headers_ext} ${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         # The avr32header zip file extracts to avr32/*.h
    39         # Put that in its directory, the same as normal tarballs
    40         CT_Extract ${avr32headers_base} -d ${CT_SRC_DIR}/${avr32headers_base}
    41     fi
    42 }
    43 
    44 do_libc_check_config() {
    45     :
    46 }
    47 
    48 do_libc_start_files() {
    49     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    50         CT_DoStep INFO "Installing C library headers & start files"
    51 
    52         CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
    53         CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include"
    54         CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/${avr32headers_base}/avr32"     \
    55                                "${CT_PREFIX_DIR}/${CT_TARGET}/include/"
    56 
    57         CT_EndStep
    58     fi
    59 }
    60 
    61 do_libc() {
    62     local -a newlib_opts
    63 
    64     CT_DoStep INFO "Installing C library"
    65 
    66     mkdir -p "${CT_BUILD_DIR}/build-libc"
    67     cd "${CT_BUILD_DIR}/build-libc"
    68 
    69     CT_DoLog EXTRA "Configuring C library"
    70 
    71     if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
    72         newlib_opts+=( "--enable-newlib-io-c99-formats" )
    73     else
    74         newlib_opts+=( "--disable-newlib-io-c99-formats" )
    75     fi
    76     if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
    77         newlib_opts+=( "--enable-newlib-io-long-long" )
    78     else
    79         newlib_opts+=( "--disable-newlib-io-long-long" )
    80     fi
    81     if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
    82         newlib_opts+=( "--enable-newlib-io-float" )
    83         if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
    84             newlib_opts+=( "--enable-newlib-io-long-double" )
    85         else
    86             newlib_opts+=( "--disable-newlib-io-long-double" )
    87         fi
    88     else
    89         newlib_opts+=( "--disable-newlib-io-float" )
    90         newlib_opts+=( "--disable-newlib-io-long-double" )
    91     fi
    92     if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
    93         newlib_opts+=( "--disable-newlib-supplied-syscalls" )
    94     else
    95         newlib_opts+=( "--enable-newlib-supplied-syscalls" )
    96     fi
    97 
    98     [ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
    99 
   100     # Note: newlib handles the build/host/target a little bit differently
   101     # than one would expect:
   102     #   build  : not used
   103     #   host   : the machine building newlib
   104     #   target : the machine newlib runs on
   105     CT_DoExecLog CFG                                    \
   106     CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
   107     CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}"             \
   108     AR=${CT_TARGET}-ar                                  \
   109     RANLIB=${CT_TARGET}-ranlib                          \
   110     "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
   111         --host=${CT_BUILD}                              \
   112         --target=${CT_TARGET}                           \
   113         --prefix=${CT_PREFIX_DIR}                       \
   114         "${newlib_opts[@]}"                             \
   115         "${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
   116 
   117     CT_DoLog EXTRA "Building C library"
   118     CT_DoExecLog ALL make ${JOBSFLAGS}
   119 
   120     CT_DoLog EXTRA "Installing C library"
   121     CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
   122 
   123     if [ "${CT_BUILD_MANUALS}" = "y" ]; then
   124         local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
   125 
   126         CT_DoLog EXTRA "Building and installing the C library manual"
   127         CT_DoExecLog ALL make pdf html
   128 
   129         # NEWLIB install-{pdf.html} fail for some versions
   130         CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
   131         CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf"   \
   132                                 "${doc_dir}/newlib/libm/libm.pdf"   \
   133                                 "${doc_dir}/newlib/libc/libc.html"  \
   134                                 "${doc_dir}/newlib/libm/libm.html"  \
   135                                 "${CT_PREFIX_DIR}/share/doc/newlib"
   136     fi
   137 
   138     CT_EndStep
   139 }