aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/update-binutils
blob: ae2ca80fe42b2975fe5dbc6eeceaf7c9db616c7d (plain)
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
#!/bin/sh

set -ef

TARGETS="x86_64-elf aarch64-elf"

[ -z "$1" ] && echo "$0: missing url" && exit 1

if [ -n "$2" ]; then
    TARGETS="$2"
fi

TMPFILE=$(mktemp)
TMPDIR=$(mktemp -d)

echo "downloading..."
curl -o "$TMPFILE" "$1"
echo "extracting..."
tar Jxf "$TMPFILE" --strip-components=1 -C "$TMPDIR"
echo "cleaning up temp file"
rm "$TMPFILE"
cd "$TMPDIR"
for TARGET in $TARGETS
do
    echo "configuring target $TARGET..."
    ./configure --target="$TARGET" --prefix="$HOME/opt/cross" \
        --disable-nls --disable-werror --disable-libdecnumber --disable-readline --disable-sim
    echo "building target $TARGET..."
    make MAKEINFO=true -j "$(nproc)"
    echo "installing target $TARGET..."
    make MAKEINFO=true install
    echo "cleaning after target $TARGET"
    make distclean
done
echo "cleaning up temp dir"
rm -rf "$TMPDIR"