From 033d9244b2685c72d7934dbaaf8288b0f66c5230 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 25 Aug 2015 05:37:49 +0200
Subject: [PATCH] Add user-friendly safeguards against running with unmet
 dependencies.

---
 redo                         | 26 ++++++++++++++++++++++++++
 start_server_client_union.sh |  9 +++++++++
 2 files changed, 35 insertions(+)

diff --git a/redo b/redo
index 4081117..51f7aff 100755
--- a/redo
+++ b/redo
@@ -18,5 +18,31 @@
 # <https://github.com/plomlompom/plomrogue/issues/2#issuecomment-50972436> for a
 # workaround.
 
+# Some tests first: for gcc, and certain necessary header files. (This is not
+# strictly the responsibility of a mere redo wrapper. But those using a
+# pre-installed redo probably will be fine with the error messages thrown by it
+# if these miss.)
+test=`command -v gcc | wc -l`
+if [ 1 != $test ]
+then
+    echo "FAILURE:"
+    echo "No gcc installed, but it's needed!"
+    exit 1
+fi
+test_header() {
+    code="#include <$1>"
+    test=`echo $code | cpp -H -o /dev/null 2>&1 | head -n1 | grep error | wc -l`
+    if [ 0 != $test ]
+    then
+        echo "FAILURE:"
+        echo "No $1 header file found, but it's needed!"
+        echo "Maybe install some $2 package?"
+        exit 1
+    fi
+}
+test_header stdlib.h libc6-dev      # Assume stdlib.h guarantees full libc6-dev.
+test_header ncurses.h libncurses5-dev
+
+# The actual redo calling.
 export PATH=$PATH:$PWD/build/redo_scripts
 redo "$@"
diff --git a/start_server_client_union.sh b/start_server_client_union.sh
index 3b7dccc..ad05038 100755
--- a/start_server_client_union.sh
+++ b/start_server_client_union.sh
@@ -9,6 +9,15 @@ then
     rm log
 fi
 
+# Abort if no proper Python version installed.
+test=`command -v python3 | wc -l`
+if [ 1 != $test ]
+then
+    echo "FAILURE:"
+    echo "No python3 installed, but it's needed!"
+    exit 1
+fi
+
 # Give helpful message to players that want to start without compiling first.
 if [ ! -e ./roguelike-client ]
 then
-- 
2.30.2