1#!/bin/sh
2
3# NOTE: this is a simple script wrapper around the cmake command line tools,
4# 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 Hatari 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 "  --enable-small-mem         Use less memory - at the expense of emulation speed"
19  echo "  --disable-dsp              Disable DSP emulation for Falcon mode."
20  echo "  --disable-tracing          Disable tracing messages for debugging"
21  echo "  --enable-winuae-cpu        Use WinUAE CPU core (default)"
22  echo "  --enable-old-uae-cpu       Use old UAE CPU core (deprecated)"
23  echo "  --disable-osx-bundle       Disable application bundling on macOS"
24  echo "  --disable-sdl2             Do not compile with libsdl 2.0, use 1.2 instead"
25  echo "  --cross-compile-win64_32   Build the 32 bit Windows version under linux using mingw-w64"
26  echo "  --cross-compile-win64_64   Build the 64 bit Windows version under linux using mingw-w64"
27  echo
28  echo "Please run cmake directly for full control over the build."
29  echo
30}
31
32cmake_args=""
33build_type="Release"
34
35while [ $# -gt 0 ]
36do
37  preq=${1%=*}			# get part before =
38  case $preq
39  in
40    --help)
41      print_help
42      exit 0
43    ;;
44    --prefix)
45      prefix=${1##*=}		# get part after =
46      cmake_args="$cmake_args -DCMAKE_INSTALL_PREFIX:PATH=$prefix"
47    ;;
48    --enable-debug)
49      build_type="Debug"
50      cmake_args="$cmake_args -DCMAKE_BUILD_TYPE:STRING=Debug"
51    ;;
52    --disable-debug)
53      build_type="Release"
54      cmake_args="$cmake_args -DCMAKE_BUILD_TYPE:STRING=Release"
55    ;;
56    --enable-dsp)
57      cmake_args="$cmake_args -DENABLE_DSP_EMU:BOOL=1"
58    ;;
59    --disable-dsp)
60      cmake_args="$cmake_args -DENABLE_DSP_EMU:BOOL=0"
61    ;;
62    --enable-tracing)
63      cmake_args="$cmake_args -DENABLE_TRACING:BOOL=1"
64    ;;
65    --disable-tracing)
66      cmake_args="$cmake_args -DENABLE_TRACING:BOOL=0"
67    ;;
68    --enable-small-mem)
69      cmake_args="$cmake_args -DENABLE_SMALL_MEM:BOOL=1"
70    ;;
71    --disable-small-mem)
72      cmake_args="$cmake_args -DENABLE_SMALL_MEM:BOOL=0"
73    ;;
74    --enable-winuae-cpu)
75      cmake_args="$cmake_args -DENABLE_WINUAE_CPU:BOOL=1"
76    ;;
77    --disable-winuae-cpu)
78      cmake_args="$cmake_args -DENABLE_WINUAE_CPU:BOOL=0"
79    ;;
80    --enable-old-uae-cpu)
81      cmake_args="$cmake_args -DENABLE_WINUAE_CPU:BOOL=0"
82    ;;
83    --disable-old-uae-cpu)
84      cmake_args="$cmake_args -DENABLE_WINUAE_CPU:BOOL=1"
85    ;;
86    --enable-osx-bundle)
87      cmake_args="$cmake_args -DENABLE_OSX_BUNDLE:BOOL=1"
88    ;;
89    --disable-osx-bundle)
90      cmake_args="$cmake_args -DENABLE_OSX_BUNDLE:BOOL=0"
91    ;;
92    --enable-sdl2)
93      cmake_args="$cmake_args -DENABLE_SDL2:BOOL=1"
94    ;;
95    --disable-sdl2)
96      cmake_args="$cmake_args -DENABLE_SDL2:BOOL=0"
97    ;;
98    --cross-compile-win64_32)
99      cmake_args="$cmake_args -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-mingw32-win64_32.cmake"
100    ;;
101    --cross-compile-win64_64)
102      cmake_args="$cmake_args -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-mingw32-win64_64.cmake"
103    ;;
104    *)
105      echo "Invalid argument: $preq"
106      echo "Run $0 --help for a list of valid parameters."
107      exit 2
108    ;;
109  esac
110  shift 1
111done
112
113# remove previous cmake's cache
114rm -f `dirname $0`/CMakeCache.txt
115rm -rf `dirname $0`/CMakeFiles/
116
117cmake `dirname $0` $cmake_args || exit 1
118
119echo
120echo "Now you must type: make; make install"
121echo "to actually build and install the software"
122echo
123