-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·173 lines (148 loc) · 3.89 KB
/
setup.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
#!/bin/bash
# Setup the configuration of platform and MOSEK
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
blue='\033[0;34m'
plain='\033[0m'
echo "# Configuration file for MOSEK and platform." > config.mk
echo "Creating 'build' directory..."
make_build=`mkdir build`
if [[ $? -eq 0 ]]; then
echo -e "${green}[Succeed]${plain} 'build' directioy has been created"
else
echo -e "${yellow}[Warning]${plain} Something wrong. "
read -p "Press enter to continue."
fi
echo
echo "----------------------------------------"
echo "Setting up the configuration about MOSEK and platform"
if [[ $# -eq 1 ]]; then
mskhome=$1
echo -e "The path to MOSEK is set to ${blue}${mskhome}${plain}"
else
echo -e "Please input your home folder of MOSEK ${blue}<MSKHOME>${plain}:"
read mskhome
fi
echo "MSKHOME="${mskhome} >> config.mk
echo
echo "----------------------------------------"
echo "MOSEK versions in the given directory:"
versions=()
i=0
for dir in `ls ${mskhome}/mosek`
do
if [ -d ${mskhome}"/mosek/"$dir ]
then
let i++
versions[$i]=$dir
echo $i") "$dir
fi
done
echo "----------------------------------------"
choose_version(){
read -p "Found multiple versions, please choose one:" versionNum
if [[ $versionNum -gt 0 && $versionNum -lt $i+1 ]]
then
mskversion=${versions[$versionNum]}
echo -e "Selecting version: ${blue}${mskversion}${plain}"
echo "MSKVERSION="${mskversion} >> config.mk
else
echo -e "${red}[Error]${plain} Input number is not valid, please try again."
choose_version
fi
}
if [ "$i" -eq "0" ]
then
echo -e "${red}[Error]${plain} No MOSEK version is found"
exit 1
elif [ "$i" -eq "1" ]
then
mskversion=${versions[1]}
echo -e "Selecting the only one version found: ${blue}${mskversion}${plain}"
echo "MSKVERSION="${mskversion} >> config.mk
read -p "Press enter to continue."
else
choose_version
fi
echo
echo "----------------------------------------"
echo "Platforms folder in the MOSEK directory:"
platforms=()
j=0
for dir in `ls ${mskhome}/mosek/${mskversion}/tools/platform`
do
if [ -d ${mskhome}"/mosek/"${mskversion}"/tools/platform/"$dir ]
then
let j++
platforms[$j]=$dir
echo $j") "$dir
fi
done
echo "----------------------------------------"
choose_platform(){
read -p "Found multiple platforms, please choose one:" platformNum
if [[ $platformNum -gt 0 && $platformNum -lt $j+1 ]]
then
platform=${platforms[$platformNum]}
echo -e "Selecting platform: ${blue}${platform}${plain}"
echo "MSKVERSION="${platform} >> config.mk
else
echo -e "${red}[Error]${plain} Input number is not valid, please try again."
choose_platform
fi
}
if [ "$j" -eq "0" ]
then
echo -e "${red}[Error]${plain} No platform is found"
exit 1
elif [ "$j" -eq "1" ]
then
platform=${platforms[1]}
echo -e "Selecting the only one version found: ${blue}${platform}${plain}"
echo "PLATFORM="${platform} >> config.mk
read -p "Press enter to continue."
else
choose_platform
fi
echo
echo "----------------------------------------"
echo -e "${green}[Succeed]${plain} The MOSEK configuration has been saved as config.mk"
echo "========================================"
while true
do
echo -e "Do you want compile the program now? [y/n]"
read -p '(default: n):' compile_flag
[ -z "$compile_flag" ] && compile_flag=n
case "${compile_flag}" in
y|Y|n|N)
break
;;
*)
echo -e "${red}[Error]${plain} Please only enter [y/n]"
;;
esac
done
if [ "${compile_flag}" == 'y' ] || [ "${compile_flag}" == 'Y' ]
then
echo
echo "Compiling..."
echo
make all
if [[ $? -eq 0 ]]; then
echo
echo -e "${green}[Succeed]${plain} Program has been compiled."
echo
else
echo
echo -e "${red}[Error]${plain} Compiling failed."
echo
fi
else
echo
echo "You choose not to compile now."
echo
fi
echo
echo -e "${blue}[Note]${plain} To compile again, please run 'make all' command."
echo