Subject: [alpine-aports] [PATCH] testing/newlib-cross-bare-metal: New aport

From: Marian Buschsieweke <[email-masked]>
Date: Tue, 19 Sep 2017 22:44:29 +0200

A C standard library implementation intended for use on embedded systems
http://www.sourceware.org/newlib/

Provides: newlib-arm-none-eabi
---
 testing/newlib-cross-bare-metal/APKBUILD | 107 +++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)
 create mode 100644 testing/newlib-cross-bare-metal/APKBUILD

diff --git a/testing/newlib-cross-bare-metal/APKBUILD b/testing/newlib-cross-bare-metal/APKBUILD
new file mode 100644
index 0000000000..26633fab2d
--- /dev/null
+++ b/testing/newlib-cross-bare-metal/APKBUILD
@@ -0,0 +1,107 @@
+# Contributor: Marian Buschsieweke <[email-masked]>
+# Maintainer: Marian Buschsieweke <[email-masked]>
+
+_pkgbase=newlib
+_targets="arm-none-eabi"
+pkgname="${_pkgbase}-cross-bare-metal"
+pkgver=2.5.0.20170818
+pkgrel=0
+pkgdesc="A C standard library implementation intended for use on embedded systems"
+url="http://www.sourceware.org/newlib/"
+makedepends="texinfo"
+for target in $_targets; do
+	targetnorm="${target//-/_}"
+	makedepends="${makedepends} binutils-${target} gcc-${target}"
+	subpackages="${subpackages} ${_pkgbase}-${target}:${targetnorm}"
+done
+arch="all"
+license="BSD"
+source="ftp://sourceware.org/pub/$_pkgbase/$_pkgbase-$pkgver.tar.gz"
+options="!check"
+
+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"
+		CFLAGS_NANO="-Os -ffunction-sections -fdata-sections -D=__OPTIMIZE_SIZE__ -DPREFER_SIZE_OVER_SPEED"
+		env CFLAGS_FOR_TARGET="$CFLAGS_NANO" "$builddir"/configure \
+			--prefix=/usr/ \
+			--target=$target \
+			--disable-newlib-supplied-syscalls \
+			--enable-newlib-reent-small \
+			--disable-newlib-fvwrite-in-streamio \
+			--disable-newlib-fseek-optimization \
+			--disable-newlib-wide-orient \
+			--enable-newlib-nano-malloc \
+			--disable-newlib-unbuf-stream-opt \
+			--enable-lite-exit \
+			--enable-newlib-global-atexit \
+			--enable-newlib-nano-formatted-io \
+			--disable-nls \
+			--disable-newlib-io-float \
+			--disable-libssp
+		make
+		
+		# regular version
+		cd "${builddir}/build-${target}"
+		"$builddir"/configure \
+			--prefix=/usr/ \
+			--target=$target \
+			--enable-newlib-io-long-long \
+			--enable-newlib-register-fini \
+			--disable-newlib-supplied-syscalls \
+			--disable-nls
+		make
+	done
+}
+
+package() {
+	mkdir -p "${pkgdir}"
+}
+
+install_subpkg() {
+	for dir in include lib/thumb lib/fpu lib/cpu-init; do
+		mkdir -p "${subpkgdir}/usr/${target}/${dir}"
+	done
+	
+	# install nano version
+	cd "${builddir}/build-${target}-nano"
+	make 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
+	
+	# install regular version
+	cd "${builddir}/build-${target}"
+	make DESTDIR="$subpkgdir" install
+	rm -rf "${subpkgdir}/usr/share/man" "${subpkgdir}/usr/share/info"
+}
+
+arm_none_eabi() {
+	target="${subpkgname#${_pkgbase}-}"
+	depends="binutils-${target} gcc-${target}"
+	pkgdesc="A newlib C std lib for platform ${target}"
+	install_subpkg
+}
+
+avr() {
+	target="${subpkgname#${_pkgbase}-}"
+	depends="binutils-${target} gcc-${target}"
+	pkgdesc="A newlib C std lib for platform ${target}"
+	install_subpkg
+}
+
+sha512sums="41382f722232593a9a2bf7de09dc51a26ad51bf8ad06259b0fd38a13cfcd577688e836446d7e88b7741eeec316cfa137ff9b4e16cca846b11bb70948ff1b8c16  newlib-2.5.0.20170818.tar.gz"
-- 
2.14.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---