-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·43 lines (34 loc) · 1.16 KB
/
configure
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
#!/bin/bash
if [[ $# -gt 0 && ( "$1" == "-h" || "$1" == "--help" ) ]]; then
echo "Usage: configure [debug | release]"
echo
echo "Configures the either a debug or release build."
exit 1
fi
if [ ! -e build/ ]; then
mkdir build
fi
# Determine the build type from the commandline (in case it is specified), and
# lowercase it.
build_type="$(tr '[:upper:]' '[:lower:]' <<< "$*")"
# By default, make a debug build in case no build type has been specified.
if [ "$build_type" = "" ]; then
build_type="debug"
fi
echo "Configuring a $build_type build..."
# In case this is run as root, configure the installation prefix as /usr/local,
# otherwise, $HOME/.local.
if [ "$EUID" -eq 0 ]; then
install_prefix="/usr/local"
else
install_prefix="$HOME/.local"
fi
# Upper the first character of the build type for use with CMake.
build_type="$(tr '[:lower:]' '[:upper:]' <<< ${build_type:0:1})${build_type:1}"
cd build && cmake ../ -GNinja \
-DCMAKE_MAKE_PROGRAM="$(command -v ninja)" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX="$install_prefix" \
-DCMAKE_BUILD_TYPE="$build_type"
echo
echo "Configuration complete, to build issue 'ninja -C build'"