-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-dependencies.sh
executable file
·103 lines (85 loc) · 2.43 KB
/
install-dependencies.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
#!/bin/bash
# Function to install packages on Debian-based systems
install_debian() {
sudo apt update
sudo apt install -y build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo curl qemu nasm make
}
# Function to install packages on Gentoo
install_gentoo() {
sudo emerge --ask sys-devel/gcc sys-devel/make sys-devel/bison sys-devel/flex dev-libs/gmp dev-libs/mpc dev-libs/mpfr sys-apps/texinfo app-emulation/qemu dev-lang/nasm
}
# Function to install packages on Fedora
install_fedora() {
sudo dnf install -y gcc gcc-c++ make bison flex gmp-devel libmpc-devel mpfr-devel texinfo curl qemu nasm
}
# Function to install packages on OpenBSD
install_openbsd() {
doas pkg_add -v gmp libmpc mpfr curl qemu nasm gmake
}
# Function to install packages on Arch Linux
install_arch() {
sudo pacman -Syu base-devel gmp libmpc mpfr curl qemu nasm make
}
# Detect the operating system and call the respective function
OS=$(uname -s)
case $OS in
Linux)
if [ -f /etc/os-release ]; then
. /etc/os-release
case $ID in
debian|ubuntu|*mint*|*wsl*)
install_debian
;;
gentoo)
install_gentoo
;;
fedora)
install_fedora
;;
arch|manjaro)
install_arch
;;
*)
echo "Unsupported Linux distribution"
;;
esac
else
echo "Unable to detect the Linux distribution."
fi
;;
OpenBSD)
install_openbsd
;;
*)
echo "Unsupported operating system."
;;
esac
# Install binutils and gcc
cd ~
curl -O https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.xz
curl -O https://ftp.lip6.fr/pub/gcc/releases/gcc-10.2.0/gcc-10.2.0.tar.gz
tar -xzvf gcc-10.2.0.tar.gz
tar -xJvf binutils-2.35.tar.xz
mkdir src
export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"
# Binutils
cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-2.35/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make
make install
# GCC
cd $HOME/src
# The $PREFIX/bin dir _must_ be in the PATH. We did that above.
which -- $TARGET-as || echo $TARGET-as is not in the PATH
mkdir build-gcc
cd build-gcc
../gcc-10.2.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc
echo "Dependency installation script has finished."