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 (RISCV64 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 sha512sums=('6a24b64bb8136e4cd9d21b8720a36f87a34397fd952520af66903e183455c5cf19bb0ee4607c12a05d139c6c59382263383cb62c461a839f969d23d3bc4b1d34')
19 rm -rf build-{newlib,nano}
20 mkdir build-{newlib,nano}
22 cd "$srcdir"/build-newlib
24 export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'
25 ../newlib-$_upstream_ver/configure \
28 --enable-newlib-io-long-long \
29 --enable-newlib-io-c99-formats \
30 --enable-newlib-register-fini \
31 --enable-newlib-retargetable-locking \
32 --disable-newlib-supplied-syscalls \
36 cd "$srcdir"/build-nano
38 export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections'
39 ../newlib-$_upstream_ver/configure \
42 --disable-newlib-supplied-syscalls \
43 --enable-newlib-reent-small \
44 --enable-newlib-retargetable-locking \
45 --disable-newlib-fvwrite-in-streamio \
46 --disable-newlib-fseek-optimization \
47 --disable-newlib-wide-orient \
48 --enable-newlib-nano-malloc \
49 --disable-newlib-unbuf-stream-opt \
51 --enable-newlib-global-atexit \
52 --enable-newlib-nano-formatted-io \
58 cd "$srcdir"/build-nano
60 make DESTDIR="$pkgdir" install -j1
62 find "$pkgdir" -regex ".*/lib\(c\|g\|m\|rdimon\|gloss\)\.a" -exec rename .a _nano.a '{}' \;
63 install -d "$pkgdir"/usr/$_target/include/newlib-nano
64 install -m644 -t "$pkgdir"/usr/$_target/include/newlib-nano "$pkgdir"/usr/$_target/include/newlib.h
66 cd "$srcdir"/build-newlib
68 make DESTDIR="$pkgdir" install -j1
70 find "$pkgdir"/usr/$_target/lib \( -name "*.a" -or -name "*.o" \) \
71 -exec $_target-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges \
72 -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line \
73 -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;
75 install -d "$pkgdir"/usr/share/licenses/$pkgname/
76 install -m644 -t "$pkgdir"/usr/share/licenses/$pkgname/ "$srcdir"/newlib-$_upstream_ver/COPYING*