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

55
configure vendored
View file

@ -8,27 +8,40 @@ cont() {
fi fi
} }
if [ ! -e `which cmake` ] if [ ! -x "$(which cmake 2>/dev/null)" ]
then then
echo "CMake required." echo "-!- CMake required."
exit 1 exit 1
fi fi
if [ -x "$(which ninja 2>/dev/null)" ]; then ninja_bin="$(which ninja-build 2>/dev/null)"
echo "-- Found Ninja: $(which ninja)" if ! [ -x "$ninja_bin" ]; then
cmake_type="Ninja" ninja_bin="$(which ninja 2>/dev/null)"
exec_bin="ninja" fi
elif [ -x "$(which ninja-build 2>/dev/null)" ]; then if [ -x "$ninja_bin" ]; then
echo "-- Found Ninja: $(which ninja-build)" ninja_version=$($ninja_bin --version 2>/dev/null)
cmake_type="Ninja" if [ $? -eq 0 ]; then
exec_bin="ninja-build" echo "-- Found Ninja: $ninja_bin (found version \"$ninja_version\")"
elif [ -x "$(which make 2>/dev/null)" ]; then cmake_type="Ninja"
echo "-- Found Make: $(which make)" exec_bin="$ninja_bin"
cmake_type="Unix Makefiles" exec_command="$exec_bin"
exec_bin="make -j4" elif [[ "/usr/sbin/ninja" == "$ninja_bin" ]]; then
echo "-- Using Ninja might improve build experience." echo "-- Ninja at $ninja_bin is not usable. Did you install 'ninja' instead of 'ninja-build'?"
cont fi
else 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." echo "-!- No compatible build system (Ninja, Make) found."
exit 4 exit 4
fi fi
@ -66,9 +79,9 @@ if [ "$cmake_type" == "Ninja" ]
then then
cat << EOF > Makefile cat << EOF > Makefile
default: default:
@sh -c "$exec_bin" @sh -c "$exec_command"
%: %:
@sh -c "$exec_bin \"\$@\"" @sh -c "$exec_command \"\$@\""
EOF EOF
fi fi
@ -76,7 +89,7 @@ cd ..
cat << EOF > Makefile cat << EOF > Makefile
default: 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 EOF