aboutsummaryrefslogtreecommitdiffstats
path: root/testing/picolibc/APKBUILD
blob: 5ee7fb8ba8e3c4dbc9342810774c0e70055685ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>

_targets="
	arm-none-eabi
	riscv-none-elf
	"
pkgname=picolibc
pkgver=1.7.7
pkgrel=0
pkgdesc="A C standard library based on newlib with focus on compact size"
url="https://github.com/picolibc/picolibc"
makedepends="meson"
# s390x blocked by gcc-cross-embedded
arch="all !s390x"
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="$pkgname-$pkgver.tar.xz::https://github.com/picolibc/picolibc/releases/download/$pkgver/picolibc-$pkgver.tar.xz"
options="!check"

for target in $_targets; do
	targetnorm="${target//-/_}"
	subpackages="picolibc-$target:$targetnorm $subpackages"
	makedepends="binutils-$target gcc-$target newlib-$target $makedepends"
done

prepare() {
	default_prepare

	# Handle mismatch of target triples
	mv "$builddir/scripts/cross-riscv64-unknown-elf.txt" \
		"$builddir/scripts/cross-riscv-none-elf.txt"
	sed -e 's/riscv64-unknown-elf/riscv-none-elf/g' \
		-i "$builddir/scripts/cross-riscv-none-elf.txt"
}

build() {
	for target in $_targets; do
		# cannot use abuild-meson here, as target != host
		meson \
			--prefix=/usr/ \
			--buildtype=plain \
			--cross-file=scripts/cross-$target.txt \
			-Dincludedir=picolibc/$target/include \
			-Dlibdir=picolibc/$target/lib \
			. build-$target
		meson compile -C build-$target
	done
}

package() {
	for target in $_targets; do
		depends="$depends picolibc-$target"
	done
	mkdir -p "$pkgdir"
}

_install_subpkg() {
	target="${subpkgname#picolibc-}"
	pkgdesc="A C standard library based on newlib with focus on compact size for $target"
	depends="binutils-$target gcc-$target $depends"

	DESTDIR="$subpkgdir" meson install -C "$builddir/build-$target"
}

arm_none_eabi() {
	_install_subpkg
}

riscv_none_elf() {
	_install_subpkg
}

sha512sums="
afb8bd40601a0ecc46fffa15e23078d3a87b241212a48298f4d604ca482cba59dd3f0f7a7d4c7d69520d2b4261bb364da8fc4c46946c601c2423ab00920c08d9  picolibc-1.7.7.tar.xz
"