-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·131 lines (92 loc) · 3.07 KB
/
configure.sh
File metadata and controls
executable file
·131 lines (92 loc) · 3.07 KB
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
#!/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)
Features:
The following flags enable optional features (disable with --no-<option name>).
--static build static binary [default=no]
--werror build with -Werror
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
build_static=default
werror=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##*=} ;;
--static) build_static=ON;;
--no-static) build_static=OFF;;
--werror) werror=ON;;
-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
#--------------------------------------------------------------------------#
if [ $werror != default ]; then
export CFLAGS=-Werror
export CXXFLAGS=-Werror
fi
[ $buildtype != default ] \
&& cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
[ "$install_prefix" != default ] \
&& cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
[ $build_static != default ] \
&& cmake_opts="$cmake_opts -DBUILD_STATIC=$build_static"
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/"