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

51
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
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" cmake_type="Ninja"
exec_bin="ninja" exec_bin="$ninja_bin"
elif [ -x "$(which ninja-build 2>/dev/null)" ]; then exec_command="$exec_bin"
echo "-- Found Ninja: $(which ninja-build)" elif [[ "/usr/sbin/ninja" == "$ninja_bin" ]]; then
cmake_type="Ninja" echo "-- Ninja at $ninja_bin is not usable. Did you install 'ninja' instead of 'ninja-build'?"
exec_bin="ninja-build" fi
elif [ -x "$(which make 2>/dev/null)" ]; then fi
echo "-- Found Make: $(which make)"
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" cmake_type="Unix Makefiles"
exec_bin="make -j4" exec_bin="$make_bin"
echo "-- Using Ninja might improve build experience." exec_command="$exec_bin -j4"
cont fi
else 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