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