-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·85 lines (73 loc) · 1.82 KB
/
build
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
#!/bin/bash
#
# FileName: build
# Description: A build script that runs configures, builds and installs armamin.
#
# Copyright (C) 2014 K M Masum Habib <masum.habib@gmail.com>
#
# Created: 18 June 2014.
build_dir="obj"
function usage(){
echo "Usage: build [options]"
echo " When no option is given, builds armamin using make."
echo " options: "
echo " config: configures armamin using cmake."
echo " install [path]: installs armamin."
echo " doc: build documentation."
echo " clean: deletes compiled object files in the build folder."
echo " superclean: deletes build folder."
echo " help: shows this message."
}
function doconfig(){
mkdir -p $build_dir
cd $build_dir
cmake ../
cd ../
}
function domake(){
mkopt=""
ncpu="4"
if [[ "$1" ]]; then
mkopt=$1
fi
if [[ "$2" ]]; then
ncpu=$2
fi
if [[ ! -f "./$build_dir/Makefile" ]]; then
doconfig
fi
cd $build_dir && make -j $ncpu $mkopt
}
if [[ $# -eq 0 ]]; then
# No argument, run build armamin
domake
elif [[ $# -ge 1 ]]; then
opt=$1
if [[ $opt == "help" ]]; then
usage
elif [[ $opt == "config" ]]; then
doconfig
elif [[ $opt == "clean" ]]; then
domake "clean"
elif [[ $opt == "superclean" ]]; then
rm -rf $build_dir
elif [[ $opt == "install" ]]; then
if [[ $# == 2 ]]; then
install_dir=$2
cd $build_dir && cmake -DCMAKE_INSTALL_PREFIX:PATH=$install_dir ../ && make install
else
cd $build_dir && make install
fi
elif [[ $opt == "doc" ]]; then
if [[ ! -f "./$build_dir/Makefile" ]]; then
doconfig
fi
cd $build_dir && make doc
else
usage
exit -1
fi
else
usage
exit -1
fi