diff options
-rwxr-xr-x | configure | 55 |
1 files changed, 34 insertions, 21 deletions
@@ -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 |