-
Notifications
You must be signed in to change notification settings - Fork 9
/
step5_prepare_newlib.sh
executable file
·152 lines (120 loc) · 3.39 KB
/
step5_prepare_newlib.sh
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
145
146
147
148
149
150
151
152
#! /bin/sh
#
# Build script for V810-GCC.
#
# Stage 5 of 8 - Unpack, patch and configure NEWLIB.
#
OSNAME=`uname -s`
TARGET=v810
GITDIR=$(pwd)
echo GITDIR is $GITDIR
export DSTDIR=$GITDIR/$TARGET-gcc
echo DSTDIR is $DSTDIR
mkdir -p $DSTDIR/bin
export PATH=$DSTDIR/bin:$PATH
#---------------------------------------------------------------------------------
# Check Prerequisites
#---------------------------------------------------------------------------------
## Test for executables
TestEXE()
{
TEMP=`type $1`
if [ $? != 0 ]; then
echo "Error: $1 not installed";
exit 1;
fi
}
TestEXE "make";
TestEXE "gcc";
TestEXE "flex";
TestEXE "patch";
TestEXE "tar";
TestEXE "gzip";
TestEXE "autoconf";
TestEXE "gperf";
TestEXE "bison";
## Test for files to unpack
TestFile()
{
if [ ! -f "$1" ]; then
echo "Error: $1 not found";
exit 1;
fi
}
TestFile "archive/newlib-2.2.0-1.tar.gz";
TestFile "patch/newlib-2.2.0-1-v810.patch";
TestFile "patch/newlib-2.2.0-1-v810-memcpy.patch";
#---------------------------------------------------------------------------------
# Prepare Source and Install directories
#---------------------------------------------------------------------------------
PrepareSource()
{
if [ -e newlib-2.2.0-1 ] ; then
rm -rf newlib-2.2.0-1
fi
if [ -e build/newlib ] ; then
rm -rf build/newlib
fi
tar zxvf archive/newlib-2.2.0-1.tar.gz
cd newlib-2.2.0-1
patch -p 1 -i ../patch/newlib-2.2.0-1-v810.patch
patch -p 1 -i ../patch/newlib-2.2.0-1-v810-memcpy.patch
cd ..
}
if [ -d newlib-2.2.0-1 ] ; then
if [ "${1}" = "clean" ] ; then
PrepareSource
fi
else
PrepareSource
fi
if [ -d build/newlib ] ; then
rm -rf build/newlib
fi
#---------------------------------------------------------------------------------
# Set the target compiler flags
#---------------------------------------------------------------------------------
export CFLAGS='-O2'
export CXXFLAGS='-O2'
if [ "$OS" = "Windows_NT" ] ; then
export LDFLAGS='-Wl,-Bstatic'
else
export LDFLAGS=
fi
if [ "$OSNAME" = "Darwin" ] ; then
BUILD='--build=x86_64-apple-darwin20'
else
BUILD=
fi
#---------------------------------------------------------------------------------
# Build and install binutils
#---------------------------------------------------------------------------------
# Compiling on Windows (mingw/cygwin) requires that this configure is invoked
# from a relative path and not an absolute path. Linux doesn't care.
export SRCDIR=../../newlib-2.2.0-1
export TMPDIR=$GITDIR/build/newlib
mkdir -p $TMPDIR
cd $TMPDIR
$SRCDIR/configure \
--prefix=$DSTDIR \
$BUILD --target=$TARGET \
--disable-multilib \
--disable-newlib-multithread \
--disable-newlib-iconv \
--disable-newlib-fvwrite-in-streamio \
--disable-newlib-fseek-optimization \
--disable-newlib-wide-orient \
--disable-newlib-io-float \
--disable-newlib-atexit-dynamic-alloc \
--disable-newlib-supplied-syscalls \
--enable-newlib-global-atexit \
--enable-newlib-nano-formatted-io \
--enable-newlib-nano-malloc \
--enable-newlib-reent-small \
--enable-lite-exit \
--enable-newlib-hw-fp \
2>&1 | tee newlib_configure.log
cd ../../
echo
echo "$0 finished, don't forget to check for any error messages."
exit 0;