forked from ReturnInfinity/BareMetal-OS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newlib.sh
executable file
·65 lines (47 loc) · 1.49 KB
/
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
#!/bin/sh
if [ ! -d "$newlib" ]; then
mkdir newlib
fi
cd newlib
echo Downloading Newlib
wget ftp://sourceware.org/pub/newlib/newlib-2.2.0.tar.gz
tar xf newlib-2.2.0.tar.gz
mkdir build
echo Configuring Newlib
cd ../src/BareMetal-OS/newlib/patches
cp config.sub.patch ../../../../newlib/newlib-2.2.0/
cp configure.host.patch ../../../../newlib/newlib-2.2.0/newlib/
cp configure.in.patch ../../../../newlib/newlib-2.2.0/newlib/libc/sys/
cd ../../../../newlib
cd newlib-2.2.0
patch < config.sub.patch
cd newlib
patch < configure.host.patch
cd libc/sys
patch < configure.in.patch
cd ../../../..
mkdir newlib-2.2.0/newlib/libc/sys/baremetal
cp ../src/BareMetal-OS/newlib/baremetal/* newlib-2.2.0/newlib/libc/sys/baremetal/
cd newlib-2.2.0/newlib/libc/sys
autoconf
cd baremetal
autoreconf
cd ../../../../../build
../newlib-2.2.0/configure --target=x86_64-pc-baremetal --disable-multilib
sed -i 's/TARGET=x86_64-pc-baremetal-/TARGET=/g' Makefile
sed -i 's/WRAPPER) x86_64-pc-baremetal-/WRAPPER) /g' Makefile
echo Building Newlib
make
echo Build complete!
cd x86_64-pc-baremetal/newlib/
cp libc.a ../../..
cp libm.a ../../..
cp crt0.o ../../..
cd ../../..
echo Compiling test application...
cp ../src/BareMetal-OS/newlib/*.* .
gcc -I newlib-2.2.0/newlib/libc/include/ -c test.c -o test.o
ld -T app.ld -o test.app crt0.o test.o libc.a
cp ../src/BareMetal-OS/programs/libBareMetal.* .
gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -mno-red-zone -o libBareMetal.o libBareMetal.c
echo Complete!