-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure.sh
executable file
·109 lines (77 loc) · 2.57 KB
/
configure.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
#!/usr/bin/env bash
#--------------------------------------------------------------------------#
set -e -o pipefail
usage () {
cat <<EOF
Usage: $0 [<build type>] [<option> ...]
Build types:
release
debug
General options;
-h, --help display this help and exit
--prefix=STR install directory
--name=STR use custom build directory name (optionally: +path)
CMake Options (Advanced)
-DVAR=VALUE manually add CMake options
EOF
exit 0
}
#--------------------------------------------------------------------------#
die () {
echo "*** configure.sh: $*" 1>&2
exit 1
}
msg () {
echo "[configure.sh] $*"
}
#--------------------------------------------------------------------------#
[ ! -e src ] && die "$0 not called from ethos base directory"
#--------------------------------------------------------------------------#
build_dir=build
install_prefix=default
#--------------------------------------------------------------------------#
buildtype=default
#--------------------------------------------------------------------------#
cmake_opts=""
while [ $# -gt 0 ]
do
case $1 in
-h|--help) usage;;
--prefix) die "missing argument to $1 (try -h)" ;;
--prefix=*)
install_prefix=${1##*=}
# Check if install_prefix is an absolute path and if not, make it
# absolute.
case $install_prefix in
/*) ;; # absolute path
*) install_prefix=$(pwd)/$install_prefix ;; # make absolute path
esac
;;
--name) die "missing argument to $1 (try -h)" ;;
--name=*) build_dir=${1##*=} ;;
-D*) cmake_opts="${cmake_opts} $1" ;;
-*) die "invalid option '$1' (try -h)";;
*) case $1 in
release) buildtype=Release;;
debug) buildtype=Debug;;
*) die "invalid build type (try -h)";;
esac
;;
esac
shift
done
#--------------------------------------------------------------------------#
[ $buildtype != default ] \
&& cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
[ "$install_prefix" != default ] \
&& cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
uname_output=$(uname)
[[ $uname_output =~ ^MSYS || $uname_output =~ ^MINGW ]] \
&& export CMAKE_GENERATOR="MSYS Makefiles"
root_dir=$(pwd)
mkdir -p "$build_dir"
cd "$build_dir"
[ -e CMakeCache.txt ] && rm CMakeCache.txt
build_dir_escaped=$(echo "$build_dir" | sed 's/\//\\\//g')
cmake "$root_dir" $cmake_opts 2>&1 | \
sed "s/^Now just/Now change to '$build_dir_escaped' and/"