1#!/bin/sh
2
3# NOTE: this is a simple script wrapper around the cmake command line
4# tools, for those used to the autotools configure script conventions
5
6if ! which cmake > /dev/null; then
7  echo "ERROR: You need the 'cmake' program to configure the build process."
8  echo "Please install 'cmake' first, then try again."
9  exit 1
10fi
11
12print_help()
13{
14  echo "This is a simple configure script wrapper around cmake build system."
15  echo "Parameters are:"
16  echo "  --prefix=<path>         Set the install prefix to path"
17  echo "  --enable-debug          Enable debug (non-optimized) build"
18  echo "  --disable-color-make    Disable color output for Makefiles"
19  echo "  --enable-sdl2           Compile with libsdl 2.0 instead of 1.2"
20  echo
21  echo "Please run cmake directly for full control over the build."
22  echo
23}
24
25cmake_args=""
26build_type="Release"
27
28while [ $# -gt 0 ]
29do
30  preq=${1%=*}			# get part before =
31  case $preq
32  in
33    --help)
34      print_help
35      exit 0
36    ;;
37    --prefix)
38      prefix=${1##*=}		# get part after =
39      cmake_args="$cmake_cmd -DCMAKE_INSTALL_PREFIX:PATH=$prefix"
40    ;;
41    --enable-debug)
42      build_type="Debug"
43      cmake_args="$cmake_args -DCMAKE_BUILD_TYPE:STRING=Debug"
44    ;;
45    --disable-debug)
46      build_type="Release"
47      cmake_args="$cmake_args -DCMAKE_BUILD_TYPE:STRING=Release"
48    ;;
49    --enable-color-make)
50      cmake_args="$cmake_args -DCMAKE_COLOR_MAKEFILE:BOOL=1"
51    ;;
52    --disable-color-make)
53      cmake_args="$cmake_args -DCMAKE_COLOR_MAKEFILE:BOOL=0"
54    ;;
55    --enable-sdl2)
56      cmake_args="$cmake_args -DENABLE_SDL2:BOOL=1"
57    ;;
58    --disable-sdl2)
59      cmake_args="$cmake_args -DENABLE_SDL2:BOOL=0"
60    ;;
61    *)
62      echo "Invalid argument: $preq"
63      echo "Run $0 --help for a list of valid parameters."
64      exit 2
65    ;;
66  esac
67  shift 1
68done
69
70cmake `dirname $0` $cmake_args || exit 1
71
72echo
73echo "Now you must type: make; make install"
74echo "to actually build and install the software"
75echo
76