home · contact · privacy
Add user-friendly safeguards against running with unmet dependencies.
[plomrogue] / redo
1 #!/bin/sh
2
3 # The purpose of this script is to step in if no version of the "redo" build
4 # system is installed on your system to interpret the files that (Makefile-like)
5 # build the PlomRogue system: ./all.do, ./roguelike-client.do and
6 # ./roguelike-server.do.
7
8 # If a version of "redo" is installed on your system and in your $PATH, just run
9 # "redo roguelike-client", "redo roguelike-server" or plain "redo" (to build
10 # both via all.do). Otherwise, run this very script with the very same
11 # arguments. It uses parts of a basic "redo" implementation written by Nils
12 # Dagsson Moskopp a.k.a. erlehmann, snapshots of which are stored in
13 # build/redo_scripts/. For details on this version, see:
14 # - <http://news.dieweltistgarnichtso.net/bin/redo.html>
15 # - <http://news.dieweltistgarnichtso.net/bin/redo-ifchange.html>
16 #
17 # This "redo" implementation may experience trouble on OS X systems, see
18 # <https://github.com/plomlompom/plomrogue/issues/2#issuecomment-50972436> for a
19 # workaround.
20
21 # Some tests first: for gcc, and certain necessary header files. (This is not
22 # strictly the responsibility of a mere redo wrapper. But those using a
23 # pre-installed redo probably will be fine with the error messages thrown by it
24 # if these miss.)
25 test=`command -v gcc | wc -l`
26 if [ 1 != $test ]
27 then
28     echo "FAILURE:"
29     echo "No gcc installed, but it's needed!"
30     exit 1
31 fi
32 test_header() {
33     code="#include <$1>"
34     test=`echo $code | cpp -H -o /dev/null 2>&1 | head -n1 | grep error | wc -l`
35     if [ 0 != $test ]
36     then
37         echo "FAILURE:"
38         echo "No $1 header file found, but it's needed!"
39         echo "Maybe install some $2 package?"
40         exit 1
41     fi
42 }
43 test_header stdlib.h libc6-dev      # Assume stdlib.h guarantees full libc6-dev.
44 test_header ncurses.h libncurses5-dev
45
46 # The actual redo calling.
47 export PATH=$PATH:$PWD/build/redo_scripts
48 redo "$@"