aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-11 11:16:01 +0100
committerMarvin W <git@larma.de>2017-03-11 12:01:02 +0100
commit7bb6ff6250e7bfc1f5d8ee4cc5d49c7aaf5ac435 (patch)
tree918dfeac16a7fd23fc705458c1b74b7a392c48bf /configure
parent4c48bdc07291f55d7320721a5b0a29c092f7daa0 (diff)
downloaddino-7bb6ff6250e7bfc1f5d8ee4cc5d49c7aaf5ac435.tar.gz
dino-7bb6ff6250e7bfc1f5d8ee4cc5d49c7aaf5ac435.zip
Update ./configure to detect ninja package of debian/ubuntu (#4)
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure55
1 files changed, 34 insertions, 21 deletions
diff --git a/configure b/configure
index 4940f9bd..dbbeaabd 100755
--- a/configure
+++ b/configure
@@ -8,27 +8,40 @@ cont() {
fi
}
-if [ ! -e `which cmake` ]
+if [ ! -x "$(which cmake 2>/dev/null)" ]
then
- echo "CMake required."
+ echo "-!- CMake required."
exit 1
fi
-if [ -x "$(which ninja 2>/dev/null)" ]; then
- echo "-- Found Ninja: $(which ninja)"
- cmake_type="Ninja"
- exec_bin="ninja"
-elif [ -x "$(which ninja-build 2>/dev/null)" ]; then
- echo "-- Found Ninja: $(which ninja-build)"
- cmake_type="Ninja"
- exec_bin="ninja-build"
-elif [ -x "$(which make 2>/dev/null)" ]; then
- echo "-- Found Make: $(which make)"
- cmake_type="Unix Makefiles"
- exec_bin="make -j4"
- echo "-- Using Ninja might improve build experience."
- cont
-else
+ninja_bin="$(which ninja-build 2>/dev/null)"
+if ! [ -x "$ninja_bin" ]; then
+ ninja_bin="$(which ninja 2>/dev/null)"
+fi
+if [ -x "$ninja_bin" ]; then
+ ninja_version=$($ninja_bin --version 2>/dev/null)
+ if [ $? -eq 0 ]; then
+ echo "-- Found Ninja: $ninja_bin (found version \"$ninja_version\")"
+ cmake_type="Ninja"
+ exec_bin="$ninja_bin"
+ exec_command="$exec_bin"
+ elif [[ "/usr/sbin/ninja" == "$ninja_bin" ]]; then
+ echo "-- Ninja at $ninja_bin is not usable. Did you install 'ninja' instead of 'ninja-build'?"
+ fi
+fi
+
+if ! [ -x "$exec_bin" ]; then
+ make_bin="$(which make 2>/dev/null)"
+ if [ -x "$make_bin" ]; then
+ echo "-- Found Make: $make_bin"
+ echo "-- Using Ninja (ninja-build) might improve build experience."
+ cmake_type="Unix Makefiles"
+ exec_bin="$make_bin"
+ exec_command="$exec_bin -j4"
+ fi
+fi
+
+if ! [ -x "$exec_bin" ]; then
echo "-!- No compatible build system (Ninja, Make) found."
exit 4
fi
@@ -66,9 +79,9 @@ if [ "$cmake_type" == "Ninja" ]
then
cat << EOF > Makefile
default:
- @sh -c "$exec_bin"
+ @sh -c "$exec_command"
%:
- @sh -c "$exec_bin \"\$@\""
+ @sh -c "$exec_command \"\$@\""
EOF
fi
@@ -76,7 +89,7 @@ cd ..
cat << EOF > Makefile
default:
- @sh -c "cd build; $exec_bin"
+ @sh -c "cd build; $exec_command"
%:
- @sh -c "cd build; $exec_bin \"\$@\""
+ @sh -c "cd build; $exec_command \"\$@\""
EOF