scripts/build/libc/newlib.sh
author Esben Haabendal <esben.haabendal@prevas.dk>
Fri Oct 07 15:06:44 2011 +0200 (2011-10-07)
changeset 2721 7b64746b0ab3
parent 2352 3e4197f32a07
child 2781 504b0759c149
permissions -rw-r--r--
scripts/functions: Fix CT_ExtractGit function.

Change CT_ExtractGit so that it clones the repository, instead of just
symlinking it. After cloning, any given ref is checked out, or if no
ref is given, the HEAD of the repository is checked out.

This makes CT_Extract behave similar for git repositories as it does
for tarballs, so that it for example can be used for passing glibc-ports
as a git repository.

Signed-off-by: "Esben Haabendal" <esben.haabendal@prevas.dk>
[yann.morin.1998@anciens.enib.fr: fix incomplete var rename]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.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 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 [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
    24         CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
    25     else
    26         CT_GetCVS "newlib-$(libc_newlib_version)"                   \
    27                   ":pserver:anoncvs@sources.redhat.com:/cvs/src"    \
    28                   "newlib"                                          \
    29                   "${CT_LIBC_VERSION}"                              \
    30                   "newlib-$(libc_newlib_version)=src"
    31     fi
    32 
    33     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    34         CT_GetFile "avr32headers" ${avr32headers_src}
    35     fi
    36 }
    37 
    38 do_libc_extract() {
    39     CT_Extract "newlib-$(libc_newlib_version)"
    40     CT_Patch "newlib" "$(libc_newlib_version)"
    41 
    42     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    43         CT_Extract "avr32headers"
    44     fi
    45 }
    46 
    47 do_libc_check_config() {
    48     :
    49 }
    50 
    51 do_libc_start_files() {
    52     local -a newlib_opts
    53 
    54     CT_DoStep INFO "Installing C library"
    55 
    56     mkdir -p "${CT_BUILD_DIR}/build-libc"
    57     cd "${CT_BUILD_DIR}/build-libc"
    58 
    59     CT_DoLog EXTRA "Configuring C library"
    60 
    61     if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
    62         newlib_opts+=( "--enable-newlib-io-c99-formats" )
    63     else
    64         newlib_opts+=( "--disable-newlib-io-c99-formats" )
    65     fi
    66     if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
    67         newlib_opts+=( "--enable-newlib-io-long-long" )
    68     else
    69         newlib_opts+=( "--disable-newlib-io-long-long" )
    70     fi
    71     if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
    72         newlib_opts+=( "--enable-newlib-io-float" )
    73         if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
    74             newlib_opts+=( "--enable-newlib-io-long-double" )
    75         else
    76             newlib_opts+=( "--disable-newlib-io-long-double" )
    77         fi
    78     else
    79         newlib_opts+=( "--disable-newlib-io-float" )
    80         newlib_opts+=( "--disable-newlib-io-long-double" )
    81     fi
    82     if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
    83         newlib_opts+=( "--disable-newlib-supplied-syscalls" )
    84     else
    85         newlib_opts+=( "--enable-newlib-supplied-syscalls" )
    86     fi
    87 
    88     # Note: newlib handles the build/host/target a little bit differently
    89     # than one would expect:
    90     #   build  : not used
    91     #   host   : the machine building newlib
    92     #   target : the machine newlib runs on
    93     CT_DoExecLog CFG                                    \
    94     CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
    95     CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O"          \
    96     AR=${CT_TARGET}-ar                                  \
    97     RANLIB=${CT_TARGET}-ranlib                          \
    98     "${CT_SRC_DIR}/newlib-$(libc_newlib_version)/configure" \
    99         --host=${CT_BUILD}                              \
   100         --target=${CT_TARGET}                           \
   101         --prefix=${CT_PREFIX_DIR}                       \
   102         "${newlib_opts[@]}"
   103 
   104     CT_DoLog EXTRA "Building C library"
   105     CT_DoExecLog ALL make ${JOBSFLAGS}
   106 
   107     CT_DoLog EXTRA "Installing C library"
   108     CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
   109 
   110     CT_EndStep
   111 }
   112 
   113 do_libc() {
   114     :
   115 }
   116 
   117 do_libc_finish() {
   118     CT_DoStep INFO "Finishing C library"
   119     
   120     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
   121         CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
   122         CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"
   123     fi
   124 
   125     CT_EndStep
   126 }