crosstool-ng/scripts/build/libc/newlib.sh
Martin Guy e284b218a7 arch/avr32: Fix download of header files
This patch fixes the download of the avr32 headers in crosstool-ng by
fetching them directly from Atmel's web site instead of the now-broken URL
given by the original author of the avr32-header-fetching modification,
who fetched them from a copy on his own, now-defunct server.

It also adds the necessary logic to extract from a zip file, as that is
how the headers are packaged.

To configure it for avr32 after launching ct-ng menuconfig in an empty
directory:

       Paths and misc options ->
               Shell to use as CONFIG_SHELL = sh
       Target options ->
               Target Architecture = avr32
       Toolchain options ->
               Tuple's alias = avr32
       Binary utilities ->
               binutils version = 2.18a
       C compiler
               gcc version = 4.2.2
       C-library
               newlib version = 1.17.0
               Enable IOs on long long = yes
               Enable IOs on floats and doubles = yes
               Disable the syscalls supplied with newlib = yes

CONFIG_SHELL is necessary to get round the "fragment: command not
found" bug when binutils-2.18 is configured using bash.

Prepared against crosstool-ng mercurial trunk on 31 March 2012.

Signed-off-by: Martin Guy <martinwguy@gmail.com>
[yann.morin.1998@free.fr: update bundles sample accordingly]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <CAL4-wQrg_NQ7jm-NCADqeyQr9twyhtx42OUGNThP6gWeqZc=kw@mail.gmail.com>
Patchwork-Id: 232612
2013-03-31 04:07:38 +00:00

139 lines
4.9 KiB
Bash

# This file adds functions to build the Newlib C library
# Copyright 2009 DoréDevelopment
# Licensed under the GPL v2. See COPYING in the root of this package
#
# Edited by Martin Lund <mgl@doredevelopment.dk>
#
do_libc_get() {
local libc_src="ftp://sourceware.org/pub/newlib"
local avr32headers_src="http://www.atmel.com/Images"
avr32headers_base="avr-headers-3.2.3.970" # used below
local avr32headers_ext=".zip"
if [ "${CT_LIBC_NEWLIB_CUSTOM}" = "y" ]; then
CT_GetCustom "newlib" "${CT_LIBC_VERSION}" \
"${CT_LIBC_NEWLIB_CUSTOM_LOCATION}"
else # ! custom location
CT_GetFile "newlib-${CT_LIBC_VERSION}" ${libc_src}
fi # ! custom location
if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
CT_GetFile ${avr32headers_base} ${avr32headers_ext} ${avr32headers_src}
fi
}
do_libc_extract() {
# If using custom directory location, nothing to do
if [ "${CT_LIBC_NEWLIB_CUSTOM}" != "y" \
-a -d "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}" ]; then
return 0
fi
CT_Extract "newlib-${CT_LIBC_VERSION}"
CT_Patch "newlib" "${CT_LIBC_VERSION}"
if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
# The avr32header zip file extracts to avr32/*.h
# Put that in its directory, the same as normal tarballs
CT_Extract ${avr32headers_base} -d ${CT_SRC_DIR}/${avr32headers_base}
fi
}
do_libc_check_config() {
:
}
do_libc_start_files() {
if [ "${CT_ATMEL_AVR32_HEADERS}" = "y" ]; then
CT_DoStep INFO "Installing C library headers & start files"
CT_DoLog EXTRA "Installing Atmel's AVR32 headers"
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include"
CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/${avr32headers_base}/avr32" \
"${CT_PREFIX_DIR}/${CT_TARGET}/include/"
CT_EndStep
fi
}
do_libc() {
local -a newlib_opts
CT_DoStep INFO "Installing C library"
mkdir -p "${CT_BUILD_DIR}/build-libc"
cd "${CT_BUILD_DIR}/build-libc"
CT_DoLog EXTRA "Configuring C library"
if [ "${CT_LIBC_NEWLIB_IO_C99FMT}" = "y" ]; then
newlib_opts+=( "--enable-newlib-io-c99-formats" )
else
newlib_opts+=( "--disable-newlib-io-c99-formats" )
fi
if [ "${CT_LIBC_NEWLIB_IO_LL}" = "y" ]; then
newlib_opts+=( "--enable-newlib-io-long-long" )
else
newlib_opts+=( "--disable-newlib-io-long-long" )
fi
if [ "${CT_LIBC_NEWLIB_IO_FLOAT}" = "y" ]; then
newlib_opts+=( "--enable-newlib-io-float" )
if [ "${CT_LIBC_NEWLIB_IO_LDBL}" = "y" ]; then
newlib_opts+=( "--enable-newlib-io-long-double" )
else
newlib_opts+=( "--disable-newlib-io-long-double" )
fi
else
newlib_opts+=( "--disable-newlib-io-float" )
newlib_opts+=( "--disable-newlib-io-long-double" )
fi
if [ "${CT_LIBC_NEWLIB_DISABLE_SUPPLIED_SYSCALLS}" = "y" ]; then
newlib_opts+=( "--disable-newlib-supplied-syscalls" )
else
newlib_opts+=( "--enable-newlib-supplied-syscalls" )
fi
[ "${CT_LIBC_NEWLIB_ENABLE_TARGET_OPTSPACE}" = "y" ] && newlib_opts+=("--enable-target-optspace")
# Note: newlib handles the build/host/target a little bit differently
# than one would expect:
# build : not used
# host : the machine building newlib
# target : the machine newlib runs on
CT_DoExecLog CFG \
CC_FOR_BUILD="${CT_BUILD}-gcc" \
CFLAGS_FOR_TARGET="${CT_TARGET_CFLAGS}" \
AR=${CT_TARGET}-ar \
RANLIB=${CT_TARGET}-ranlib \
"${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/configure" \
--host=${CT_BUILD} \
--target=${CT_TARGET} \
--prefix=${CT_PREFIX_DIR} \
"${newlib_opts[@]}" \
"${CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY[@]}"
CT_DoLog EXTRA "Building C library"
CT_DoExecLog ALL make ${JOBSFLAGS}
CT_DoLog EXTRA "Installing C library"
CT_DoExecLog ALL make install install_root="${CT_SYSROOT_DIR}"
if [ "${CT_BUILD_MANUALS}" = "y" ]; then
local -a doc_dir="${CT_BUILD_DIR}/build-libc/${CT_TARGET}"
CT_DoLog EXTRA "Building and installing the C library manual"
CT_DoExecLog ALL make pdf html
# NEWLIB install-{pdf.html} fail for some versions
CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share/doc/newlib"
CT_DoExecLog ALL cp -av "${doc_dir}/newlib/libc/libc.pdf" \
"${doc_dir}/newlib/libm/libm.pdf" \
"${doc_dir}/newlib/libc/libc.html" \
"${doc_dir}/newlib/libm/libm.html" \
"${CT_PREFIX_DIR}/share/doc/newlib"
fi
CT_EndStep
}