-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·127 lines (102 loc) · 2.25 KB
/
build.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
#! /bin/bash
set -eu
if [[ $# -gt 1 ]]; then
echo "Usage: $0 [--prefix=/your/path]"
exit 1
fi
echo $root_path
root_path=$(pwd)
if [[ $# -eq 1 ]]; then
case $1 in
--prefix=*)
root_path="${1#*=}"
;;
*)
echo "Usage: $0 [--prefix=/your/path]"
exit 1
;;
esac
fi
function init() {
mkdir -p build && cd build
mkdir -p $root_path
mkdir -p $root_path/sysroot
mkdir -p $root_path/sysroot/usr
mkdir -p $root_path/sysroot/usr/include
mkdir -p $root_path/sysroot/usr/lib
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
export PATH=$PATH:$root_path/bin/bin
git submodule init
git submodule update --recursive --remote --progress --depth 1
}
function build_binutils() {
../binutils/configure \
--target=riscv64-caffeinix \
--prefix=$root_path/bin \
--disable-werror \
--disable-bootstrap \
--enable-languages=c \
--disable-libstdcxx \
--without-headers \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-libatomic \
--disable-libitm \
--disable-libvtv \
--disable-libsanitizer
make -j$(nproc) && make install
rm -rf *
}
function build_gcc() {
../gcc/configure \
--target=riscv64-caffeinix \
--prefix=$root_path/bin \
--disable-werror \
--disable-bootstrap \
--enable-languages=c \
--disable-libstdcxx \
--without-headers \
--disable-libssp \
--disable-libquadmath \
--disable-libgomp \
--disable-libatomic \
--disable-libitm \
--disable-libvtv \
--disable-libsanitizer
make -j$(nproc) && make install
rm -rf *
}
function build_binutils1() {
../binutils/configure \
--target=riscv64-caffeinix \
--prefix=$root_path/bin \
--disable-werror \
-with-sysroot=$root_path/sysroot
make -j$(nproc) && make install
rm -rf *
}
function build_gcc1() {
../gcc/configure \
--target=riscv64-caffeinix \
--prefix=$root_path/bin \
--enable-languages=c \
-with-sysroot=$root_path/sysroot
make -j$(nproc) && make install
rm -rf *
}
function build_newlib() {
rm -rf *
../newlib/configure --prefix=/usr --target=riscv64-caffeinix
make -j$(nproc) && make DESTDIR=$root_path/sysroot install
cp -ar $root_path/sysroot/usr/riscv64-caffeinix/* $root_path/sysroot/usr
rm -rf *
}
init
build_binutils
build_gcc
build_newlib
rm -rf $root_path/bin/*
build_binutils1
build_gcc1
cd ..