1# Compiling 2 3As it stands, the version of Lugaru in this repository supports Linux, OSX 4and Windows. Not all toolchains are tested, thus we would welcome help from 5new contributors especially regarding MSVC and OSX support. 6 7## Common dependencies 8 9You will need the following development libraries and tools, usually 10available via your package manager (dnf, urpmi, apt, brew, etc.): 11 12- CMake 13- SDL2 14- Mesa OpenGL Utility library (GLU) 15- LibJPEG (TurboJPEG) 16- LibPNG 17- OpenAL Soft 18- Ogg, Vorbis and Vorbisfile 19- Zlib 20 21## GNU/Linux 22 23Both GCC and Clang are supported as compilers. Define the `CC` and `CXX` env 24variables according to the compiler you want to use, if not the default one. 25Then build with: 26 27``` 28mkdir build && cd build 29cmake .. 30make 31``` 32 33The resulting `lugaru` binary will expect to find the `Data/` folder next to 34it, so either copy `build/lugaru` in the main directory, or create a symbolic 35link to run the game. 36 37### Packaging 38 39If you want to package Lugaru for a GNU/Linux distribution, or if you want to 40install it system-wide locally, you need to set the `SYSTEM_INSTALL` CMake 41option, and (optionally) define the CMAKE_INSTALL_BINDIR and _DATADIR if they 42differ from the default ones (`bin` and `share` appended to the prefix). 43Example: 44 45``` 46mkdir build && cd build 47cmake -DSYSTEM_INSTALL=ON \ 48 -DCMAKE_INSTALL_BINDIR=games \ 49 -DCMAKE_INSTALL_DATADIR=share/games \ 50 .. 51make 52sudo make install 53``` 54 55## Mac OSX 56 57The instructions are similar to the GNU/Linux ones, provided you have 58installed Xcode and the required dependencies (e.g. via homebrew). 59 60## Windows 61 62As of now, only MinGW32 and MinGW64 are supported, and were only tested by 63cross-compiling from Linux. 64 65### MSVC 66 67Help needed :) 68 69### MinGW on Windows 70 71Help needed :) 72 73### Cross-compiling from Linux 74 75Cross-compiling for Windows using MinGW32 and MinGW64 was tested on Fedora 76and Mageia. The instructions may vary for other distros, do not hesitate to 77send a merge request to update them if need be. 78 79You will need to install the `mingw32-` or `mingw64-` variants of the 80dependencies listed above. 81 82#### MinGW32 83 84First you will need to setup some environment variables: 85``` 86export PKG_CONFIG_LIBDIR="/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/i686-w64-mingw32/sys-root/mingw/share/pkgconfig" 87export PATH=/usr/i686-w64-mingw32/bin:$PATH 88``` 89 90Then build: 91``` 92mkdir build-mingw32 && cd build-mingw32 93cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=install 94make 95make install 96``` 97 98The `make install` step should copy the `Data/` and required DLLs from the 99system to `build-mingw32/install`. 100 101#### MinGW64 102 103The instructions are similar to those for MinGW32: 104 105``` 106export PKG_CONFIG_LIBDIR="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/x86_64-w64-mingw32/sys-root/mingw/share/pkgconfig" 107export PATH=/usr/x86_64-w64-mingw32/bin:$PATH 108``` 109``` 110mkdir build-mingw64 && cd build-mingw64 111cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw64.cmake -DCMAKE_INSTALL_PREFIX=install 112make 113make install 114``` 115