aboutsummaryrefslogtreecommitdiffstats
path: root/testing/newlib/APKBUILD
blob: 3d09b2fba98973147f877c1928591e8da738c534 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>

_pkgbase=newlib
_targets="
	mips-mti-elf
	msp430-elf
	arm-none-eabi
	"
pkgname="$_pkgbase"
pkgver="3.0.0.20180831"
pkgrel=1
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}:${targetnorm} ${subpackages}"
	makedepends="binutils-${target} gcc-${target} ${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-}"
	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"
	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"