forked from lowRISC/lowrisc-toolchains
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-binutils.sh
More file actions
executable file
·106 lines (91 loc) · 2.3 KB
/
build-binutils.sh
File metadata and controls
executable file
·106 lines (91 loc) · 2.3 KB
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
#!/bin/bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
## build-binutils.sh
#
# Builds:
# - GNU Binutils, GDB
#
# Then:
# - Creates a tar file of the whole install directory
set -e -o pipefail
repo_dir="$(git rev-parse --show-toplevel)"
build_dir="${repo_dir}/build"
patch_dir="${repo_dir}/patches"
dist_dir="${build_dir}/dist"
static_libs_dir="${build_dir}/libs"
source "${repo_dir}/sw-versions.sh"
if [ "$#" -ne 1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "USAGE: $0 <target>" >&2
echo >&2
echo "EXAMPLE:" >&2
echo " $0 riscv32" >&2
exit 1
fi
target="$1"
# Double check the arch part of the target tuple.
target_arch="${target/%-*}"
if [ "$target_arch" != "riscv32" ] && [ "$target_arch" != "riscv64" ]; then
echo "Error: unsupported target '${target}'" >&2
echo >&2
echo "Supported arches are: riscv32, riscv64" >&2
exit 1
fi
set -x
mkdir -p "$dist_dir"
mkdir -p "$build_dir"
mkdir -p "$static_libs_dir"
cd "$build_dir"
if [ ! -d binutils ]; then
git clone "$BINUTILS_URL" binutils \
--branch "$BINUTILS_BRANCH" \
--depth 1
fi
if [ ! -d gmp ]; then
tmp=$(mktemp -d)
mkdir -p ${tmp}/gmp
curl -L "$GMP_URL" -o "${tmp}/gmp.tar.xz"
printf "$GMP_SHA256 ${tmp}/gmp.tar.xz\n" > ${tmp}/gmp.sha256
sha256sum -c ${tmp}/gmp.sha256
xzcat ${tmp}/gmp.tar.xz | tar --strip-components=1 -C ${tmp}/gmp -x -v -f -
mv ${tmp}/gmp gmp
rm ${tmp}/gmp.tar.xz
fi
if [ ! -d mpfr ]; then
git clone "$MPFR_URL" mpfr \
--branch "$MPFR_BRANCH" \
--depth 1
fi
cd gmp
./configure \
--enable-static=yes \
--enable-shared=no \
--prefix=$static_libs_dir
make -j "$(nproc)"
make -j "$(nproc)" check
make install
cd ..
cd mpfr
./autogen.sh
./configure \
--enable-static=yes \
--enable-shared=no \
--with-gmp=$static_libs_dir \
--prefix=$static_libs_dir
make -j "$(nproc)"
make install
cd ..
cd binutils
mkdir -p build
cd build
../configure \
--target="$target" \
--program-prefix="$target-" \
--prefix="$dist_dir" \
--with-libexpat-type=static \
--with-gmp=$static_libs_dir \
--with-mpfr=$static_libs_dir
make -j "$(nproc)"
make -C gas check
make install