This repository was archived by the owner on May 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_toolchain.sh
More file actions
executable file
·78 lines (62 loc) · 1.76 KB
/
Copy pathsetup_toolchain.sh
File metadata and controls
executable file
·78 lines (62 loc) · 1.76 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
#!/bin/bash
BINUTILS_VERSION="${BINUTILS_VERSION:-2.40}"
GCC_VERSION="${GCC_VERSION:-11.3.0}"
BINUTILS_URL="https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz"
GCC_URL="https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz"
TARGET=i686-elf
# ---------------------------
set -e
TOOLCHAINS_DIR=/toolchains-InfinityX
OPERATION='build'
while test $# -gt 0
do
case "$1" in
-c) OPERATION='clean'
;;
*) TOOLCHAINS_DIR="$1"
;;
esac
shift
done
if [ -z "$TOOLCHAINS_DIR" ]; then
echo "Missing arg: toolchains directory"
exit 1
fi
pushd $TOOLCHAINS_DIR
TOOLCHAIN_PREFIX="/$TOOLCHAINS_DIR/$TARGET"
if [ "$OPERATION" = "build" ]; then
# Download and build binutils
BINUTILS_SRC="binutils-${BINUTILS_VERSION}"
BINUTILS_BUILD="binutils-build-${BINUTILS_VERSION}"
wget ${BINUTILS_URL}
tar -xf binutils-${BINUTILS_VERSION}.tar.xz
mkdir -p ${BINUTILS_BUILD}
pushd ${BINUTILS_BUILD}
../binutils-${BINUTILS_VERSION}/configure \
--prefix="${TOOLCHAIN_PREFIX}" \
--target=${TARGET} \
--with-sysroot \
--disable-nls \
--disable-werror
make -j8
make install
popd
# Download and build GCC
GCC_SRC="gcc-${GCC_VERSION}"
GCC_BUILD="gcc-build-${GCC_VERSION}"
wget ${GCC_URL}
tar -xf gcc-${GCC_VERSION}.tar.xz
mkdir -p ${GCC_BUILD}
pushd ${GCC_BUILD}
../gcc-${GCC_VERSION}/configure \
--prefix="${TOOLCHAIN_PREFIX}" \
--target=${TARGET} \
--disable-nls \
--enable-languages=c,c++ \
--without-headers
make -j8 all-gcc all-target-libgcc
make install-gcc install-target-libgcc
popd
elif [ "$OPERATION" = "clean" ]; then
rm -rf *
fi