Update ./configure to detect ninja package of debian/ubuntu (#4)

This commit is contained in:
Marvin W 2017-03-11 11:16:01 +01:00
parent 4c48bdc072
commit 7bb6ff6250
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
1 changed files with 34 additions and 21 deletions

55
configure vendored
View File

@ -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