forked from openhwgroup/corev-binutils-gdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-corev-binutils-gdb.sh
132 lines (112 loc) · 4.28 KB
/
build-corev-binutils-gdb.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
#!/bin/bash
# Build script for the CORE-V Binutils and GDB.
# Copyright (C) 2020 Embecosm Limited
# Contributor Jessica Mills <jessica_mills@embecosm.com>
# This file is part of the Embecosm GNU toolchain build system for RISC-V.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
export ROOT_PREFIX=$(cd ../ && pwd)
export BINUTILS_GDB_FOLDER=corev-binutils-gdb
export BINUTILS_GDB_PREFIX=${ROOT_PREFIX}/${BINUTILS_PREFIX}
export BUILD_BINUTILS_FOLDER=build-${BINUTILS_GDB_FOLDER}
export BUILD_BINUTILS_PREFIX=${ROOT_PREFIX}/${BUILD_BINUTILS_FOLDER}
export INSTALL_FOLDER=toolchain-install
export INSTALL_PREFIX=${ROOT_PREFIX}/${INSTALL_FOLDER}
mkdir -p ${INSTALL_PREFIX}
PARALLEL_JOBS=$(nproc)
DEFAULTARCH=rv32i
DEFAULTABI=ilp32
if [[ $* == *--debug* ]]; then
export BUILD_BINGDB_PREFIX=${ROOT_PREFIX}/${BUILD_BINUTILS_FOLDER}-DEBUG
else
export BUILD_BINGDB_PREFIX=${ROOT_PREFIX}/${BUILD_BINUTILS_FOLDER}
fi
installs=(
"riscv32-corev-elf-addr2line"
"riscv32-corev-elf-nm"
"riscv32-corev-elf-ar"
"riscv32-corev-elf-objcopy"
"riscv32-corev-elf-objdump"
"riscv32-corev-elf-ranlib"
"riscv32-corev-elf-c++filt"
"riscv32-corev-elf-readelf"
"riscv32-corev-elf-run"
"riscv32-corev-elf-elfedit"
"riscv32-corev-elf-gdb"
"riscv32-corev-elf-size"
"riscv32-corev-elf-gprof"
"riscv32-corev-elf-strings"
"riscv32-corev-elf-ld"
"riscv32-corev-elf-strip"
"riscv32-corev-elf-ld.bfd"
"riscv32-corev-elf-as"
"riscv32-corev-elf-gcc-ar"
"riscv32-corev-elf-gcc-nm"
"riscv32-corev-elf-gcc-ranlib"
"riscv32-corev-elf-gcov"
"riscv32-corev-elf-gcov-dump"
"riscv32-corev-elf-cpp"
"riscv32-corev-elf-gcov-tool"
"riscv32-corev-elf-gcc"
"riscv32-corev-elf-gcc-7.1.1"
"riscv32-corev-elf-c++"
"riscv32-corev-elf-g++"
)
if [[ $* == *--help* || $* == *-h* ]]; then
echo "Usage: build-corev-binutils-gdb.sh [--clean] [--debug] [--help | -h]"
echo " Builds and installs the COREV binutils and GDB"
echo " Build directory is the peer directory 'build', install directory is the peer directory 'install'"
echo " Generates installation summary - this is the only action if no options are specified"
echo "The options are:"
echo " --clean Remove build directory"
echo " --debug Include debugging CFLAGS"
echo " --help | -h Print this help message and exit"
exit 0
fi
if [[ $* == *--clean* ]]; then
if [[ -d ${BUILD_BINGDB_PREFIX} ]]; then
echo Cleaning... ${BUILD_BINGDB_PREFIX}
rm -rf ${BUILD_BINGDB_PREFIX}
fi
fi
# Binutils-gdb
mkdir -p ${BUILD_BINGDB_PREFIX}
cd ${BUILD_BINGDB_PREFIX}
../${BINUTILS_GDB_FOLDER}/configure \
--target=riscv32-corev-elf \
--prefix=${INSTALL_PREFIX} \
--disable-werror
#CFLAGS as option for debugging
if [[ $* == *--debug* ]]; then
if ! make CFLAGS="-O0 -ggdb3" -j${PARALLEL_JOBS}; then
echo "The build has failed during binutils-gdb!" >/dev/stderr
exit 1
fi
if ! make CFLAGS="-O0 -ggdb3" install; then
echo "The build has failed during binutils-gdb!" >/dev/stderr
exit 1
fi
else
if ! make -j${PARALLEL_JOBS}; then
echo "The build has failed during binutils-gdb!" >/dev/stderr
exit 1
fi
if ! make install; then
echo "The build has failed during binutils-gdb!" >/dev/stderr
exit 1
fi
fi
echo ===== Install summary =====
echo ${INSTALL_PREFIX}/bin/
for install in "${installs[@]}"
do
[ -f ${INSTALL_PREFIX}/bin/${install} ] && echo "${install} ... exists." || echo "${install} ... does not exist."
done