-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·61 lines (51 loc) · 998 Bytes
/
build.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
#!/usr/bin/env bash
prefix=/usr/local/
debug() {
mkdir -p build
cd build || exit
cmake "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_INSTALL_PREFIX=$prefix" ".."
make
sudo make install
}
release() {
mkdir -p build
cd build || exit
cmake "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=$prefix" ".."
make
sudo make install
}
clean() {
if [ -d "build" ]; then
cd build || exit
make clean
exit 0
else
echo "build directory does not exists"
exit 0
fi
}
help_msg() {
printf "usage: ./build.sh [options...]\n\n"
printf "options:\n"
printf "\t-d - compile and install debug version\n"
printf "\t-r - compile and install release version\n"
printf "\t-c - delete compiled object files\n"
printf "\t-h - prints help message\n"
}
check_options() {
if [ -z "$*" ]; then
release
exit 0
fi
while getopts "drch" opt; do
case $opt in
d) debug ;;
r) release ;;
c) clean ;;
h) help_msg ;;
*) echo "unknown option" ;;
esac
done
}
check_options "$@"
exit 0