aboutsummaryrefslogtreecommitdiffstats
path: root/testing/picolibc/APKBUILD
blob: fb92ba5ba3aff5c93355c483a32084627a3fac8a (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
75
76
77
78
79
80
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>

_targets="
	arm-none-eabi
	riscv-none-elf
	"
pkgname=picolibc
pkgver=1.7.4
pkgrel=2
pkgdesc="A C standard library based on newlib with focus on compact size"
url="https://github.com/picolibc/picolibc"
makedepends="meson"
# s390x and riscv64 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
	a8ae5ad10df0b14c0b5ab34d7b67d25ede317bdb.patch"
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"

	# We don't really need bash
	find "$builddir/scripts" -type f -exec \
		sed -e 's|#!/bin/bash|#!/bin/sh|g' -i {} \;
}

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="
33fb67a23e36f3dd5934b6cf27d6dbb5abab5bd4439cb4d2c67c31750b590e198e7fc79363874bb775b109eddc636d6970e3cebabd0b857e9071cfcffc2ad351  picolibc-1.7.4.tar.xz
3254abfb6d97ec6b8fdc23cae8c0d094d598155f9766ab1f40613721872d8a0a0b52385eab515b58da1ca521ec40c3e8e3166e1425c798d5674b9124af3fe72c  a8ae5ad10df0b14c0b5ab34d7b67d25ede317bdb.patch
"