-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildFC.sh
executable file
·136 lines (117 loc) · 2.72 KB
/
buildFC.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
#!/bin/bash
program_name="FanController"
echo "This script compiles and installs the $program_name program using cmake"
#Setup variables
declare -i useDefaultBuildDir=1
declare -i useDefault=1
declare -i portable=1
declare -i debug=1
declare -i dep_use_existing=1
declare -i dep_locations=1
buildDir="build"
cmakeFlags=""
#Function for flipping build switches
buildSwitch ()
{
local prompt=$1
local doEcho=$2
if [ "$doEcho" == "" ]; then
doEcho=0
fi
PS3="$prompt"
select option in yes no quit
do
case $option in
yes)
if [ $doEcho == 1 ]; then
echo "Chose $option"
fi
return 0
;;
no)
if [ $doEcho == 1 ]; then
echo "Chose $option"
fi
return 1
;;
quit)
if [ $doEcho == 1 ]; then
echo "Chose $option"
fi
return 2
;;
*)
echo "Please choose yes or no"
;;
esac
done
}
query ()
{
#$1 = prompt text
#$2 = echo user choice (optional)
echo
buildSwitch "$1" $2
local _store=$?
#If user chose quit
if [ $_store == 2 ]; then
exit 0
fi
return $_store
}
build ()
{
echo
mkdir "$buildDir"
cd "$buildDir"
echo
cmake $cmakeFlags ..
query "Did cmake fail? "
if [ $? == 0 ]; then
exit 1
fi
echo
make install
query "Did make fail? "
if [ $? == 0 ]; then
exit 1
fi
}
query "Use the default build directory name (which is $buildDir)? "
useDefaultBuildDir=$?
if [ $useDefaultBuildDir == 1 ]; then
echo "Please type the new directory name"
read buildDir
fi
query "Do you want to use the default options? "
useDefault=$?
if [ $useDefault != 0 ]; then
#User said no to default settings
query "Do you want to build portable mode? "
portable=$?
if [ $portable == 0 ]; then
cmakeFlags+=" -D PORTABLE=ON "
fi
query "Do you want to build debug mode? "
debug=$?
if [ $debug == 0 ]; then
cmakeFlags+=" -D CMAKE_BUILD_TYPE=Debug "
fi
query "Do you want to use existing dependency installs? "
dep_use_existing=$?
if [ $dep_use_existing == 0 ]; then
cmakeFlags+=" -D DEP_USE_EXISTING=ON "
fi
query "Do you want to print dependency locations? "
dep_locations=$?
if [ $dep_locations == 0 ]; then
cmakeFlags+=" -D DEP_LOCATIONS=ON "
fi
fi
build
#Enable the FanController service, to start on boot
echo
systemctl enable FanController.service
#Unset functions after use
unset buildSwitch
unset query