aboutsummaryrefslogtreecommitdiffstats
path: root/community/newlib/APKBUILD
diff options
context:
space:
mode:
Diffstat (limited to 'community/newlib/APKBUILD')
-rw-r--r--community/newlib/APKBUILD164
1 files changed, 164 insertions, 0 deletions
diff --git a/community/newlib/APKBUILD b/community/newlib/APKBUILD
new file mode 100644
index 0000000000..889eb1c26a
--- /dev/null
+++ b/community/newlib/APKBUILD
@@ -0,0 +1,164 @@
+# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
+
+# mips-mti-elf fails with "Error: unrecognized opcode `cfc1 $3,$31'"
+_targets="
+ arm-none-eabi
+ msp430-elf
+ riscv-none-elf
+ aarch64-none-elf
+ "
+# or1k-elf fails to build on 32-bit architectures
+case "$CARCH" in
+ x86_64|aarch64|ppc64le|mips64) _targets="$_targets or1k-elf"
+esac
+pkgname=newlib
+pkgver=4.1.0
+pkgrel=0
+pkgdesc="C standard library implementation intended for use on embedded systems"
+url="http://www.sourceware.org/newlib/"
+makedepends="texinfo"
+# s390x, mips64 and riscv64 blocked by gcc-cross-embedded
+arch="all !s390x !mips64 !riscv64"
+license="GPL-2.0-only AND LGPL-2.1-only AND 0BSD AND BSD-3-Clause AND GPL-3.0-only AND LGPL-3.0-only"
+source="ftp://sourceware.org/pub/newlib/newlib-$pkgver.tar.gz"
+options="!check"
+
+for target in $_targets; do
+ targetnorm="${target//-/_}"
+ subpackages="newlib-$target:$targetnorm $subpackages"
+ makedepends="binutils-$target gcc-$target $makedepends"
+done
+
+# secfixes:
+# 4.1.0-r0:
+# - CVE-2021-3420
+
+# 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 newlib-$target"
+ done
+ mkdir -p "$pkgdir"
+}
+
+_install_subpkg() {
+ target="${subpkgname#newlib-}"
+ pkgdesc="A C standard library implementation intended for $target"
+ depends="binutils-$target gcc-$target $depends"
+ 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"
+ find . -regex ".*\(c\|g\|rdimon\|gloss\)\.a" | while read -r _file; 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
+}
+
+or1k_elf() {
+ _install_subpkg
+}
+
+riscv_none_elf() {
+ _install_subpkg
+}
+
+aarch64_none_elf() {
+ _install_subpkg
+}
+
+sha512sums="
+6a24b64bb8136e4cd9d21b8720a36f87a34397fd952520af66903e183455c5cf19bb0ee4607c12a05d139c6c59382263383cb62c461a839f969d23d3bc4b1d34 newlib-4.1.0.tar.gz
+"