Files
nethack/sys/windows/build-msys2.txt
nhmall fec6320e68 rename sys/windows/Makefile.mingw32 to GNUmakefile
GNU make looks first for a file called GNUmakefile, ahead of
looking for Makefile and then makefile.

Renaming sys/windows/Makefile.mingw32 to sys/windows/GNUmakefile
allows:

o src/GNUmakefile (for use by GNU make) and src/Makefile (for use
  Microsoft nmake) to both reside in the src folder during build.

o src/GNUmakefile will be used by GNU make, without having to
  explicitly specify "-f GNUmakefile" on the GNU make command line.

o src/Makefile will be used by Microsoft nmake, without having to
  explicitly specify "-f Makefile" on the Microsoft nmake command line.

For the gcc build, the movemement of sys/windows/GNUmakefile needs
to be copied to src/GNUmakefile as part of the build process (see
sys/windows/build-msys2.txt).

For the Microsoft Visual Studio command line build with nmake,
sys/windows/Makefile.nmake needs to be copied to src/Makefile as
part of the build process (see sys/windows/build-nmake.txt).

They are both copied to the src folder from their respective
repository source file names when the nhsetup.bat file is used.
2024-12-02 19:04:08 -05:00

153 lines
6.1 KiB
Plaintext

Building NetHack using MSYS2
Prerequisite Requirements:
o MSYS2
- https://www.msys2.org/
- Download and run the installer, and start the UCRT64 shell.
then
pacman -S mingw-w64-ucrt-x86_64-gcc
pacman -S git
pacman -S make
pacman -S vim (or your editor of choice)
pacman -S man (otherwise "git help foo" will not work)
pacman -S perl-doc (otherwise "git nhhelp foo" will not work,
so only needed if you use nhgitset.pl)
o Lua
o pdcursesmod (Only required if curses interface support is desired)
Instructions for obtaining these are later in this file.
/---------------------------------------------\
| Directories for a Windows NetHack build |
\---------------------------------------------/
(NetHack-top)
|
+-----+------+-----+-------+-----------+-----------+-----~-----+------+
| | | | | | | | |
dat doc include lib src sys win submodules util
| | | |
+----------+ +------+ +----+ +----+
| | | | | | | |
| | | | | | | |
lua-5.4.6 pdcursesmod share windows tty win32 lua pdcursesmod
|
vs
|
+----------+-------+--------+--------+-----------+-------+-----+------+
| | | | | | | | |
makedefs NetHack NetHackW PDCurses PDCursesGui tile2bmp tilemap tiles uudecode
/-----------------------------------------------------------\
| Building from MSYS2 bash |
\-----------------------------------------------------------/
Required components that are not bundled in the NetHack repository, but
are required to build NetHack yourself.
Lua
NetHack 3.7 for Windows requires 3rd party Lua source that is not part
of the NetHack distribution or repository.
A bash shell script for fetching prerequisite
sources is available, and can be run as follows from the top of
the NetHack source tree to obtain lua:
sh sys/windows/fetch.sh lua
Curses
If you want to include curses interface support in NetHack 3.7 for
3rd part pdcursesmod source code is required and is not part of the
NetHack distribution or repository.
A bash shell script for fetching prerequisite
sources is available, and can be run as follows from the top of
the NetHack source tree to obtain pdcursesmod:
sh sys/windows/fetch.sh pdcursesmod
Building
Two different versions of NetHack will be built for Windows from the
command line using the Makefile approach:
A tty port utilizing the Win32 Console I/O subsystem Console,
and a curses interface in an executable called NetHack.exe.
A Win32 native port built on the Windows API Graphical NetHack,
and graphical curses in an executable called NetHackW.exe.
The Makefile configurations will build both NetHack.exe and NetHackW.exe
and will be able to use the same datafiles, save files and bones files.
Since the last official release of NetHack, compilers and computer
architectures have evolved and you can now choose whether to build
a 32-bit x86 version, or a 64-bit x64 version. The default Makefile
is set up for a 32-bit x86 version, but that's only because it will
run on the largest number of existing Windows environments. Change it if you
want. Be aware that NetHack's save files and bones files in the 3.7.0
release are not interchangeable between the 32-bit version and the
64-bit version (or between different platforms).
I. Dispelling the Myths:
Compiling NetHack for Windows is not as easy as it sounds, nor as hard
as it looks, however it will behoove you to read this entire section
through before beginning the task.
We have provided GNUmakefile in sys/windows/GNUmakefile, which you use
from the bash Windows command shell included with MSYS2. It is called
GNUmakefile because that is the first name searched for by the GNU
make utility thus preventing conflict with the Makefile used by the
Microsoft nmake utility.
II. To compile your copy of NetHack on a Windows machine using MSYS2:
Setting Up
1. Change your current directory the top of the nethack
source tree if it isn't there already.
2. Execute the following command to place copies of the Makefiles in
the src subfolder.
cp sys/windows/GNUmakefile* src
3. Change your current directory to the src subfolder of the nethack
source tree. The following command assumes you are still in the
sys/windows folder from steps #1 and #2 above:
cd src
Compiling
4. Now that everything is set up, you should be ready to start the
process.
Your current directory should be the NetHack src directory.
Issue these following commands, which will find and use GNUmakefile
by default:
make clean
make depend
make
If all goes well, intermediate NetHack files will be placed in the
binary subfolder of the NetHack tree, and the final NetHack package
for windows will be in the package subfolder.
Notes:
1. To rebuild NetHack after changing something, change your current directory
to src and issue the following command:
make
2. An alternative to MSYS2 may be MinGW-w64 - winlibs standalone build.
That has not been tested by us at time of writing.
MinGW-w64 - winlibs standalone build
- https://github.com/brechtsanders/winlibs_mingw
- Download one of the releases from
https://github.com/brechtsanders/winlibs_mingw/releases
and extract the contents into a folder (ideally in a folder
without spaces in the path), and add the location of the
subfolder containing gcc.exe to your PATH.