scripts/build/libc/newlib.sh
author Zoltan Devai <zdevai@gmail.com>
Wed Oct 28 12:03:38 2009 +0100 (2009-10-28)
changeset 1602 1ba79f2126df
parent 1589 c8619ad47c6d
child 1900 835379d47869
permissions -rw-r--r--
libc/uClibc: fix building on system with recent glibc

While trying to build a toolchain with ct-ng 1.5.0,
arm-unknown-linux-uclibcgnueabi target,
I get the following error:

[INFO ] Installing C library headers
[EXTRA] Copying sources to build dir
[EXTRA] Applying configuration
[EXTRA] Building headers
[EXTRA] Installing headers
[ERROR] extra/scripts/unifdef.c:209: error: conflicting types for 'getline'
[ERROR] make[2]: *** [extra/scripts/unifdef] Error 1
[ERROR] Build failed in step 'Installing C library headers'

The following patch solves the problem.
(It's a backport of this uClibc commit:
http://git.uclibc.org/uClibc/commit/?id=49e81cada73616864b9b31df0aeb6961c30f5a6e
)

[--SNIP from another mail--]
AFAIK this is a problem since glibc 2.10.
     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_basename() {
     9     if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
    10         echo "newlib-${CT_LIBC_VERSION}"
    11     else
    12         echo "newlib-cvs${CT_LIBC_VERSION:+-${CT_LIBC_VERSION}}"
    13     fi
    14 }
    15 
    16 do_libc_get() {
    17     libc_src="ftp://sources.redhat.com/pub/newlib"
    18     avr32headers_src="http://dev.doredevelopment.dk/avr32-toolchain/sources"
    19 
    20     if [ -z "${CT_LIBC_NEWLIB_CVS}" ]; then
    21         CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
    22     else
    23         CT_GetCVS "$(libc_newlib_basename)"                         \
    24                   ":pserver:anoncvs@sources.redhat.com:/cvs/src"    \
    25                   "newlib"                                          \
    26                   "${CT_LIBC_VERSION}"                              \
    27                   "$(libc_newlib_basename)=src"
    28     fi
    29 
    30     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    31         CT_GetFile "avr32headers" ${avr32headers_src}
    32     fi
    33 }
    34 
    35 do_libc_extract() {
    36     CT_Extract "$(libc_newlib_basename)"
    37     CT_Patch "$(libc_newlib_basename)"
    38 
    39     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    40         CT_Extract "avr32headers"
    41     fi
    42 }
    43 
    44 do_libc_check_config() {
    45     :
    46 }
    47 
    48 do_libc_headers() {
    49     :
    50 }
    51 
    52 do_libc_start_files() {
    53     :
    54 }
    55 
    56 do_libc() {
    57     CT_DoStep INFO "Installing C library"
    58 
    59     mkdir -p "${CT_BUILD_DIR}/build-libc"
    60     cd "${CT_BUILD_DIR}/build-libc"
    61 
    62     CT_DoLog EXTRA "Configuring C library"
    63 
    64     # Note: newlib handles the build/host/target a little bit differently
    65     # than one would expect:
    66     #   build  : not used
    67     #   host   : the machine building newlib
    68     #   target : the machine newlib runs on
    69     CC_FOR_BUILD="${CT_BUILD}-gcc"                      \
    70     CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS} -O"          \
    71     AR=${CT_TARGET}-ar                                  \
    72     RANLIB=${CT_TARGET}-ranlib                          \
    73     CT_DoExecLog ALL                                    \
    74     "${CT_SRC_DIR}/$(libc_newlib_basename)/configure"   \
    75         --host=${CT_BUILD}                              \
    76         --target=${CT_TARGET}                           \
    77         --prefix=${CT_PREFIX_DIR}
    78     
    79     CT_DoLog EXTRA "Building C library"
    80 
    81     CT_DoExecLog ALL make ${PARALLELMFLAGS}
    82     
    83     CT_DoLog EXTRA "Installing C library"
    84 
    85     CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
    86 
    87     CT_EndStep
    88 }
    89 
    90 do_libc_finish() {
    91     CT_DoStep INFO "Finishing C library"
    92     
    93     if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
    94         CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
    95         CT_DoExecLog ALL cp -r ${CT_SRC_DIR}/avr32headers "${CT_PREFIX_DIR}/${CT_TARGET}/include/avr32"
    96     fi
    97 
    98     CT_EndStep
    99 }