forked from draconisPW/PWMAngband
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcompiling.txt
685 lines (491 loc) · 26.1 KB
/
compiling.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
Compiling Instructions
======================
The methods for compiling PWMAngband vary by platform and by build system. If
you get PWMAngband working on a different platform or build system please let us
know so we can add to this file. Unless otherwise noted, all the commands
listed are to be run from top-level directory of the PWMAngband source files.
.. contents:: Contents
:local:
macOS
-----
To build the new Cocoa front-end::
cd src
make -f Makefile.osx
That'll create a self-contained Mac application, PWMAngband.app, in the directory
above src. You may use that application where it is or move it to wherever
is convenient for you.
By default, the current Makefile.osx builds an application that'll run natively
on x86_64 or arm64 machines. If only one of those architectures is of interest
to you or the version of Xcode you have doesn't support building both (a
typical error message in that case is something like ``/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:784:2: error: Unsupported architecture``),
you can change the architectures built by setting ARCHS on the command line of
make. To only build for x86_64, for instance, you would use::
cd src
make -f Makefile.osx clean
make -f Makefile.osx ARCHS=x86_64
(the clean step is to ensure that nothing from a previous build would cause
trouble; you'll typically need to do that if you've built it before and then
want to change the set of architectures to use). To build for multiple
architectures, use a list of architectures separated by whitespace, which
you'll have to quote. This is the equivalent to what Makefile.osx does by
default::
make -f Makefile.osx ARCHS="x86_64 arm64"
Debug build
~~~~~~~~~~~
This will generate a debugging build like that described in the Linux section::
cd src
make -f Makefile.osx clean
make -f Makefile.osx OPT="-g -O1 -fno-omit-frame-pointer -fsanitize=undefined -fsanitize=address"
The clean step is there to clean out object files that were compiled with the
default options. The "-g" adds debugging symbols.
"-O1 -fno-omit-frame-pointer" dials back the optimization to get call stack
traces that are easier to interpret. For even clearer call stack traces, you
could add "-fno-optimize-sibling-calls" to the options or omit optimization
entirely by replacing "-O1 -fno-omit-frame-pointer" with "-O0".
"-fsanitize=address -fsanitize=undefined" enables the AddressSanitizer and
UndefinedBehaviorSanitizer tools.
To run the generated executable under Xcode's command-line debugger, lldb, do
this if you are already in the src directory from the compilation step::
cd ../PWMAngband.app/Contents/MacOS
lldb ./pwmangband
Test cases
~~~~~~~~~~
To compile and run the unit tests, do this::
cd src
make -f Makefile.osx tests
If you want to rerun just one part, say monster/attack, of the unit tests,
that's most easily done from the top directory of the source distribution::
src/tests/monster/attack.exe
Somewhat older versions configure the test cases so they should be run
from src/tests. For those you would either use::
cd src/tests
monster/attack.exe
or, for the even older versions that put the test executables in src/tests/bin,
use::
cd src/tests
bin/monster/attack
Statistics build
~~~~~~~~~~~~~~~~
The Mac front end bypasses main.c and can not use the statistics front end.
It is possible to enable the debugging commands related to statistics (see
the descriptions for ``S``, ``D``, and ``P`` in :ref:`DebugDungeon`). To do so,
include "-DUSE_STATS" in the setting for OPT passed to make. The equivalent
of the standard build with those debugging commands enabled would be::
cd src
make -f Makefile.osx OPT="-DUSE_STATS -O2"
If you had already built everything without statistics enabled, you would need
to run either "rm wiz-stats.o" or "make -f Makefile.osx clean" immediately
after running "cd src".
Linux / other UNIX
------------------
Native builds
~~~~~~~~~~~~~
Linux builds using autotools. There are several different front ends that you
can optionally build (GCU, SDL, SDL2) using arguments to configure
such as --enable-sdl, --disable-curses, etc. Each front end has different
dependencies (e.g. ncurses, SDL libraries, etc).
If your source files are from rephial.org, from a "Source code" link on the
github releases page, or from cloning the git repository, you'll first need to
run this to create the configure script::
./autogen.sh
That is not necessary for source files that are from the github releases page
but not from a "Source code" link on that page.
To build PWMAngband to be run in-place, then run this::
./configure --with-no-install [other options as needed]
make
That'll create an executable in the src directory. You can run it from the
same directory where you ran make with::
src/pwmangband
To see what command line options are accepted, use::
src/pwmangband -?
Note that some of PWMAngband's makefiles (src/Makefile and src/tests/Makefile are
the primary offenders) assume features present in GNU make. If the default
make on your system is not GNU make, you'll likely have to replace instances
of make in the quoted commands with whatever will run GNU make. On OpenBSD,
for instance, that is gmake (which can be installed by running "pkg_add gmake").
On systems where there's several C compilers, ./configure may choose the
wrong one. One example of that is on OpenBSD 6.9 when building PWMAngband with
SDL2: ./configure chooses gcc but the installed version of gcc can't handle
the SDL2 header files that are installed via pkg_add. To override ./configure's
default selection of the compiler, use::
env CC=the_good_compiler ./configure [the appropriate configure options]
Replace the_good_compiler in that command with the command for running the
compiler that you want. For OpenBSD 6.9 when compiling with SDL2, you'd
replace the_good_compiler with cc or clang.
To build PWMAngband to be installed in some other location, run this::
./configure --prefix /path/to [other options as needed]
make
make install
To build SDL client to be installed in home directory::
./configure --prefix="$HOME/PWMAngband" --disable-curses --enable-sdl
make
make install
To show a list of command line arguments::
./configure --help
On some BSDs, you may need to copy install-sh into lib/ and various
subdirectories of lib/ in order to install correctly.
Compilation with CMake
~~~~~~~~~~~~~~~~~~~~~~
The compilation process with CMake requires a version greater than 3,
by default the compilation process uses the X11 front end unless
one or more of the other graphical front ends are selected. The graphical front
ends are: GCU, SDL, SDL2 and X11. All of the following generate a
self-contained directory, build, that you can move elsewhere or rename. To
run the result, change directories to build (or whatever you renamed it to) and
run ./PWMAngband .
To build PWMAngband with the X11 front end::
mkdir build && cd build
cmake ..
make
If you want to build the X11 front end while building one of the other
graphical front ends, the option to pass to cmake is -DSUPPORT_X11_FRONTEND=ON .
To build PWMAngband with the SDL front end::
mkdir build && cd build
cmake -DSUPPORT_SDL_FRONTEND=ON ..
make
To build PWMAngband with the SDL2 front end::
mkdir build && cd build
cmake -DSUPPORT_SDL2_FRONTEND=ON ..
make
To build PWMAngband with the GCU front end::
mkdir build && cd build
cmake -DSUPPORT_GCU_FRONTEND=ON ..
make
On OpenBSD (at least with OpenBSD 6.9), there's known issues with detecting
the software needed for the GCU front end. As a workaround, you could use
this instead::
mkdir build && cd build
mkdir -p ncursesw/include/ncursesw
ln -s /usr/include/ncurses.h ncursesw/include/ncursesw
mkdir -p ncursesw/lib
ln -s /usr/lib/libncursesw.so* ncursesw/lib
cmake -DCMAKE_PREFIX_PATH=`pwd`/ncursesw -DSUPPORT_GCU_FRONTEND=ON ..
make
You can build support for more than one of the graphical front ends by setting
all the desired SUPPORT_*_FRONTEND options when running cmake (the exception to
this are the SDL and SDL2 which can not be built at the same time). If you
want the executable to have support for sound, pass -DSUPPORT_SDL_SOUND=ON or
-DSUPPORT_SDL2_SOUND=ON to cmake (as with the SDL and SDL2 front ends, you
can't build support for both SDL and SDL2 sound; it is also not possible to
build the SDL front end with SDL2 sound or the SDL2 front end with SDL sound).
There are options to not build a self-contained installation and, instead,
organize the files for a typical Linux or Unix layout. One such option
installs the executable as setgid so the high score and save files can be
stored in a centralized location for multiple users. To enable that option,
pass -DSHARED_INSTALL=ON to cmake. To specify the group used for the setgid
executable, pass -DINSTALL_GROUP_ID=xxx to cmake where you replace xxx with
the name or number of the group to use. If you do not set the group, the games
group will be used. Another option creates a read-only installation with any
variable state, including the high score and save files, stored on a per-user
basis in the user's own directories. To enable that option, pass
-DREADONLY_INSTALL=ON to cmake. With either SHARED_INSTALL or READONLY_INSTALL,
you will need to run 'make install' after the other steps for compiling with
CMake. As an example, this would build a shared installation with an
executable that is setgid for the games group::
mkdir build && cd build
cmake -DSHARED_INSTALL=ON -DSUPPORT_GCU_FRONTEND=ON ..
make
sudo make install
Turning on both SHARED_INSTALL and READONLY_INSTALL is not supported and will
cause cmake to exit with an error. Turning either SHARED_INSTALL or
READONLY_INSTALL when SUPPORT_WINDOWS_FRONTEND is on is also not supported
and will cause cmake to exit with an error. To customize where the shared
and read-only installations place files, pass -DCMAKE_INSTALL_PREFIX=prefix
to install all the files within the given prefix (i.e. using
-DCMAKE_INSTALL_PREFIX=/opt/PWMAngband-1.6.0 would place all the files within
/opt/PWMAngband-1.6.0 or its subdirectories). For finer-grained placement
of the files within the given prefix, you could also set CMAKE_INSTALL_BINDIR
(for the subdirectory of prefix where the executable will be placed; by
default that is bin), CMAKE_INSTALL_DATAROOTDIR (for the subdirectory of
prefix to hold read-only data not configured for the site; by default that is
share), CMAKE_INSTALL_SYSCONFDIR (for the subdrectory of prefix to hold data
configured for the site; by default that is etc), and
CMAKE_INSTALL_SHAREDSTATEDIR (for the subdirectory of prefix to hold writable
persistent state; by default that is com). Because paths to the data are
hardwired in the executable, setting the destination directory when running
make (i.e. by setting DESTDIR) is not supported and will not work in general:
set the destination when running cmake by setting the variables mentioned above.
Cross-building for Windows with Mingw
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many developers (as well as the auto-builder) build PWMAngband for Windows using
Mingw on Linux. This requires that the necessary Mingw packages are all
installed.
This type of build now also uses autotools so the overall procedure is very
similar to that for a native build. The key difference is setting up to
cross-compile when running configure.
If your source files are from rephial.org, from a "Source code" link on the
github releases page, or from cloning the git repository, you'll first need to
run this to create the configure script::
./autogen.sh
That is not necessary for source files that are from the github releases page
but not from a "Source code" link on that page.
Then configure the cross-compilation and perform the compilation itself::
./configure --enable-win --build=i686-pc-linux-gnu --host=i686-w64-mingw32
make install
You may need to change the --build and --host options there to match your
system. Mingw installs commands like 'i686-w64-mingw32-gcc'. The value of --host
should be that same command with the '-gcc' removed. Instead of i686 you may
see i686, amd64, etc. The value of --build should be the host you're building
on (see http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.68/html_node/Specifying-Target-Triplets.html#Specifying%20Names for
gory details of how these triplets are arrived at). The 'make install' step
only works with very recent version. For older ones, use this instead of the
last step::
make
cp src/pwmangband.exe .
cp src/win/dll/*.dll .
To run the result, you can use wine like this::
wine pwmangband.exe
TODO: except for recent versions (after PWMAngband 1.6.0) you likely need to
manually disable curses (add --disable-curses to the options passed to
configure), or the host curses installation will be found causing the build
process to fail when linking pwmangband.exe (the error message will likely be
"cannot find -lncursesw" and "cannot find -ltinfo"). Most of the --with or
--enable options for configure are not appropriate when using --enable-win.
The ones that are okay are --with-private-dirs (on by default),
--with-gamedata-in-lib (has no effect), and --enable-release.
A build using Mingw cross-compiler is also possible with CMake. You will
need to have a toolchain file appropriate for Mingw on your system. Some
information on toolchain files can be found at https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html .
On a Debian 11 system using Mingw from the gcc-mingw-w64 package (that puts
the Mingw executables in /usr/bin with the prefix, i686-w64-mingw32-, and
has the other files for cross-compiling in /usr/i686-w64-mingw32), this
worked as the contents of a minimal toolchain file::
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
With Wine installed on that system, you could add this to the toolchain file::
set(CMAKE_CROSSCOMPILING_EMULATOR wine)
so the unit test cases could be run from cmake (for instance with
"cmake --build . --target allunittests").
If the toolchain file was saved as /home/user/mingw-cross.cmake, then you could
use this to perform the build::
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/home/user/mingw-cross.cmake ..
cmake --build .
That will leave an PWMAngband.exe and the needed .dll files in the directory
where cmake was run. That executable can be run with wine:
wine PWMAngband.exe
Debug build
~~~~~~~~~~~
**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).
When 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 pwmangband::
./configure [options]
SANITIZE_FLAGS="-fsanitize=undefined -fsanitize=address" make
Note that compiling with these tools will require installing additional dependencies: libubsan libasan (names of the packages might be different in your distribution).
There is probably a way to get these tools to work on Windows. If you know how, please add the information to this file.
Test cases
~~~~~~~~~~
To compile and run the unit tests if you used ./configure --with-no-install,
do this::
make tests
If you want to rerun just one part, say monster/attack, of the unit tests,
that's most easily done by directly running from the top-level directory::
src/tests/monster/attack.exe
Previous versions put the test executables in src/tests/bin. With those
versions, the line above would be::
src/tests/bin/monster/attack
There's a separate set of tests that use scripts to control a character in
the full game. To run those tests, you'll need to enable the test module
when running configure and then run the run-tests script in the top-level
directory::
./configure --with-no-install --enable-test
make
./run-tests
To compile and run the unit tests and run the run-tests script while using
CMake, do the following::
mkdir build && cd build
cmake -DSUPPORT_TEST_FRONTEND=ON ..
make alltests
If you only want the unit tests while using CMake, it's a little simpler::
mkdir build && cd build
cmake ..
make allunittests
Statistics build
~~~~~~~~~~~~~~~~
If building directly for Linux/Unix using configure, you can get the statistics
front end and support for the debugging commands related to statistics (see
the descriptions for ``S``, ``D``, and ``P`` in :ref:`DebugDungeon`) by
including --enable-stats in the options to configure. For that to work, you'll
need to have sqlite3's headers and libraries installed (on Debian and Ubuntu,
the libsqlite3-dev package and its dependencies provides those). If using
CMake, pass -DSUPPORT_STATS_FRONTEND=ON to cmake to get the statistics front
end and support for the debugging commands related to statistics; like builds
with configure that use --enable-stats, that requires sqlite3. With CMake, you
also have an the option to only include support for the debugging commands
related to statistics: pass -DSUPPORT_STATS_BACKEND=ON to cmake and either do
nothing for SUPPORT_STATS_FRONTEND or explicitly turn it off by passing
-DSUPPORT_STATS_FRONTEND=OFF to cmake.
When cross-compiling for Windows, the statistics front end is not useful
(the Windows front end bypasses main.c and can not use the statistics front
end). With configure, you could include support for debugging commands
related to statistics by setting CFLAGS to include -DUSE_STATS::
./configure [your cross-compiling options] --enable-win CFLAGS=-DUSE_STATS
Windows
-------
Using MinGW
~~~~~~~~~~~
This build now also uses autotools, so should be very similar to the Linux
build. Open the MinGW shell (MSYS) by running msys.bat.
If your source files are from rephial.org, from a "Source code" link on the
github releases page, or from cloning the git repository, you'll first need to
run this to create the configure script::
./autogen.sh
That is not necessary for source files that are from the github releases page
but not from a "Source code" link on that page.
Then run these commands::
./configure --enable-win
make install
The last step only works with very recent versions. For older ones, use
"make" rather than "make install" and copy src/pwmangband.exe,
src/win/dll/libpng12.dll, and src/win/dll/zlib1.dll to the top-level directory.
Using Cygwin (with MinGW)
~~~~~~~~~~~~~~~~~~~~~~~~~
Use this option if you want to build a native Windows executable that
can run with or without Cygwin.
Use the Cygwin setup.exe to install the mingw-gcc-core package and any
dependencies suggested by the installer.
If your source files are from rephial.org, from a "Source code" link on the
github releases page, or from cloning the git repository, you'll first need to
run this to create the configure script::
./autogen.sh
That is not necessary for source files that are from the github releases page
but not from a "Source code" link on that page.
Then run these commands::
./configure --enable-win --host=i686-pc-mingw32
make install
The last step only works with very recent versions. For older ones, use
"make" rather than "make install" and copy src/pwmangband.exe,
src/win/dll/libpng12.dll, and src/win/zlib1.dll to the top-level directory.
If you want to build the Unix version of PWMAngband that uses X11 or
Curses and run it under Cygwin, then follow the native build
instructions (./autogen.sh; ./configure; make; make install).
Using MSYS2 (with MinGW64)
~~~~~~~~~~~~~~~~~~~~~~~~~~
Install the dependencies by::
pacman -S make mingw-w64-x86_64-gcc
The additional dependency for ncurses is::
pacman -S mingw-w64-x86_64-ncurses
Additional dependencies for the SDL2 client are::
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image \
mingw-w64-x86_64-SDL2_ttf
Then run the following to compile with ncurses::
cd src
make -f Makefile.msys2
For SDL2, do::
cd src
make -f Makefile.msys2.sdl2
Very recent versions of Makefile.msys2.sdl2 allow use of SDL2 sound; to build
with that you'll need SDL2_mixer installed in addition to the other SDL2
libraries mentioned above::
pacman -S mingw-w64-x86_64-SDL2_mixer
Then the executable with SDL2 sound support can be built with::
cd src
make -f Makefile.msys2.sdl2 SOUND=yes
Once built, go to the root of the source directory and start pwmangband by::
./pwmangband.exe -uPLAYER
The ncurses client may not be able to start properly from msys2 shell, try::
start bash
and run::
export TERM=
./pwmangband.exe -uPLAYER
Using eclipse (Indigo) on Windows (with MinGW)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* For eclipse with EGit, select File | Import..., Git | Projects from Git, Next >
* Clone your/the upstream repo, or Add your existing cloned repo, Next >
* Select "Use the New Projects Wizard", Finish
* In the New Project Wizard, select C/C++ | Makefile Project with Existing Code, Next >
* Give the project a name (PWMAngband),
* navigate to the repo you cloned in "Existing Code Location",
* Select "C", but not "C++"
* Choose "MinGW GCC" Toolchain, Finish
* Once the project is set up, r-click | Properties
* Go to C/C++ Build | Toolchain Editor, select "Gnu Make Builder" instead of "CDT Internal Builder"
* go to C/C++ Build, uncheck "Generate Makefiles automatically"
You still need to run ./autogen.sh, if your source files are from a
"Source code" link on the github releases page or from cloning the
git repository, and ./configure manually, outside eclipse (see above)
Using Visual Studio
~~~~~~~~~~~~~~~~~~~
Blue Baron has detailed instructions for setting this up at:
src/win/pwmangband_visual_studio_step_by_step.txt
Statistics build
~~~~~~~~~~~~~~~~
The Windows front end bypasses main.c and can not use the statistics front end.
It is possible to enable the debugging commands related to statistics (see
the descriptions for ``S``, ``D``, and ``P`` in :ref:`DebugDungeon`). To do
so, set your compiler options so that the USE_STATS preprocessor macro is set.
When using mingw (either stand-alone or as part of Cygwin) and configure,
include CFLAGS=-DUSE_STATS in the options to configure to do that.
Nintendo DS / Nintendo 3DS
--------------------------
Builds for the Nintendo DS are made using devkitARM and libnds (or libctru for
the Nintendo 3DS respectively). All required dependencies can be installed by
selecting the appropriate package group while following the installation
instructions for devkitPro ( https://devkitpro.org/wiki/Getting_Started ).
The executable can then be built using::
cd src
make -f Makefile.nds
This will generate ``pwmangband.nds`` in the current directory. For the Nintendo
3DS, replace the ``Makefile.nds`` part of the command with ``Makefile.3ds``,
and ``pwmangband.3dsx`` will be generated instead.
Debugging
~~~~~~~~~
Homebrew can be debugged using a gdbstub-enabled emulator, such as a Windows Dev+ build
of DeSmuMe (if you really dare to, note that it is very slow compared to real hardware)
for the Nintendo DS or Citra for the Nintendo 3DS. A Nintendo 3DS that has been modified
with custom firmware (such as Luma3DS) may also have the ability to debug homebrew on-device.
It is recommended to set/export ``NDS_DEBUG=1`` and to do a clean build when debugging,
as this disables some optimization and enables more debugging information.
Once the GDB server has been set up (and the host and port noted), the GDB client
can be loaded with the executable information::
/path/to/devkitARM/bin/arm-none-eabi-gdb pwmangband.elf
The ``pwmangband.elf`` file is a byproduct from the build process, and it has to match
the executable that is currently running in the emulator or on the device.
It is always named ``pwmangband.elf`` for the Nintendo 3DS, and it's always either
``pwmangband.arm7.elf`` or ``pwmangband.arm9.elf`` for the Nintendo DS, depending on
which processor should be debugged (as the main game runs on the ARM9 core exclusively,
this will almost always be the core that should be debugged).
Once the GDB command prompt is available, the following command can be used to
connect to the target device::
target remote <host>:<port>
Afterwards, the debugging target will pause automatically and it can be debugged as usual
using GDB.
Cross-building for DOS with DJGPP
---------------------------------
These instructions were written using a Slackware64-15.0 host.
Install the following cross-compiler:
https://github.com/andrewwutw/build-djgpp
git clone https://github.com/andrewwutw/build-djgpp.git
cd build-djgpp
DJGPP_PREFIX=$HOME/local/cross-djgpp ./build-djgpp.sh 10.3.0
Then build pwmangband using the cross-compiler:
cd pwmangband/src
PATH=$PATH:$HOME/local/cross-djgpp/bin
make -f Makefile.ibm
Optionally build the documentation (requires Sphinx):
make -f Makefile.ibm docs
To create the pwmangband.zip distribution
make -f Makefile.ibm dist
Documentation
-------------
To convert the documentation from restructured text to the desired output
format, you'll need Sphinx ( https://www.sphinx-doc.org/en/master/ )
and, unless you change the theme in the documentation configuration, the
sphinx-better-theme ( https://pypi.org/project/sphinx-better-theme/ ; which
can be installed via pip using::
pip install sphinx-better-theme
).
With those utilities in place and sphinx-build in your path, you can perform
the conversion by running::
make html
in the docs subdirectory of the top-level directory in the source files.
That will generate a _build/html directory with the result of the conversion;
_build/html/index.html is the top-level help with links to everything else.
Other output formats besides HTML are possible. Run::
make
without any arguments in the docs subdirectory to see the formats that Sphinx
can generate.