1 # Maintainer: Filipe LaĆns (FFY00) <lains@archlinux.org>
2 # Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
5 pkgname=$_target-newlib
9 pkgdesc='A C standard library implementation intended for use on embedded systems (RISCV32 bare metal)'
11 url='https://www.sourceware.org/newlib/'
13 makedepends=($_target-gcc)
14 options=(!emptydirs !strip)
15 source=(https://sourceware.org/pub/newlib/newlib-$_upstream_ver.tar.gz)
16 sha256sums=('58dd9e3eaedf519360d92d84205c3deef0b3fc286685d1c562e245914ef72c66')
19 rm -rf build-{newlib,nano}
20 mkdir build-{newlib,nano}
22 export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'
23 cd "$srcdir"/build-newlib
24 ../newlib-$_upstream_ver/configure \
27 --enable-newlib-io-long-long \
28 --enable-newlib-io-c99-formats \
29 --enable-newlib-register-fini \
30 --enable-newlib-retargetable-locking \
31 --disable-newlib-supplied-syscalls \
35 export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
36 cd "$srcdir"/build-nano
37 ../newlib-$_upstream_ver/configure \
40 --disable-newlib-supplied-syscalls \
41 --enable-newlib-reent-small \
42 --enable-newlib-retargetable-locking \
43 --disable-newlib-fvwrite-in-streamio \
44 --disable-newlib-fseek-optimization \
45 --disable-newlib-wide-orient \
46 --enable-newlib-nano-malloc \
47 --disable-newlib-unbuf-stream-opt \
49 --enable-newlib-global-atexit \
50 --enable-newlib-nano-formatted-io \
56 cd "$srcdir"/build-nano
57 make DESTDIR="$pkgdir" install -j1
58 find "$pkgdir" -regex ".*/lib\(c\|g\|rdimon\)\.a" -exec rename .a _nano.a '{}' \;
59 install -d "$pkgdir"/usr/$_target/include/newlib-nano
60 install -m644 -t "$pkgdir"/usr/$_target/include/newlib-nano "$pkgdir"/usr/$_target/include/newlib.h
62 cd "$srcdir"/build-newlib
63 make DESTDIR="$pkgdir" install -j1
65 find "$pkgdir"/usr/$_target/lib \( -name "*.a" -or -name "*.o" \) \
66 -exec $_target-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges \
67 -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line \
68 -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
70 install -d "$pkgdir"/usr/share/licenses/$pkgname/
71 install -m644 -t "$pkgdir"/usr/share/licenses/$pkgname/ "$srcdir"/newlib-$_upstream_ver/COPYING*