1Compiling Instructions
2======================
3
4The methods for compiling Angband vary by platform and by build system. If
5you get Angband working on a different platform or build system please let us
6know so we can add to this file.
7
8.. contents:: Contents
9   :local:
10
11macOS
12-----
13
14To build the new Cocoa front-end::
15
16    cd src
17    make -f Makefile.osx
18
19Debug build
20~~~~~~~~~~~
21
22This will generate a debugging build like that described in the Linux section::
23
24    cd src
25    make -f Makefile.osx clean
26    make -f Makefile.osx OPT="-g -O1 -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address"
27
28The clean step is there to clean out object files that were compiled with the
29default options.  The "-g" adds debugging symbols.
30"-O1 -fno-omit-frame-pointer" dials back the optimization to get call stack
31traces that are easier to interpret.  For even clearer call stack traces, you
32could add "-fno-optimize-sibling-calls" to the options or omit optimization
33entirely by replacing "-O1 -fno-omit-frame-pointer" with "-O0".
34"-fsanitize=address -fsanitize=undefined" enables the AddressSanitizer and
35UndefinedBehaviorSanitizer tools.
36
37To run the generated executable under Xcode's command-line debugger, lldb, do
38this if you are already in the src directory from the compilation step::
39
40    cd ../Angband.app/Contents/MacOS
41    lldb ./angband
42
43Linux / other UNIX
44------------------
45
46Native builds
47~~~~~~~~~~~~~
48
49Linux builds using autotools. There are several different front ends that you
50can optionally build (GCU, SDL, X11, and GTK) using arguments to configure
51such as --enable-sdl, --disable-gtk, etc. Each front end has different
52dependencies (e.g. ncurses, SDL libraries, etc).
53
54To build Angband to be run in-place::
55
56    ./autogen.sh
57    ./configure --with-no-install [other options as needed]
58    make
59
60To build Angband to be installed in some other location::
61
62    ./autogen.sh
63    ./configure --prefix /path/to [other options as needed]
64    make
65    make install
66
67On some BSDs, you may need to copy install-sh into lib/ and various
68subdirectories of lib/ in order to install correctly.
69
70Compilation with CMake
71~~~~~~~~~~~~~~~~~~~~~~
72
73The compilation process with CMake requires a version greater than 3,
74by default the compilation process uses the X11 front end unless
75that the contrary is indicated. The optional front ends are: SDL and NCurses.
76
77To build Angband (X11 Frontend) to be run::
78
79    mkdir build && cd build
80    cmake ..
81    make
82
83To build Angband with the frontend SDL::
84
85    mkdir build && cd build
86    cmake  -DSUPPORT_SDL_FRONTEND=ON ..
87    make
88
89To build Angband with the frontend NCurses::
90
91    mkdir build && cd build
92    cmake  -DSUPPORT_NCURSES_FRONTEND=ON ..
93    make
94
95Cross-building for Windows with Mingw
96~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
98Many developers (as well as the auto-builder) build Angband for Windows using
99Mingw on Linux. This requires that the necessary Mingw packages are all
100installed.
101
102This type of build now also uses autotools, so you must configure it to
103cross-compile, e.g.::
104
105	./autogen.sh
106	./configure --enable-win --disable-curses --build=i686-pc-linux-gnu --host=i586-mingw32msvc
107
108Mingw installs commands like 'i586-mingw32msvc-gcc'. The value of --host
109should be that same command with the '-gcc' removed. Instead of i586 you may
110see i686, amd64, etc. The value of --build should be the host you're building
111on. (See http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/
112autoconf-2.68/html_node/Specifying-Target-Triplets.html#Specifying%20Names for
113gory details of how these triplets are arrived at)
114
115TODO: you will probably need to manually disable curses, or the host curses
116installation will be found, and will not be able to link properly. More
117checking of permissible combinations to configure is necessary
118
119Debug build
120~~~~~~~~~~~
121
122**WARNING** this build is intended primarily for debugging purposes. It might have a somewhat slower performance, higher memory requirements and panic saves don't always work (in case of a crash there is a higher chance of losing progress).
123
124When debugging crashes it can be very useful to get more information about *what exactly* went wrong. There are many tools that can detect common issues and provide useful information. Two such tools that are best used together are AddressSanitizer (ASan) and UndefinedBehaviorSanitizer (UBSan). To use them you'll need to enable them when compiling angband::
125
126    ./configure [options]
127    SANITIZE_FLAGS="-fsanitize=undefined -fsanitize=address" make
128
129Note that compiling with this tools will require installing additional dependancies: libubsan libasan (names of the packages might be different in your distribution).
130
131There is probably a way to get these tools to work on Windows. If you know how, please add the information to this file.
132
133Windows
134-------
135
136Using MinGW
137~~~~~~~~~~~
138
139This build now also uses autotools, so should be very similar to the Linux
140build. Open the MinGW shell (MSYS) by running msys.bat then run these commands::
141
142	./autogen.sh
143	./configure --enable-win
144	make
145
146The install target almost certainly won't work
147
148Following build, to get the program to run, you need to copy the executable
149from the src directory into the top-level dir, and copy 2 DLLs (libpng12.dll
150and zlib1.dll) from src/win/dll to the top-level dir
151
152Using Cygwin (with MinGW)
153~~~~~~~~~~~~~~~~~~~~~~~~~
154
155Use this option if you want to build a native Windows executable that
156can run with or without Cygwin.
157
158Use the Cygwin setup.exe to install the mingw-gcc-core package and any
159dependencies suggested by the installer.
160
161Run these commands::
162
163	./autogen.sh
164	./configure --enable-win --with-no-install --host=i686-pc-mingw32
165	make
166
167As with the "Using MinGW" process, you need to copy the executable and
168DLLs to the top-level dir.
169
170If you want to build the Unix version of Angband that uses X11 or
171Curses and run it under Cygwin, then follow the native build
172instructions (./autogen.sh; ./configure; make; make install).
173
174Using MSYS2 (with MinGW64)
175~~~~~~~~~~~~~~~~~~~~~~~~~~
176
177Install the dependencies by::
178
179	pacman -S make mingw-w64-x86_64-toolchain mingw-w64-x86_64-ncurses
180
181Additional dependencies for SDL2 client::
182
183	pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_gfx \
184		  mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_ttf
185
186Then run the following to compile with ncurse::
187
188	cd src
189	make -f Makefile.msys2
190
191For SDL2, do::
192
193	cd src
194	make -f Makefile.msys2.sdl2
195
196Go to the root of the source directory and start angband by::
197
198	./angband.exe -uPLAYER
199
200The ncurse client may not be able to start properly from msys2 shell, try::
201
202	start bash
203
204and run::
205
206	export TERM=
207	./angband.exe -uPLAYER
208
209Using eclipse (Indigo) on Windows (with MinGW)
210~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
211
212* For eclipse with EGit, select File | Import..., Git | Projects from Git, Next >
213* Clone your/the upstream repo, or Add your existing cloned repo, Next >
214* Select "Use the New Projects Wizard", Finish
215* In the New Project Wizard, select C/C++ | Makefile Project with Existing Code, Next >
216* Give the project a name (Angband),
217  * navigate to the repo you cloned in "Existing Code Location",
218  * Select "C", but not "C++"
219  * Choose "MinGW GCC" Toolchain, Finish
220* Once the project is set up, r-click | Properties
221* Go to C/C++ Build | Toolchain Editor, select "Gnu Make Builder" instead of "CDT Internal Builder"
222* go to C/C++ Build, uncheck "Generate Makefiles automatically"
223
224You still need to run ./autogen.sh and ./configure manually, outside eclipse (see above)
225
226Using Visual Studio
227~~~~~~~~~~~~~~~~~~~
228
229Blue Baron has detailed instructions for setting this up at:
230
231    src/win/angband_visual_studio_step_by_step.txt
232