-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild-newlib
executable file
·58 lines (46 loc) · 1.7 KB
/
build-newlib
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
#!/bin/bash
set -e
NEWLIB_VERSION=newlib-4.2.0.20211231
JOBS=$(nproc --all)
OUT_DIR_NOPIC=$PWD/no-pic
OUT_DIR_PIC=$PWD/pic
mkdir -p $OUT_DIR_NOPIC
mkdir -p $OUT_DIR_PIC
NEWLIB_FLAGS="--disable-newlib-supplied-syscalls \
--disable-nls \
--enable-newlib-reent-small \
--disable-newlib-fvwrite-in-streamio \
--disable-newlib-fseek-optimization \
--disable-newlib-wide-orient \
--enable-newlib-nano-malloc \
--disable-newlib-unbuf-stream-opt \
--enable-lite-exit \
--enable-newlib-global-atexit \
--enable-newlib-nano-formatted-io"
mkdir -p build
cd build
wget -nc ftp://sourceware.org/pub/newlib/$NEWLIB_VERSION.tar.gz
tar --skip-old-files -xaf $NEWLIB_VERSION.tar.gz
cd $NEWLIB_VERSION
mkdir -p build
cd build
../configure --target=arm-none-eabi \
$NEWLIB_FLAGS \
CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections -fshort-wchar"
make -j $JOBS
cp arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libc.a $OUT_DIR_NOPIC/libc_nano.a
cp arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libg.a $OUT_DIR_NOPIC/libg_nano.a
cp arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libm.a $OUT_DIR_NOPIC/
cp arm-none-eabi/thumb/v7e-m+dp/hard/libgloss/libnosys/libnosys.a $OUT_DIR_NOPIC
cd ..
# PIC
mkdir -p build-pic
cd build-pic
../configure --target=arm-none-eabi \
$NEWLIB_FLAGS \
CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections -fshort-wchar -fPIC -mno-pic-data-is-text-relative -mno-single-pic-base"
make -j $JOBS
cp arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libc.a $OUT_DIR_PIC/libc_nano.a
cp arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libg.a $OUT_DIR_PIC/libg_nano.a
cp arm-none-eabi/thumb/v7e-m+dp/hard/newlib/libm.a $OUT_DIR_PIC/
cp arm-none-eabi/thumb/v7e-m+dp/hard/libgloss/libnosys/libnosys.a $OUT_DIR_PIC