Commit 9ad91686 authored by Marian Buschsieweke's avatar Marian Buschsieweke Committed by Leonardo Arena

testing/newlib-stage1: New aport

Intermediate step in building a cross toolchain for bare metal targets.

This is working around cyclic dependencies between GCC and newlib. The
build order is this:

1. binutils-cross-embedded (final package)
2. gcc-cross-embedded-stage1 (intermediate step, needed for step 3)
3. newlib-stage1 (intermediate step, needed for step 4)
4. gcc-cross-embedded (final package)
5. newlib (final package)
parent 9952bc7f
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
_pkgbase=newlib
_targets="
arm-none-eabi
mips-mti-elf
msp430-elf
"
pkgname="$_pkgbase-stage1"
pkgver="3.0.0.20180831"
pkgrel=0
pkgdesc="A C standard library implementation intended for use on embedded systems"
url="http://www.sourceware.org/newlib/"
makedepends="texinfo"
arch="all"
license="BSD"
source="
ftp://sourceware.org/pub/${_pkgbase}/${_pkgbase}-${pkgver}.tar.gz
"
options="!check"
for target in $_targets; do
targetnorm="${target//-/_}"
subpackages="${_pkgbase}-${target}-stage1:${targetnorm} ${subpackages}"
makedepends="binutils-${target} gcc-${target}-stage1 ${makedepends}"
done
builddir="$srcdir/$_pkgbase-$pkgver"
# This package installes two version of the newlib library to remain compatible
# with projects expecting the GNU ARM Embedded Toolchain [1]. The nano version
# appends the postix "_nano" to the libaries. The is not an arbitrary choice,
# it matches the specs in "/usr/arm-none-eabi/lib/nano.specs", which is
# part of the default newlib installation.
# [1]: https://launchpad.net/gcc-arm-embedded/
build() {
for target in $_targets; do
mkdir "${builddir}/build-$target" "${builddir}/build-$target-nano"
# nano version
cd "${builddir}/build-$target-nano"
"$builddir"/configure \
--target=$target \
--prefix=/usr/ \
--infodir=/deleteme/info \
--mandir=/deleteme/man \
--htmldir=/deleteme/html \
--pdfdir=/deleteme/pdf \
--disable-newlib-supplied-syscalls \
--disable-nls \
--disable-newlib-fseek-optimization \
--disable-newlib-fvwrite-in-streamio \
--disable-newlib-unbuf-stream-opt \
--disable-newlib-wide-orient \
--enable-lite-exit \
--enable-newlib-global-atexit \
--enable-newlib-nano-formatted-io \
--enable-newlib-nano-malloc \
--enable-newlib-reent-small \
CC_FOR_TARGET="$target"-gcc \
GCC_FOR_TARGET="$target"-gcc \
AR_FOR_TARGET="$target"-ar \
AS_FOR_TARGET="$target"-as \
LD_FOR_TARGET="$target"-ld \
NM_FOR_TARGET="$target"-nm \
OBJDUMP_FOR_TARGET="$target"-objdump \
RANLIB_FOR_TARGET="$target"-ranlib \
READELF_FOR_TARGET="$target"-readelf \
STRIP_FOR_TARGET="$target"-strip \
CFLAGS="-Os -ffunction-sections -fdata-sections -fshort-wchar"
make
# regular version
cd "${builddir}/build-$target"
"$builddir"/configure \
--host=$CHOST \
--target=$target \
--prefix=/usr \
--infodir=/deleteme/info \
--mandir=/deleteme/man \
--htmldir=/deleteme/html \
--pdfdir=/deleteme/pdf \
--disable-newlib-supplied-syscalls \
--disable-nls \
--enable-newlib-io-long-long \
--enable-newlib-register-fini \
CC_FOR_TARGET="$target"-gcc \
GCC_FOR_TARGET="$target"-gcc \
AR_FOR_TARGET="$target"-ar \
AS_FOR_TARGET="$target"-as \
LD_FOR_TARGET="$target"-ld \
NM_FOR_TARGET="$target"-nm \
OBJDUMP_FOR_TARGET="$target"-objdump \
RANLIB_FOR_TARGET="$target"-ranlib \
READELF_FOR_TARGET="$target"-readelf \
STRIP_FOR_TARGET="$target"-strip \
CFLAGS="-O2 -ffunction-sections -fdata-sections -pipe"
make
done
}
package() {
for target in $_targets; do
depends="$depends $_pkgbase-$target"
done
mkdir -p "$pkgdir"
}
_install_subpkg() {
pkgdesc="A C standard library implementation intended for ${target}"
target="${subpkgname#$_pkgbase-}"
target="${target%-stage1}"
mkdir -p "$subpkgdir"
# install nano version
cd "${builddir}/build-${target}-nano"
make -j1 DESTDIR="$subpkgdir" install
# rename nano version libs
cd "${subpkgdir}/usr/$target/lib"
for file in $(find . -regex ".*\(c\|g\|rdimon\)\.a"); do
mv "$file" "${file%.a}_nano.a"
done
mkdir -p "${subpkgdir}/usr/$target/include/nano"
mv "${subpkgdir}/usr/$target/include/newlib.h" \
"${subpkgdir}/usr/$target/include/nano/"
# install regular version
cd "${builddir}/build-${target}"
make -j1 DESTDIR="$subpkgdir" install
rm -rf "${subpkgdir}/deleteme"
}
arm_none_eabi() {
_install_subpkg
}
mips_mti_elf() {
_install_subpkg
}
msp430_elf() {
_install_subpkg
}
sha512sums="c195111ac61458fccbd700345cd8ed7806776b3d16557e9a86fbcdf0ff5f544bff7eb701e84defb3f6b4d6fc00674163fa89aead1b171ed3281470a4f6306d1f newlib-3.0.0.20180831.tar.gz"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment