-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·160 lines (140 loc) · 4.98 KB
/
install.sh
File metadata and controls
executable file
·160 lines (140 loc) · 4.98 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#! /bin/bash
set -eux
function _on_exit {
echo "Script ended"
}
trap _on_exit EXIT
Help()
{
# Display Help
echo "Install script for the development environment."
echo
echo "Syntax: ./install.sh [-j|-h]"
echo "Example ./install.sh -j <number-of-threads>"
echo "Options:"
echo "-j Number of cores to be used during building."
echo "-h Prints this help."
}
# ================ HANDLING OPTIONS ================
NBTHREADS=""
while getopts ":j:h" option; do
case $option in
j)
NBTHREADS=$OPTARG;;
h)
Help
exit;;
\?)
echo "Error: Invalid option"
exit;;
esac
done
mkdir -p env
WORKSPACE=$(dirname $(readlink -f ${0}))
INSTALL_DIR=$(mktemp -d)
cd $INSTALL_DIR
# ================ INSTALLING GCC ================
# check if gcc is empty, if not, do nothing.
if [[ -z $(ls -A "${WORKSPACE}/env/gcc") ]]; then
mkdir -p "${WORKSPACE}/env/gcc"
wget https://ftp.gwdg.de/pub/misc/gcc/releases/gcc-13.2.0/gcc-13.2.0.tar.gz
tar -vxzf ./gcc-13.2.0.tar.gz
cd ./gcc-13.2.0
./contrib/download_prerequisites
mkdir objdir
cd objdir
if [[ "$OSTYPE" == "darwin"* ]]; then
../configure --prefix=$WORKSPACE/env/gcc --enable-languages=c,c++ --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
../configure --prefix=$WORKSPACE/env/gcc --enable-languages=c,c++ --disable-multilib
fi
if [[ "$NBTHREADS" != "" ]]; then
make -j $NBTHREADS
else
make
fi
make install
else
echo "gcc is already installed"
fi
# ================ INSTALLING CMAKE ================
if [[ -z $(ls -A "${WORKSPACE}/env/cmake") ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
wget https://github.com/Kitware/CMake/releases/download/v3.29.1/cmake-3.29.1-linux-x86_64.tar.gz
tar -vxzf cmake-3.29.1-linux-x86_64.tar.gz
rm -rf cmake-3.29.1-linux-x86_64.tar.gz
mv cmake-3.29.1-linux-x86_64 "${WORKSPACE}/env/cmake" # rename to cmake
elif [[ "$OSTYPE" == "darwin"* ]]; then
wget https://github.com/Kitware/CMake/releases/download/v3.29.1/cmake-3.29.1-macos10.10-universal.tar.gz
tar -vxzf cmake-3.29.1-macos10.10-universal.tar.gz
rm -rf cmake-3.29.1-macos10.10-universal.tar.gz
mv cmake-3.29.1-macos10.10-universal "${WORKSPACE}/env/cmake" # rename to cmake
fi
else
echo "CMake is already installed"
fi
# ================ INSTALLING OPENSSL ================
if [[ -z $(ls -A "${WORKSPACE}/env/openssl") ]]; then
mkdir -p "${WORKSPACE}/env/openssl"
# determine which version of openssl to install
version=$(openssl version | sed 's/^[^[:space:]]* //' | sed 's/ .*//')
if [[ "${version}" == "3.0"* ]]; then
wget https://www.openssl.org/source/old/3.0/openssl-${version}.tar.gz
elif [[ "${version}" == "3.1"* ]]; then
wget https://www.openssl.org/source/old/3.1/openssl-${version}.tar.gz
elif [[ "${version}" == "3.2"* ]]; then
wget https://www.openssl.org/source/old/3.2/openssl-${version}.tar.gz
elif [[ "${version}" == "3.3"* ]]; then
wget https://www.openssl.org/source/old/3.3/openssl-${version}.tar.gz
fi
tar -vxf openssl-${version}.tar.gz
cd openssl-${version}
./Configure --prefix=$WORKSPACE/env/openssl --openssldir=$WORKSPACE/env/openssl no-ssl2
if [[ "$NBTHREADS" != "" ]]; then
make -j $NBTHREADS
else
make
fi
make install
else
echo "OpenSSL is already installed"
fi
# ================ INSTALLING PYTHON ================
if [[ -z $(ls -A "${WORKSPACE}/env/python") ]]; then
mkdir -p "${WORKSPACE}/env/python"
wget https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tar.xz
tar -vxf Python-3.12.1.tar.xz
cd Python-3.12.1
LDFLAGS="-L$WORKSPACE/env/openssl/lib/ -L$WORKSPACE/env/openssl/lib64/" \
LD_LIBRARY_PATH="$WORKSPACE/env/openssl/lib/:$WORKSPACE/env/openssl/lib64/" \
CPPFLAGS="-I/$WORKSPACE/env/openssl/include -I/$WORKSPACE/env/openssl/include/openssl" \
./configure --with-openssl="$WORKSPACE/env/openssl" --enable-shared --prefix=$WORKSPACE/env/python
if [[ "$NBTHREADS" != "" ]]; then
make -j $NBTHREADS
else
make
fi
make install
else
echo "Python is already installed"
fi
# ================ INSTALLING NINJA ================
if [[ -z $(ls -A "${WORKSPACE}/env/ninja") ]]; then
mkdir -p "${WORKSPACE}/env/ninja/bin"
if [[ "$OSTYPE" == "darwin"* ]]; then
wget https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip
unzip ninja-mac.zip
rm ninja-mac.zip
mv ninja $WORKSPACE/env/ninja/bin
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
wget https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip
unzip ninja-linux.zip
rm ninja-linux.zip
mv ninja $WORKSPACE/env/ninja/bin
fi
else
echo "Ninja is already installed"
fi
echo "Environment installation is finished"
cd $WORKSPACE
rm -rf $INSTALL_DIR