This repository has been archived by the owner on Jul 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·184 lines (161 loc) · 5.09 KB
/
install.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
# Install script that will look for the required dependencies in the envionrment and will try to install them
# if not found. Once all the required dependencies are installed the script will build tinyDLM from source and
# launch the program.
# I only provide cURLpp source since it does not seem to be found on some Linux distributions using apt.
# macOS
# libcurl and libncurses will be installed via homebrew if homebrew is installed. Otherwise the installation
# will stop.
# Linux
# lbcurl and libncurses will be installed via apt on Linux Debian distributions. Otherwise the installation
# will stop.
# set some bools
linux=0
macos=0
# set some bools
apt=0
brew=0
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
linux=1
echo Using Linux...
# temporary
apt=1
# check apt presence
elif [[ "$OSTYPE" == "darwin"* ]]; then
macos=1
echo Using macOS...
echo checking if brew is installed...
brewout=$( { brew > tmp; } 2>&1 )
if [[ $brewout == *"brew install FORMULA"* ]]; then
brew=1
echo brew is installed.
else
echo brew is not installed.
fi
else
echo tinyDLM can only be installed on Linux and macOS for now.
fi
mkdir -p app/downloads
mkdir build
cd build
# comp will either be "gcc" or "clang"
comp="0"
# set some bools
gcc=0
clang=0
# check for gcc or clang presence
gccout=$( { gcc > tmp; } 2>&1 )
if [[ $gccout == *"no input files"* ]]; then
echo "gcc is installed"
comp="gcc"
else
echo "gcc is not installed"
echo "checking if clang is installed..."
fi
if [[ "${comp}" == "0" ]]
then
clout=$( { clang -v > tmp; } 2>&1 )
if [[ $clout == *"Apple clang"* ]]; then
echo "clang is installed"
comp="clang"
else
echo "clang is not installed"
fi
fi
# set some bools
curl=0
curlpp=0
ncurses=0
if [ "${comp}" != "0" ]; then
curlout=$( { ${comp} -lcurl > tmp; } 2>&1 )
if [[ $curlout != *"main"* ]]; then
echo "curl dev libraries are not installed"
if [ "$brew" -eq 1 ]; then
read -p "Do you want to install libcurl-dev (using homebrew)? [Y/n] " answer
if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then
brew install curl --with-openssl
curl=1
echo curl dev libraries are installed
else
echo Please install curl dev libraries
fi
elif [ "$apt" -eq 1 ]; then
read -p "Do you want to install curl dev libraries (using apt)? [Y/n] " answer
if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then
sudo apt-get install libcurl4-openssl-dev
curl=1
echo curl dev libraries are installed.
fi
else
echo Please install curl dev libraries.
fi
else
curl=1
echo "curl dev libraries are installed."
fi
# Build curlpp from source
curlppout=$( { ${comp} -lcurlpp > tmp; } 2>&1 )
if [[ $curlppout != *"main"* ]]; then
echo "curlpp is not installed"
read -p "Do you want to install curlpp ? Y/n " answer
if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then
cd ../dependencies/curlpp-0.8.1
mkdir build
cd build
sudo cmake ../
sudo make install
cd ../../../build
curlpp=1
echo curlpp is installed
fi
else
curlpp=1
echo "curlpp is installed."
fi
ncursesout=$( { ${comp} -lncurses > tmp; } 2>&1 )
if [[ $curlppout != *"main"* ]]; then
echo "ncurses dev libraries are not installed"
if [ "$brew" -eq 1 ]; then
read -p "Do you want to install ncurses dev libraries (using homebrew)? [Y/n] " answer
if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then
brew install ncurses
ncurses=1
else
echo Please install ncurses.
fi
elif [ "$apt" -eq 1 ]; then
read -p "Do you want to install ncurses dev libraries (using apt)? [Y/n] " answer
if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then
sudo apt-get install libncurses-dev
ncurses=1
echo ncurses dev libraries are installed
fi
else
echo Please install ncurses dev libraries.
fi
else
ncurses=1
echo "ncurses dev libraries are installed."
fi
else
echo Please installed all the required dependencies.
fi
# rm tmp files
rm tmp
rm ../tmp
# if everything required is installed
if [ "${comp}" != "0" ] && [ "${curl}" -eq 1 ] && [ "${curlpp}" -eq 1 ] && [ "${ncurses}" -eq 1 ]; then
# run cmake from build
cmake ../
# run make
make
if [ ! -f tinyDLM ]; then
echo "Couldn't locate tinyDLM. Build certainly failed. Check cmake error logs."
elif [ -f tinyDLM ]; then
mv tinyDLM ../app/tinyDLM
echo tinyDLM was successfully built in app/.
fi
else
echo Installation failed. Please install all required dependencies.
fi
rm -r ../build