Compiling IVAN under different systems
--------------------------------------

To build IVAN from source, you need to have the following dependencies
installed on your system:

- compiler with C++11 support (e.g. Clang 3.3 or newer, GCC 4.8 or newer)
- CMake (https://cmake.org) version 2.8.12.2 or newer
- SDL (https://www.libsdl.org) version 2.0 or newer
- libpng (http://www.libpng.org/pub/png/libpng.html)
- pcre, not pcre2 (ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/)

--------------------------------------

Under Linux and OS X, type:

mkdir build  # IVAN can be built in a custom folder
cd build
cmake ..  # ".." refers to the parent directory of "build"
make
make install
Note: This will make changes to /usr/bin, and you have to either run "sudo make install" instead, or log in as root.  
Note: Wizard Mode is disabled by default. To enable it run:

mkdir build
cd build
cmake -DWIZARD=ON ..
make
make install

To install IVAN to a custom prefix, pass the additional flag
-DCMAKE_INSTALL_PREFIX=/your/prefix/path to the cmake invocation.
(In particular, simply doing `make DESTDIR=/your/prefix/path install`
doesn't work because IVAN needs the prefix information at build-time.)

If config options toggle is too fast, you can add this flag '-DFELIST_WAITKEYUP',
like this: CMAKE_CXX_FLAGS="-DFELIST_WAITKEYUP"

--------------------------------------

Under DOS:

If you have DJGPP 2.03+ and gcc 2.952+
installed, type:

make -f ivandj.mak

--------------------------------------

Under Windows - Microsoft Visual Studio 2017 (or better):

You will need to install the C++ tools with CMake support, along with Git integrations from the Visual Studio Installer. 
We will not be using Visual Studio in the traditional way with everything squished into a solution file. 
Instead we will use Visual Studio to open a repo folder with a top-level CMakeLists.txt, in conjunction with a CMakeSettings.json file to create the cmake build files.
Then we will use msvc to compile ivan.exe, with the help of libraries we install from vcpkg using Powershell (PS). 

Install vcpkg and install the needed libraries using Powershell:
Here is a condensed summary of applicable instructions from https://github.com/microsoft/vcpkg
Create a folder named "tools" under C:\ and clone the vcpkg repository from github:
PS C:\tools> git clone https://github.com/Microsoft/vcpkg.git
PS C:\tools> cd vcpkg
PS C:\tools\vcpkg> ./bootstrap-vcpkg.sh
PS C:\tools\vcpkg> .\vcpkg integrate install

Install the following libraries:
PS C:\tools\vcpkg> .\vcpkg install sdl2 sdl2-mixer libpng pcre

Verify the libraries are installed with this command:
PS C:\tools\vcpkg> .\vcpkg list
libpng:x86-windows                                 1.6.37-1         libpng is a library implementing an interface fo...
pcre:x86-windows                                   8.41-2           Perl Compatible Regular Expresions
sdl2-mixer:x86-windows                             2.0.4-2          Multi-channel audio mixer library for SDL.
sdl2:x86-windows                                   2.0.9-3          Simple DirectMedia Layer is a cross-platform dev...
zlib:x86-windows                                   1.2.11-5         A compression library


Clone attnam/ivan into a directory (for example C:\Users\yourname\source\repos\ivan)

Open Microsoft Visual Studio (2017)

Go File->Open Folder

Select C:\Users\yourname\source\repos\ivan

Some stuff will happen automatically. The CMakeSettings.json file will be found, and the CMake cache will be generated.

Next to the green "play" button is some text (Select Startup Item...) in a gray dropdown menu. Select "ivan.exe (Install) (ivan\ivan.exe)".

"Build" will appear in the menu next to "CMake". Click Build->ivan.exe (Install) (ivan\ivan.exe) F7

This will build ivan.exe and install all the components, automatically copying the required dlls as well.

The build folder is located in C:\Users\yourname\CMakeBuilds\some-long-code-here-abcdef123456\install\x86-Release\ivan
Go there and hit ivan.exe, and you're playing IVAN built using Microsoft Visual Studio!!!


--------------------------------------

Under Windows - MinGW:


Install SDL2

Download SDL2-devel-2.0.4-mingw.tar.gz from http://www.libsdl.org/
and install somewhere in system, e.g. D:\Apps\SDL2-devel-2.0.4-mingw

Set environment variable SDL2DIR to "D:\Apps\SDL2-devel-2.0.4-mingw\SDL2-2.0.4\i686-w64-mingw32\".
Make sure to open command prompt after that (so this variable is taken into account).

Alternatively set it just in current command prompt:

set SDL2DIR=D:\Apps\SDL2-devel-2.0.4-mingw\SDL2-2.0.4\i686-w64-mingw32\

Use command line to generate MinGW makefiles in IVAN source directory:

D:\buildy\ivan>mkdir mingw
D:\buildy\ivan>cd mingw
D:\buildy\ivan\mingw2>cmake .. -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=D:/buildy/ivan/inst_mingw

Now you can compile from command line:

D:\buildy\ivan\mingw2>mingw32-make -j4 install

If you get a lot of weird compilation errors, try invoking cmake again with
-DCMAKE_CXX_FLAGS='-std=gnu++11' as a workaround.

Now you can run ivan from D:/buildy/ivan/inst_mingw/ivan/ directory.

--------------------------------------

Under Windows - MSYS2:


Download MSYS2 from http://www.msys2.org/ selecting the right download for your architecture.
Follow instructions on the page to install correctly.

Run MSYS2.exe from either the "-msys64" or "-msys32" folder, depending on your system, and type these commands
$ pacman -Syu
Proceed with installation (option Y), then exit by closing the terminal window. The terminal window will crash and burn eventually but may take some time to do so.

Run MSYS2.exe again:
$ pacman -Su
proceed with installation (option Y). This will take a long time to download all the packages, depending on your download speed

$ pacman -S git
Proceed with installation (option Y) etcetera

$ pacman -S mingw-w64-i686-gcc

$ pacman -S make

$ pacman -S mingw-w64-i686-cmake

$ pacman -S mingw-w64-i686-libpng

$ pacman -S mingw-w64-i686-SDL2

$ pacman -S mingw-w64-i686-SDL2_mixer

$ pacman -S mingw-w64-i686-pkg-config

Now the MSYS2 build system is installed, you only need to follow the instructions below to keep IVAN up to date

Create an empty folder in \ivan\ called msys2
run MinGW32.exe (from your "-msys64" or "-msys32" folder, whichever is applicable) and change directory to your newly created \ivan\msys2\ folder

In MinGW32.exe type the following commands, respecting the direction of the slashes:
$ cmake .. -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=C:/ivan/inst_msys2
$ make -j4 install

Navigate to \ivan\inst_msys2\ivan and you will find the ivan.exe executable!

You will probably need to copy a bunch of DLLs into the directory where ivan.exe is located. These may include the following, likely not an exhaustive list, but they can be found under for example C:\-msys64\mingw32\bin:
libpng16-16.dll
libstdc++-6.dll
libwinpthread-1.dll
zlib.dll
libgcc_s_dw2-1.dll
libSDL2_mixer-2-0-0.dll
libmad-0.dll


Use dependencywalker if you need to check for missing libraries, and if you get the message: "error cannot find entrypoint inflateValidate (in dll libpng16-16.dll)" then you need to include zlib1.dll

--------------------------------------

To build standalone application on MacOS:

Using Homebrew: https://brew.sh/

$ export SDL2DIR="$HOME/Downloads/SDL2Frameworks"
$ export BUILD_MAC_APP=ON
$ export IVAN_BUILD_DIR="$PWD/build"
$ mkdir build && cd build
$ ../ci/osx/requirements.sh
$ ../ci/osx/build.sh
$ make install
$ ../ci/osx/package.sh
$ ls ./osx

The user data will be stored at "$HOME/Library/Application Support/IVAN".
