aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-02 15:37:32 +0100
committerfiaxh <git@mx.ax.lt>2017-03-02 15:37:32 +0100
commit56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d (patch)
tree0bd0c2c80cb81179c26282fb3fbe8fd22983f40b /configure
downloaddino-56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d.tar.gz
dino-56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d.zip
Initial commit
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure82
1 files changed, 82 insertions, 0 deletions
diff --git a/configure b/configure
new file mode 100755
index 00000000..e98db6ec
--- /dev/null
+++ b/configure
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+cont() {
+ read c
+ if [ "$c" != "yes" ] && [ "$c" != "Yes" ] && [ "$c" != "y" ] && [ "$c" != "Y" ]
+ then
+ exit 3
+ fi
+}
+
+if [ ! -e `which cmake` ]
+then
+ echo "CMake required."
+ exit 1
+fi
+
+if [ -x "$(which ninja 2>/dev/null)" ]; then
+ echo "Using Ninja ($(which ninja))"
+ cmake_type="Ninja"
+ exec_bin="ninja"
+elif [ -x "$(which ninja-build 2>/dev/null)" ]; then
+ echo "Using Ninja ($(which ninja-build))"
+ cmake_type="Ninja"
+ exec_bin="ninja-build"
+elif [ -x "$(which make 2>/dev/null)" ]; then
+ echo "Using Make ($(which make))"
+ cmake_type="Unix Makefiles"
+ exec_bin="make"
+ printf "Using Ninja improves build experience, continue with Make? [y/N] "
+ cont
+else
+ echo "No compatible build system (Ninja, Make) found."
+ exit 4
+fi
+
+if [ -f ./build ]
+then
+ echo "./build file exists. ./configure can't continue"
+ exit 2
+fi
+
+if [ -d build ]
+then
+ if [ ! -f "build/.cmake_type" ]
+ then
+ printf "./build exists but was not created by ./configure script, continue? [y/N] "
+ cont
+ fi
+ last_type=`cat build/.cmake_type`
+ if [ "$cmake_type" != "$last_type" ]
+ then
+ echo "Using different build system, cleaning build system files"
+ cd build
+ rm -r CMakeCache.txt CMakeFiles
+ cd ..
+ fi
+fi
+
+mkdir -p build
+cd build
+
+echo "$cmake_type" > .cmake_type
+cmake -G "$cmake_type" ..
+
+if [ "$cmake_type" == "Ninja" ]
+then
+cat << EOF > Makefile
+default:
+ @sh -c "$exec_bin"
+%:
+ @sh -c "$exec_bin \"\$@\""
+EOF
+fi
+
+cd ..
+
+cat << EOF > Makefile
+default:
+ @sh -c "cd build; $exec_bin"
+%:
+ @sh -c "cd build; $exec_bin \"\$@\""
+EOF